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 PR #1324: depth 4.3 — cold lake query cost and progress

beenuar237dc488b1c0
diff --cc .train_resolve.py
index cbbae0ecb,000000000..fe54faf54
mode 100644,000000..100644
--- a/.train_resolve.py
+++ b/.train_resolve.py
@@@ -1,93 -1,0 +1,95 @@@
+#!/usr/bin/env python3
+"""Train conflict resolver for the recurring tracker shapes (session tool, not shipped).
+
+Usage: python3 .train_resolve.py <file> <mode>
+ modes:
+ union -> ours + theirs for every hunk
+ theirs -> theirs for every hunk
+ roadmap -> theirs, deduping repeated 'claim-to-gate matrix stands at' paragraphs
+Run from the worktree root. Refuses to leave markers behind.
+"""
+import re
+import sys
+import pathlib
+
+CONFLICT = re.compile(
+ r"^<<<<<<< [^\n]*\n(.*?)(?:^\|\|\|\|\|\|\| [^\n]*\n.*?)?^=======\n(.*?)^>>>>>>> [^\n]*\n",
+ re.DOTALL | re.MULTILINE,
+)
+
+
+def merge_checkboxes(ours: str, theirs: str) -> str:
+ """Same line set modulo [x]/[ ]: checked wins per line. Falls back to union."""
+ ol, tl = ours.splitlines(True), theirs.splitlines(True)
+ norm = lambda s: s.replace("- [x]", "- [ ]", 1)
+ if len(ol) == len(tl) and all(norm(a) == norm(b) for a, b in zip(ol, tl)):
+ return "".join(a if "- [x]" in a else b for a, b in zip(ol, tl))
+ return ours + theirs
+
+
+def merge_matrix(ours: str, theirs: str) -> str:
+ """Union of table rows from both sides, then a single trailing non-row block
+ (theirs'), for hunks spanning appended matrix rows + the Summary."""
+ def split(block: str):
+ rows, rest, in_rows = [], [], True
+ for line in block.splitlines(True):
+ if in_rows and line.startswith("|"):
+ rows.append(line)
+ else:
+ in_rows = False
+ rest.append(line)
+ return rows, "".join(rest)
+
+ orows, orest = split(ours)
+ trows, trest = split(theirs)
+ seen, rows = set(), []
+ for r in orows + trows:
+ if r not in seen:
+ seen.add(r)
+ rows.append(r)
+ return "".join(rows) + (trest if trest.strip() else orest)
+
+
+def dedupe_matrix_paragraph(text: str) -> str:
+ paras = [p for p in text.split("\n\n") if p.strip()]
+ firsts = [p for p in paras if p.lstrip().startswith("The claim-to-gate matrix stands at")]
+ if len(firsts) > 1:
+ return firsts[0] + "\n\n"
+ return text
+
+
+def main() -> None:
+ path, mode = sys.argv[1], sys.argv[2]
+ p = pathlib.Path(path)
+ t = p.read_text()
+ out, idx, n = [], 0, 0
+ for m in CONFLICT.finditer(t):
+ ours, theirs = m.group(1), m.group(2)
+ if mode == "union":
+ r = ours + theirs
+ elif mode == "theirs":
+ r = theirs
++ elif mode == "ours":
++ r = ours
+ elif mode == "roadmap":
+ r = dedupe_matrix_paragraph(theirs)
+ elif mode == "checkboxes":
+ r = merge_checkboxes(ours, theirs)
+ elif mode == "matrix":
+ r = merge_matrix(ours, theirs)
+ else:
+ raise SystemExit(f"unknown mode {mode}")
+ out.append(t[idx : m.start()])
+ out.append(r)
+ idx = m.end()
+ n += 1
+ out.append(t[idx:])
+ res = "".join(out)
+ if re.search(r"^(<<<<<<< |>>>>>>> |=======$)", res, re.MULTILINE):
+ raise SystemExit(f"{path}: markers left behind")
+ p.write_text(res)
+ print(f"{path}: {n} hunks -> {mode}")
+
+
+if __name__ == "__main__":
+ main()
diff --cc DEPTH_PROGRESS.md
index 54011a691,185763c5b..6ffde62e5
--- a/DEPTH_PROGRESS.md
+++ b/DEPTH_PROGRESS.md
@@@ -1372,11 -861,9 +1418,12 @@@ endpoint produces once triage falls thr
| 2026-10-07 | 0.3 | `make up` and `make smoke` (10/10) pass. Injection suite and load-harness baselines committed. `make up-full` deferred (D2) and hosted model rows blocked (D3). Fixing D1 was a precondition for the load-harness baseline. |
| 2026-10-09 | 3.3 | Identity privilege (18 rules) and a per-tenant first-seen store (2) built; 5 rules were never unreachable (gate operator drift, D9); 18 retired with a reason (D10). `MAX_UNREACHABLE` 45 → 2, the two remaining both needing the 3.4 baseline. Two matcher operators three shipped rules already used were implemented. |
| 2026-10-09 | 3.2 | Ordered and unordered sequences in the windowed engine; all four translatable Sigma correlation types compile, seven refusal reasons recorded. No upstream correlation rule exists in this tree to import (D8), so the corpus is first-party and labelled as such. |
+ | 2026-10-11 | 4.3 | Third bullet closed. Reproduced: `check_retention_window.py` with the new rules reported no cold-query estimator, no job surface and no job table on the pre-fix tree. Built `lake_cold_query.py` (EXPLAIN ESTIMATE + system.parts + system.processes, no invented throughput or price), `lake_query_runner.py` and migration `111`. Negative control: removing the `status = 'queued'` predicate makes both interleaved transactions claim one job and the live suite goes red. The first version of that test — five gathered claims — passed under the broken implementation and was replaced. 26 pure + 12 live tests; matrix 306 rows, 303 GATED. |
| 2026-10-11 | 4.2 | Reproduced: `check_standard_inputs.py` against the pre-fix tree reported no OTLP package, no Kafka input and no TAXII server — the only TAXII-shaped route being a demo-gated sample list. Built all three, after moving the consumer-health classifier out of `graph_ws` into `streamhealth` so the new Kafka consumer shares the table rather than copying it. Negative controls recorded in the PR: a timestamp-only TAXII cursor loses an indicator in the single-row pagination walk (measured — 3 of 4), and nineteen gate injections each go red. Writing it found four defects, including an OTLP template nobody could mint a token for and a gate rule that read an error message instead of the behaviour. Ingest Go suite green; api projection suite 37; live TAXII suite 15. |
| 2026-10-09 | 4.1 | Reproduced: `check_cloud_native_collection.py` on the unmodified tree reported all three collection paths absent. Implemented `aws_cloudtrail_s3` (SQS-notified S3 objects; management events, data events and VPC flow logs; delete-after-emit), `gcp_pubsub` (REST pull on a log-sink subscription; ack-after-read) and `azure_event_hubs` (Capture blobs over the Data Lake Gen2 JSON API, with a focused Avro OCF reader). Negative controls recorded in the PR: deleting the SQS message before the object is read, acknowledging the Pub/Sub batch before it is built, ignoring the Avro union branch index, and ignoring the flow-log header line each fail a named test, and all were restored. Connectors suite 1014 -> 1098 passed. |
+| 2026-10-11 | 5.4 | Reproduced: `check_stateful_verification.py` against `origin/main` reported eight problems — no `verification.py` at all, `verify_user` absent from the control-flow table, no resume path, no escalation, no `timed_out`, no sweep, no migration and no writer for the opt-in table. Built the stage machine on the existing pause row rather than a second table. Three negative controls recorded in the PR: reverting the run-loop break fails three tests including the `wait` regression (D11), removing `manager_ref=_extract_manager(body)` fails three SCIM tests, and removing `ENABLE ROW LEVEL SECURITY` from migration 102 fails the live tenancy test with "tenant B read tenant A's verification policy". Two pre-existing tests pinned the old shape and were widened rather than relaxed: the control-flow table's membership (still an equality, now of four) and the sweeper's return dict. Writing the gate found a hole in the gate: its first block extractor matched `\n\n\n`, which finds nothing for the *last* function in a module, so the ordering rule was skipped entirely over an injected violation. |
+| 2026-10-11 | 6.2 | Reproduced: 13 of 16 new cases failed, driving the shapes the four endpoint connectors actually emit. Root cause was 6.1's endpoint branch reading `process.name` off OCSF, which the canonical profile never populates — it found `None` on every real source while its own tests passed. Fixed by reconstructing the connector namespace. Shipped the osquery pack (5 queries, packs 5 -> 6), the source-capability table, the operator doc and a 6-rule gate. Fusion suite 683 -> 700. Claim row is PARTIAL: no osquery agent runs in CI, and the EDR connectors return vendor detections rather than process telemetry, so the plan's "CrowdStrike, Defender, SentinelOne" wording is not satisfiable with these connectors. |
+| 2026-10-11 | 6.1 | Reproduced: the new gate reported nine problems across five of eight rules on the unmodified tree. Built `aisoc_ai_assets` (migration 110), its routes behind a new `ai_estate:*` permission pair, the fusion recorder that writes it on the default profile, the `AIAsset` graph label with `OPERATES`/`HOSTS` edges, and the `/ai-estate` page. Two negative controls against a real PostgreSQL: reverting `NULLS NOT DISTINCT` turns one provider-key row into three, and a `USING (true)` policy leaks across tenants. Claim matrix 302 -> 303 rows, 300 GATED. Writing the gate found two blind spots in the gate itself. |
| 2026-10-09 | 3.1 | All 74 decided. 50 translated into `wd-*` rules derived from each original's own clauses and replayed through the real engine (162 assertions); 24 refused with a reason across five kinds. `MAX_UNREACHABLE` 119 → 45, published executable 2,603 → 2,529, windowed 18 → 68. Three findings recorded as D4–D6 below. |
| 2026-10-11 | 8.1 | parity 4.1's containerised-IdP leg **observed to pass**, both halves: `keycloak-oidc` verifies a real `id_token` against Keycloak's published JWKS with an audience-mismatch negative control, and `keycloak-saml` walks the whole SP-initiated flow to the real ACS and signs `[email protected]` in as `infosec`, with an untrusted-key control answering 400. Run `38124780886`, as `ENVIRONMENT=test` against the DML-only `aisoc_app` role. The SSO claim row moves PARTIAL → GATED on that evidence. Building it found two shipped defects no self-authored provider could expose: `resolve_saml_connection` bound `:i` untyped so `:i IS NULL` raised on asyncpg, and Keycloak's default role-list mapper emits one `<Attribute Name="Role">` per role, which python3-saml refuses. |
| 2026-10-11 | 8.1 | WebAuthn as a console second factor and MFA enforced per role. Fixing the branch's own gates found three `passkey_credentials` reads scoped by user id alone on a tenant-scoped table, and a permission-model violation where the MFA policy route imported `ROLE_PERMISSIONS` directly; the role *vocabulary* now has one owner in `role_grants.known_roles()`. 23 of 23 live cases pass against real Postgres, and deleting the login integration fails 14 of them — measured, where the workflow had said eight. |
diff --cc apps/docs/docs/compliance/evidence-pack.md
index 349c2cec1,8fb1094b5..43bc9abf8
--- a/apps/docs/docs/compliance/evidence-pack.md
+++ b/apps/docs/docs/compliance/evidence-pack.md
@@@ -33,10 -33,8 +33,10 @@@ and says so
| Prompt-injection resistance | Three adversarial corpora: 32 payloads scanned in isolation and 71 incident pairs whose payloads are placed in attacker-controllable fields, both against a clean twin with a recall floor and a false-positive ceiling, plus 34 held-out pairs authored after the guard was frozen and carrying no floor at all, on which the guard measures 7.1% | `services/agents/tests/adversarial/` |
| Claim-to-gate traceability | Every product claim mapped to the CI job that fails when it stops being true | `docs/audit/CLAIM_TO_GATE_MATRIX.md` |
- The last row is the one worth reading first. It is the honest index: 303 rows
+ The last row is the one worth reading first. It is the honest index: 304 rows
`GATED`, 2 `PARTIAL`, and a ratchet that refuses to let a row sit at
+
+`GATED`, 3 `PARTIAL`, and a ratchet that refuses to let a row sit at
`NO GATE`. Re-read the figure from the table rather than from here — a count
copied into prose goes stale in silence, which is why
`scripts/readme_gates.py` cross-checks this sentence against the matrix.