Skip to content

armgit / AiSOC

Public Imported from GitHub
0

Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.

Merge remote-tracking branch 'origin/main' into depth/9.5-hunt-reports

Beenu Arorabbccc1284c6e
diff --cc DEPTH_PROGRESS.md
index eb83bac9a,5567c305c..b0a426d0e
--- a/DEPTH_PROGRESS.md
+++ b/DEPTH_PROGRESS.md
@@@ -486,32 -673,36 +673,59 @@@ endpoint produces once triage falls thr
against real Postgres 16, real Qdrant v1.7.0 and a real embedding backend,
recorded in the PR. **The measurement is published as it came out, and it is
unflattering:** see D11.
- - [ ] **9.3** Case depth (parity 5.6 remainder)
+ - [x] **9.3** Case depth (parity 5.6 remainder). All four open bullets.
+ **Alert merge needed no schema at all**: `is_merged`, `parent_alert_id` and
+ `child_alert_ids` have been on `alerts` since migration 001 with the ORM
+ model as their only mention anywhere — the repository's recurring defect,
+ and worth naming so "new" means something. Merge keeps every row: a
+ duplicate is marked and pointed at its parent, the survivor's children are
+ **appended** not replaced, re-merging and merging into a merged alert are
+ both refused because each would orphan or cycle the chain, and the
+ survivor inherits the case a duplicate was already on. Case merge (migration
+ `106`) repoints the alerts and keeps both case rows, because deleting loses
+ the audit chain, the custody entries and any vendor ticket already naming
+ that id. Bulk triage is new in the route **and** the console: a checkbox per
+ row, a select-all that selects this page only, and a bar whose Apply
+ performs a real write and surfaces the preflight 409 with the real matched
+ count instead of silently retrying. `closed` is deliberately unreachable
+ there — `bulk-close` snapshots every row first and a weaker second path to
+ one destination is how the weaker one wins. Tenant custom fields are two
+ tables rather than a JSONB blob so a field can be enumerated, rendered,
+ validated at write time and retired cleanly; values are canonicalised on
+ write. Workload is counted per request over rows the query selected, a
+ merged-away case is not counted as work, and **a mean over nothing is
+ `null`, never `0.0`** — with the count it was taken over beside it. Graded
+ by `.github/workflows/case-depth-live.yml` against a real Postgres with
+ three negative controls, because every statement here is Postgres-only and
+ a SQLite stand-in would be a different query. 29 new tests (23 API live, 6
+ web). The live suite earned its keep immediately: it caught that
+ `aisoc_cases.alert_ids` is `uuid[]` while the two columns beside it are
+ JSONB, which a stand-in would have accepted.
- [ ] **9.4** War rooms
-- [ ] **9.5** Hunt to report
+- [x] **9.5** Hunt to report. A natural-language hunt or a retro-hunt
+ sighting becomes a stored report answering what, how, where and when, with
+ ledger citations, readable as JSON or HTML and exportable as PDF through
+ the **same WeasyPrint path and the same unavailability error** the weekly
+ digest uses — one renderer, because two drift and the PDF stops matching
+ the page somebody approved. Three refusals carry the item: a hunt that has
+ never run is refused (a report about an unexecuted query is a statement
+ about the query, not the estate), an **uncited report is refused at
+ persist time** (an uncited report is an assertion), and a section that
+ cannot be derived stays **empty** and renders as "not recorded" rather
+ than as a confident sentence about nothing. The retro-hunt builder
+ computes the gap between when intelligence arrived and when the estate
+ first saw the indicator, which is the number a retro-hunt exists to
+ produce and which a reader would otherwise get by subtracting two
+ timestamps. Graded by `.github/workflows/hunt-report-live.yml` against a
+ real Postgres with three negative controls. 14 new tests. The live suite
+ earned its keep three times on its first run: `alerts` has no singular
+ `affected_host` (it is `affected_hosts`, a JSONB array, and `entities` is
+ what fusion actually writes), `investigation_events` has **no `case_id` at
+ all** so the ledger is only reachable by joining `investigation_runs`, and
+ that table's `case_id` is TEXT rather than UUID so binding a UUID raises
+ in asyncpg instead of coercing. Each would have shipped under a SQLite
+ stand-in, and the middle one would have cited an empty set on every
+ report.
- [ ] **9.6** Native responder
## Phase 10: Close the books
@@@ -523,7 -714,7 +737,9 @@@
| Date | Item | What happened |
|---|---|---|
+ | 2026-10-11 | 9.3 | Reproduced: the alert merge columns had zero writers outside the ORM model; `grep -rn custom_field services/api` and `grep -rn workload` (excluding workload *identities*) both counted zero; and `grep -rn bulk apps/web/src/components/alerts` found only unrelated comments, so the only bulk verb in the product was `POST /alerts/bulk-close` with no console surface at all. The two-case-table trap named in the brief was already closed by migration 083 and `check_one_case_table.py` reports OK, so `aisoc_cases` is the table this item deepens. Three negative controls recorded in the PR and wired into the live workflow. The live suite found a real defect on its first run: `aisoc_cases.alert_ids` is `uuid[]` while `ioc_ids` and `artifact_ids` beside it are JSONB, and the merge statement had assumed JSONB. |
++
+| 2026-10-11 | 9.5 | Reproduced: `grep -n hunt` across `app/services/report_builder.py` and `app/api/v1/endpoints/reports.py` returned nothing — the report surface and the hunt surface did not know about each other, so a hunt produced rows and a retro-hunt produced a sightings row and neither produced anything a person could read or forward. Built the four-section report, the citation rule, the two builders and the JSON/HTML/PDF export. Three negative controls in the live workflow: allowing an uncited report, filling an empty section with a sentence, and reporting a hunt that never ran each have to turn the suite red. The live run found three schema facts a stand-in would have hidden, recorded in the item above. |
| 2026-10-11 | 9.2 | Reproduced: `knowledge_base.py` searched with `to_tsvector`/`plainto_tsquery` and nothing else; `grep -rn qdrant services/api/app/` found only the migration runner and the tenant-deletion sweep, no recall path; and no memory row anywhere carried an author, a source, a scope, an expiry or a state. Built the store of record, the Qdrant index over it, the conflict state machine, the case-closure writer and the recall scorer. Two negative controls recorded in the PR: restoring last-write-wins on a contradiction fails three tests, and restoring vector truncation fails one. The measurement is negative and is published as such — see D11, which also records that it caught the truncation defect. |
| 2026-10-07 | 0.1 | This file created at base commit `1b8bc2d4`. |
| 2026-10-07 | 0.2 | Every figure re-derived. Two matched exactly (detections, unreachable families); executor arms measured 74 against a captured 73; the cloud/identity/SaaS/code figure measured 395 against a captured 461 on a grouping the plan does not pin, recorded above. Two measurement caveats found: executable and quarantined overlap by 1,724 rules, and the "69% Windows" figure does not reproduce from the index. |