mirror of
https://github.com/yogeshojha/rengine.git
synced 2026-10-21 15:51:30 +02:00
The unit of exposure is now a service — (ip, port) — not a bare open port. Pipeline (EXPANSION): L0 produce hosts, L1 cdn_check + passive_ports, L2 port_scan, L3 http_probe, L4 screenshot/waf_detect/service_fingerprint. - cdn_check applies to every target type and records cdn_type, so a domain scan finally knows which addresses are CDN-fronted. cdn/waf is an edge you do not own (edge ports only); cloud is your own machine (scanned in full). - port_scan decides and records a per-address scan_policy (full/web/skip) honouring the scan context's excluded_ips, and offers port profiles, exclusions, scan type, a tarpit threshold and an address budget. - passive_ports reads Shodan internetdb through naabu -passive: keyless, touches_target=False, so a passive-intensity scan still gets exposure data. - http_probe seeds its host x port matrix from open ports and folds every live response back onto the port (is_http, tls, product). - service_fingerprint names the software behind non-web ports with a pure Python banner prober (tools/banner/), including a SOCKS5 CONNECT so it honours the context proxy. naabu -sV is unimplemented. - shared/definitions/ports.py is the one vocabulary; ip_inventory and port_inventory are the only writers of ip_addresses/ports. - open_ports_found is measured from the table (DERIVED_COUNTS): four stages write ports, so summing stage results double-counted. - naabu failures no longer report zero open ports as success. Surfaces: a Services tab (SERVICE_QUERY grammar, 16 fields, 18 counted leads, 9 group dimensions, detail sheet) built on the shared results shell, and an outlier-first Exposure panel on the Overview. Every count is a promise — leads, groups and panel pivots were verified to equal the row count they land on. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BnC2xMMzV6WQnpDp5zcXoU
91 lines
2.9 KiB
Python
91 lines
2.9 KiB
Python
from shared.definitions.tools import SCAN_TOOLS
|
|
from shared.enums.target import TargetType
|
|
from shared.models.scan_engine import (
|
|
EngineCatalog,
|
|
EnginePreset,
|
|
StageCatalogEntry,
|
|
StageField,
|
|
ToolOption,
|
|
)
|
|
from stages.presets import PRESETS, preset_stages
|
|
from stages.registry import phases, rate_tools, stages
|
|
|
|
|
|
def _resolve(prop: dict, defs: dict) -> dict:
|
|
"""Flatten a $ref/allOf property (an enum field) onto its definition."""
|
|
ref = prop.get("$ref") or next(
|
|
(m.get("$ref") for m in prop.get("allOf") or [] if isinstance(m, dict)), None
|
|
)
|
|
if not ref or not ref.startswith("#/$defs/"):
|
|
return prop
|
|
target = defs.get(ref.rsplit("/", 1)[-1])
|
|
return {**target, **prop} if isinstance(target, dict) else prop
|
|
|
|
|
|
def _field_specs(spec) -> list[StageField]:
|
|
schema = spec.schema
|
|
defs = schema.get("$defs") or {}
|
|
defaults = spec.defaults
|
|
out: list[StageField] = []
|
|
for name, raw in (schema.get("properties") or {}).items():
|
|
prop = _resolve(raw, defs)
|
|
options = prop.get("enum") or prop.get("options")
|
|
out.append(
|
|
StageField(
|
|
name=name,
|
|
title=prop.get("title") or name.replace("_", " ").capitalize(),
|
|
description=prop.get("description") or None,
|
|
type=_JSON_TYPES.get(prop.get("type"), prop.get("type") or "string"),
|
|
default=defaults.get(name, prop.get("default")),
|
|
options=list(options) if options else None,
|
|
option_labels=prop.get("option_labels") or None,
|
|
minimum=prop.get("minimum"),
|
|
maximum=prop.get("maximum"),
|
|
scale=prop.get("scale"),
|
|
)
|
|
)
|
|
return out
|
|
|
|
|
|
def build_catalog() -> EngineCatalog:
|
|
return EngineCatalog(
|
|
phases=[phase for phase, _ in phases()],
|
|
stages=[
|
|
StageCatalogEntry(
|
|
name=spec.name,
|
|
title=spec.title,
|
|
description=spec.description,
|
|
phase=spec.phase,
|
|
level=spec.level,
|
|
applies_to=sorted(spec.applies_to),
|
|
tools=list(spec.tools),
|
|
api_keys=list(spec.api_keys),
|
|
requires_api_keys=spec.requires_api_keys,
|
|
touches_target=spec.touches_target,
|
|
defaults=spec.defaults,
|
|
fields=_field_specs(spec),
|
|
)
|
|
for spec in stages()
|
|
],
|
|
rate_tools=list(rate_tools()),
|
|
tool_options=[ToolOption(**t.model_dump()) for t in SCAN_TOOLS],
|
|
presets=[
|
|
EnginePreset(
|
|
name=p.name,
|
|
title=p.title,
|
|
description=p.description,
|
|
stages=preset_stages(p.name),
|
|
)
|
|
for p in PRESETS
|
|
],
|
|
target_types=[t.value for t in TargetType],
|
|
)
|
|
|
|
|
|
_JSON_TYPES = {
|
|
"integer": "integer",
|
|
"number": "number",
|
|
"boolean": "boolean",
|
|
"string": "string",
|
|
}
|