Contracts¶
Shared interfaces between services. If you change these, update every service.
Services¶
| Service | Role | Depends on |
|---|---|---|
orchestrator |
HTTP API, scope service, job dispatch, audit sink | postgres, redis |
workers/passive |
passive recon (CT logs, DNS, GitHub search, Shodan, Wayback) | orchestrator |
workers/active |
authorized probing (httpx, naabu, katana, nuclei, tlsx, playwright) | orchestrator |
intel |
NVD/EPSS/KEV ingestion, CVE↔asset matching | postgres |
correlation |
policies-as-code, chain detection, blast-radius scoring | orchestrator |
dashboard |
React UI | orchestrator |
Postgres¶
Schema in /schema. Everyone connects via DATABASE_URL, a PostgreSQL async DSN (asyncpg). Services should use the ORM-free async helper in orchestrator/app/db.py as a reference (or roll their own; schema is the contract). Postgres initializes schema files in alphabetical filename order, so 006_patches.sql applies after the main tables.
Key tables:
scope_entries/scope_decisions— the allowlist and its audit log.scope_entries.metadata(JSONB) carries opaque per-entry config, e.g.{"politeness": {"concurrency": 1, "delay_ms": 500}}.assets/asset_edges/asset_snapshots— the graphfindings/finding_chains— issues and compositesoutbound_log/scans/schedules— audit + job state.scans.parent_scan_idreferences the parent scan for sub-steps of an orchestration (e.g.full_recon).cves/cve_matches/intel_cursors— threat intel
Redis queues¶
queue:passive— passive discovery jobsqueue:active— active probing jobsqueue:correlate— correlation / chain-detection jobsstream:events— fan-out events; see Event stream below for the full list
Job format (JSON, in a single job field of the stream entry):
{
"scan_id": "uuid",
"kind": "passive_subdomains | active_http_probe | nuclei_scan | ...",
"target": "normalized.host.name",
"config": {},
"scope_matched_entry": 42,
"parent_scan_id": "uuid-or-null"
}
target is already normalized by the orchestrator before enqueue (scheme / port / path stripped, lowercased, trailing dot gone).
Orchestrator HTTP API¶
Base URL: http://orchestrator:8080 (inside compose), http://localhost:8080 (dev).
Scope¶
GET /v1/scope— list entries (each row carriesmetadata).POST /v1/scope— add entry. Body:{kind, value, added_by, auth_doc_ref?, expires_at?, notes?, metadata?}.metadata.politenessmay carry{concurrency?, delay_ms?}, which the active worker applies viaPolitenessLimiter.configure_host(...)after a scope-check match. Emitsscope_addedon success.DELETE /v1/scope/{id}— deactivate entry. Emitsscope_removed.POST /v1/scope/check—{target}→{allow, matched_entry?, matched_entry_metadata, normalized, reason}.matched_entry_metadatais the matched entry'sscope_entries.metadataJSONB (empty object on no match or no metadata). The active worker'sscope_guarduses this to configure politeness.- Every worker MUST call this before touching a target. Decisions are audit-logged.
GET /v1/scope/{id}/decisions?limit=10&offset=0— recentscope_decisionsrows for a given scope entry, newest first. Defaultlimit=10.
Scope mutations (POST, DELETE) go through the require_scope_admin dependency (no-op in the MVP; wire real auth before external exposure).
Scans¶
POST /v1/scans—{kind, target, config?, priority?, parent_scan_id?}→ returns a fullScanOut.- Scope-checked before enqueue when
parent_scan_idis absent or references an unknown scan. - When
parent_scan_idreferences an existing scan, the child inherits the parent's scope decision (no newscope_decisionsrow written) and the target is still normalized for storage. - Scan kinds in the Do-not-build list below are refused with 400 before any scope-check runs.
GET /v1/scans/{id}— status + result_summary.GET /v1/scans?target=&status=&parent_scan_id=&limit=&offset=— list.PATCH /v1/scans/{id}— body{status?, result_summary?, error?, worker_id?}.started_at = NOW()on first transition torunning;finished_at = NOW()on first transition to a terminal state (completed,failed,cancelled).result_summarymerges (||) into the stored JSONB.- Idempotent: re-posting the same status is a no-op on timestamps and emits no event.
- 404 on unknown scan id.
- Emits one of
scan_started/scan_completed/scan_failedonly on an actual status transition. POST /v1/scans/{id}/start—{worker_id?}→ PATCH{status: running, worker_id}.POST /v1/scans/{id}/complete—{result_summary?}→ PATCH{status: completed, result_summary}.POST /v1/scans/{id}/fail—{error?}→ PATCH{status: failed, error}.
Assets¶
GET /v1/assets?kind=&value=&canonical=&limit=&offset=— list.GET /v1/assets/{id}— asset + depth-1 neighbourhood.GET /v1/assets/{id}/graph?depth=2— BFS subgraph.GET /v1/assets/graph?limit=500— whole-surface top-N most-connected assets + the edges among them.limitis capped at 2000; the server rejects larger values. Each node carriesdegreeandopen_high_crit_count(open findings with severity ∈ {high, critical}).POST /v1/assets/bulk— upsert from workers. Body:{items: [{kind, value, source, canonical?, confidence?, metadata?}]}. The orchestrator canonicalizes.- Edge sentinel: an item with
kind == "_edge"is routed toasset_edgesinstead ofassets. The item'smetadatamust carry{src_kind, src_canonical, dst_kind, dst_canonical, edge_kind, edge_metadata?}; the older{src_value, dst_value, kind}shape is also accepted. Both endpoints must already exist inassets; if either is missing, the edge is skipped and counted inedges_skipped_missing_endpoint. - Response adds the counters
edges_inserted,edges_updated,edges_skipped_missing_endpoint. - Emits
asset_addedper inserted asset andedge_addedper inserted edge. POST /v1/edges/bulk— dedicated edges endpoint for callers that don't need the sentinel. Body:{edges: [{src_id?, dst_id?, src_kind?, src_canonical?, dst_kind?, dst_canonical?, kind, metadata?}]}. Either id-based or (kind, canonical)-based references work. Returns{edges_inserted, edges_updated, edges_skipped_missing_endpoint}. Emitsedge_addedper inserted edge.
Findings¶
GET /v1/findings?severity=&status=&asset_id=&rule_source=&kev=&q=&limit=&offset=— paged envelope{items, total, limit, offset}. Defaults:limit=50,offset=0.kev=truekeeps only findings withmetadata.kev=trueOR an asset that has at least onecve_matchesrow to a KEV CVE.qis a case-insensitive substring match againsttitle || description.GET /v1/findings/list?...— legacy bare-list response for pre-pagination callers (same filters).GET /v1/findings/{id}— returns{finding, asset, chains: [...]}.chainsare anyfinding_chainsrows whosefinding_idsarray contains this id.PATCH /v1/findings/{id}—{status, assigned_to, notes}. Publishesfinding_closedon transition to any terminal status (fixed,wontfix,false_positive,accepted_risk).POST /v1/findings/bulk— upsert from workers / correlation / intel. Body:{items: [FindingIn]}.- Each item provides either
asset_id(preferred) orasset_value(plus optionalasset_kind; defaults toendpoint). Withasset_value, the orchestrator upserts the asset by (kind, canonical(value)) before attaching the finding. - 422 if neither
asset_idnorasset_valueis supplied. - Emits
finding_openedper inserted finding. Updates don't re-emit. GET /v1/chains?severity=&anchor_asset_id=&limit=&offset=— correlated finding chains. Each row includes the anchor asset summary (anchor_asset) and the matched findings' severities (finding_severities).POST /v1/chains— upsert from correlation. Body:{chain_rule_id, severity, title, description, impact_narrative?, blast_radius_score?, finding_ids: [uuid], anchor_asset_id?: uuid, metadata?}.- If
anchor_asset_idis present: upsert by(chain_rule_id, anchor_asset_id). - Otherwise: upsert by
(chain_rule_id, metadata.fingerprint). The correlator should setmetadata.fingerprint; if missing, the orchestrator computes a stable fingerprint from sortedfinding_idsso re-posts still upsert cleanly. - 400 if any
finding_iddoesn't exist. - Emits
chain_detectedon insert only.
Outbound audit¶
POST /v1/outbound/bulk—{entries: [...]}. Each entry maps 1:1 to anoutbound_logrow (worker,target,tool,method?,request_summary?,response_code?,scope_matched,scope_entry_id?,started_at,duration_ms?,bytes_in?,bytes_out?,error?).started_atmay be a float epoch (whatworkers/activesends) or an ISO 8601 / datetime value. Bulk inserted viaexecutemany. Returns{inserted}.
Timeline¶
GET /v1/timeline?from=&to=&sample=— asset diffs + new findings per day.
SSE event mirror¶
GET /v1/events?since=<stream-id-or-$>— SSE tail ofstream:events.
Scope enforcement (the rule nobody breaks)¶
Every outbound request from every worker goes through this check:
- Normalize the target (strip scheme, port, path; lowercase; resolve hostname to IP if IP match requested).
POST /v1/scope/checkto the orchestrator. Ifallow=false, the worker MUST abort and log.- On allow, emit the request, then write an
outbound_logrow (individually or viaPOST /v1/outbound/bulk). - Second-line defense: egress HTTP client is wrapped so it also calls
scope_checklocally from cached entries, fail-closed if cache is stale beyond 60s.
Per-host politeness is configurable on the matching scope entry (scope_entries.metadata.politeness.{concurrency, delay_ms}); the active worker reads it from matched_entry_metadata on the scope-check response.
Event stream¶
Workers and services publish to Redis stream stream:events. Current events:
| event | emitted by | fields |
|---|---|---|
asset_added |
POST /v1/assets/bulk, POST /v1/findings/bulk (when asset_value upserts a new row) |
asset_id, kind, value, canonical, source, ts |
asset_updated |
(reserved; not emitted on update today) | — |
edge_added |
POST /v1/assets/bulk (_edge items), POST /v1/edges/bulk |
edge_id, src_id, dst_id, kind |
finding_opened |
POST /v1/findings/bulk (insert only) |
finding_id, asset_id, severity, rule_id, rule_source, ts |
finding_closed |
PATCH /v1/findings/{id} on terminal status transition |
finding_id, status |
chain_detected |
POST /v1/chains (insert only) |
chain_id, chain_rule_id, severity, anchor_asset_id, finding_count |
scan_started |
PATCH /v1/scans/{id} (status→running), POST /v1/scans/{id}/start |
scan_id, kind, target, worker_id |
scan_completed |
PATCH or POST /v1/scans/{id}/complete |
scan_id, kind, target |
scan_failed |
PATCH or POST /v1/scans/{id}/fail |
scan_id, kind, target, error |
scope_added |
POST /v1/scope |
scope_entry_id, kind, value, added_by |
scope_removed |
DELETE /v1/scope/{id} |
scope_entry_id, kind, value |
cve_published |
intel service | cve_id, cvss, affected |
Correlation and dashboard subscribe to this stream.
Do-not-build list (hard rules)¶
The following are out of scope for every service in this repo. Do not add them, do not add hooks for them, do not add configuration flags that enable them:
- Auto-exploitation of discovered vulnerabilities
- Credential stuffing, password spraying, brute force
- Rate-limit evasion, timing-based evasion, header manipulation to bypass WAFs
- Stealth / low-and-slow / fragmentation scanning modes
- Session hijacking, token theft, anti-forensics
- Data exfiltration tooling
- Anything aimed at targets not represented in
scope_entries
POST /v1/scans refuses kind values in the orchestrator's _REFUSED_KINDS list with 400 before scope-check, so no audit row is written for attack-aid intents.
This tool is a defensive asset intelligence platform. Workers probe politely and transparently. The point is visibility, not access.