Skip to content

agent: ingest nuclei, httpx and ffuf output in ingest_scan_output - #215

Merged
BaaRai merged 1 commit into
mainfrom
feat/scan-ingest-jsonl
Nov 13, 2026
Merged

BaaRai merged 1 commit into
mainfrom
feat/scan-ingest-jsonl

Conversation

@BaaRai

@BaaRai BaaRai commented Nov 13, 2026

Copy link
Copy Markdown
Owner

What it does

Extends ingest_scan_output (added in #214 for nmap XML) with three more scanner formats. The worker writes the scanner output to a file, then calls the tool with the format and path instead of reading the raw output:

format write it with assets facts
nuclei-jsonl nuclei -jsonl -o <file> the scanned target (host): an HTTP service when it is an http(s) URL, otherwise an ip or subdomain asset, only when the host validates one per result
httpx-jsonl httpx -json -o <file> one HTTP service per URL (status, length, title, tech, IP) one per URL
ffuf-json ffuf -of json -o <file> one URL asset per result (status, length) one per result

Fields read:

  • nuclei: template-id, info.name, info.severity, host, matched-at, matcher-name, extracted-results.
  • httpx: url, status_code, title, tech, webserver, content_length, host, ip, tls.
  • ffuf: results[] with input, status, length, words, lines, url.

Assets go through the existing insert_assets handler and facts through record_fact (source tool_output). The model receives the same compact summary as for nmap: counters plus at most 20 notable items per type.

Additive

  • The agent decides when to call the tool. Bash output is never parsed automatically.
  • No existing behaviour changes. The tool schema only gains three values in the format enum.
  • Worker-only, as in Agent: ingest_scan_output for nmap XML files (worker, additive) #214 and like ingest_bbot. No registration change.
  • No automatic findings. A nuclei result becomes a fact whose summary says it is an unverified scanner result. The planner validates and reports.
  • No new dependency (encoding/json, bufio).

Limits

  • 64 KiB per JSONL line: nuclei and httpx are read with readJSONLines, the line reader taken from the bbot ingester. A longer line is dropped without being buffered whole and counted in oversized_lines. A line that is not valid JSON, or lacks valid typed fields, is counted in skipped. bbot now uses the same reader, with no behaviour change; its tests are unchanged and green.
  • ffuf is not JSONL: it is read token by token with json.Decoder, one results[] element at a time, under the 256 MiB file cap from Agent: ingest_scan_output for nmap XML files (worker, additive) #214. A file cut short keeps the complete results and returns truncated: true.
  • Total cap: one file yields at most 50 000 assets and facts (scanMaxItems), across all four formats, nmap included. Records past the cap are counted in over_cap, not ingested, and the result is marked truncated. The cap is checked once per record, so the last record admitted can take the total slightly past it.
  • Path confinement is inherited unchanged from Agent: ingest_scan_output for nmap XML files (worker, additive) #214: the path is resolved under the run's working directory, and .., absolute paths outside it and symlinks leading outside are refused.
  • Target text is data: titles, template names, matcher names, extracted values, ffuf inputs and TLS data go only into the fact detail, as one Go-quoted (strconv.Quote) JSON string. Summaries and notable items carry only validated typed fields: URL, host, status code, sizes, template-id token, severity enum.
  • Re-ingestion: assets go through the existing upserts, and identical facts are counted in facts_existing, not written again (Agent: ingest_scan_output for nmap XML files (worker, additive) #214).

Tests

  • Unit tests:
    • one hand-written fixture per format, with instruction-shaped target text that must stay in the quoted detail;
    • an invalid line and a line over 64 KiB (dropped without losing its neighbours);
    • a truncated ffuf file, and a non-JSON file refused;
    • the total cap, with a generated httpx file of 25 010 records.
  • Postgres test with a real task through insert_assets and record_fact for nuclei, httpx and ffuf. Re-ingestion keeps the counters and adds no asset row and no fact.
  • The existing nmap and bbot tests are unchanged.
  • gofmt -l on changed files, go build ./..., go vet ./agent, go test -count=1 ./agent, go test -count=1 -race ./agent.

Limitations

  • Fixtures are hand-written from the documented output formats. Nothing was tested against real scanner output.
  • The TOCTOU window from Agent: ingest_scan_output for nmap XML files (worker, additive) #214 is still present: the path is checked with EvalSymlinks + Rel, then opened.
  • Field names follow current nuclei, httpx and ffuf output. Only a few fields are required: template-id plus a valid host for nuclei, and a valid http(s) url for httpx and ffuf. A record without them is skipped and counted. Other missing fields are left empty. For the asset IP, httpx ip is read first, then host when it holds an IP.

Extends ingest_scan_output with three formats:

- nuclei-jsonl: one tool_output fact per result and an asset for the
  scanned target when it is valid; no automatic finding
- httpx-jsonl: one HTTP service asset and one fact per URL
- ffuf-json: one URL asset and one fact per result, read token by token
  with encoding/json; a file cut short keeps the complete results

JSONL lines go through readJSONLines, taken from the bbot ingester
(64 KiB per line; longer lines and invalid JSON are skipped and
counted). bbot now uses the same reader, with no behaviour change.
One file yields at most 50000 assets and facts; records past the cap
are counted in over_cap and the result is marked truncated.
@BaaRai
BaaRai merged commit 37e5b69 into main Nov 13, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant