Repository navigation
Add ingest_bbot tool (bbot JSONL, typed scope split) - #200
Merged
Merged
Conversation
ingest_bbot reads a bbot output file by path and ingests it through the typed parser from #199 (parseBbotJSONL), one line at a time: - Lines are read with a fixed cap (bbotMaxLineBytes = 64 KiB, newline included). A longer line is skipped and counted, never buffered whole. - scope_distance == 0 events that are assets (assetItems) go through the existing insert_assets handler; no asset SQL is written here. - Every other event is recorded as a fact with source third_party_intel. The summary is built from typed fields only; the free text is stored in detail as the inert Go-quoted string. - Intel never reaches insert_assets or task_scope. The tool is in WorkerTools, so the existing BuiltinToolSeeds/SeedTool loop inserts its row (a new key, inserted on fresh and existing DBs). It is listed in the target gate's noTargetTools: its input is a local path, not a network target (TestDomainToolsDeclareNoTarget).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
ingest_bbot: reads a bbot JSONL output file from a path and ingests it under the existing target-scope rules, reusing the typed parser from #199 unchanged.Behaviour
bbotMaxLineBytes = 64 KiB(newline included). A longer line is skipped and counted (oversized_lines), never buffered whole. Each kept line goes throughparseBbotJSONL.scope_distance == 0):assetItems()→ the existinginsert_assetshandler (t.insertAssets().Call). No asset SQL here. In-scope events that are not assets (e.g. FINDING) are only counted (in_scope_not_asset).scope_distance, or missing): one fact each viarecordOneFact(the record_fact path),source = third_party_intel. The summary is built from typed fields only; the free text is stored indetailas the inert Go-quoted string from the parser.insert_assetsortask_scope. Free text and non-JSON lines never create an asset.Wiring
WorkerTools()gainst.ingestBbot(). The existingBuiltinToolSeeds→SeedToolloop inserts its row on startup: a new key, so the insert happens on fresh and existing DBs alike. No extra seed migration.intercept/target_extract.go:ingest_bbotis added tonoTargetTools(its input is a local path).TestDomainToolsDeclareNoTargetrequires every domain tool to be listed.Tests
TestReadBbotJSONLLineCap(pure): the valid fixture is parsed line by line; a line over the cap is skipped and counted and the lines around it are kept; a line exactly at the cap is kept; a single over-cap line with no newline is dropped.TestIngestBbotScopeSplit(PG,ARTEX_PG_DSN): a benign fixture using example.com / example.net / example.org. Expected: one subdomain asset (the in-scope host); 3third_party_intelfacts with quoted detail; no asset and no task_scope row for out-of-scope hosts or the host named in free text; 1 non-JSON line skipped.in-scope host: 0 subdomain assets, want 1.2 assets created from out-of-scope lines or free text.Verification (Kali, go1.26.10 linux/amd64, throwaway postgres:16-alpine)
gofmt -lon changed files: no outputgo build ./...,go vet ./...: exit 0go test -count=1 ./agent/: okgo test -count=1 -run Extract ./intercept/,go test -count=1 -run Tool ./server/: ok