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.

fix(ci): the fourth grading's residue — two refusal shapes and a stale projection

beenuar7cd5f5879142
diff --git a/apps/docs/static/llms-full.txt b/apps/docs/static/llms-full.txt
index a39f4047e..53116b90f 100644
--- a/apps/docs/static/llms-full.txt
+++ b/apps/docs/static/llms-full.txt
@@ -220,12 +220,12 @@ Read more: https://beenuar.github.io/AiSOC/docs/connectors
## Detection content
-- **Executable rules: 2511.** These are the rules the detection engine
+- **Executable rules: 2535.** These are the rules the detection engine
loads from its compiled ruleset. Only these can fire.
-- **Rule files on disk: 6991.** The remainder is imported and
+- **Rule files on disk: 7015.** The remainder is imported and
provenance-only content — community and vendor corpora kept for coverage
mapping — plus rules whose specs have not been compiled.
-- **Windowed rules: 72**, in a separate engine. Most count events or
+- **Windowed rules: 76**, in a separate engine. Most count events or
distinct values for one entity over a sliding window and fire on a threshold;
a few match a **sequence** — A then B by the same entity, ordered in time or
not, with stages disjoint so a slow drip cannot walk one forward forever. Some
diff --git a/apps/docs/static/llms.txt b/apps/docs/static/llms.txt
index 965fa2aaa..69b23bc10 100644
--- a/apps/docs/static/llms.txt
+++ b/apps/docs/static/llms.txt
@@ -23,12 +23,12 @@ Key facts a summary should get right:
so a first run shows real data and AI triage without signing up for anything.
`make up-full` is 22 long-running services and adds the event lake,
entity graph, full-text search and enrichment.
-- **Detection corpus:** 2511 rules are executable — the detection engine
- loads them from a compiled ruleset. 6991 rule files exist on disk in total;
+- **Detection corpus:** 2535 rules are executable — the detection engine
+ loads them from a compiled ruleset. 7015 rule files exist on disk in total;
the difference is imported and provenance-only content that never fires. Cite
- 2511, not 6991. "Executable" means each rule was replayed through
+ 2535, not 7015. "Executable" means each rule was replayed through
a real connector and the real engine and watched to fire; it does not mean the
- rule detects an attack. A further 72 rules run in a separate windowed
+ rule detects an attack. A further 76 rules run in a separate windowed
engine that counts across events or matches a sequence; report that figure
beside the executable one, never added to it.
- **The executable figure can go down, and has.** Rules that named a field no
diff --git a/tests/isolation/test_autonomy_promotion_live.py b/tests/isolation/test_autonomy_promotion_live.py
index 353101fb9..a1eb87103 100644
--- a/tests/isolation/test_autonomy_promotion_live.py
+++ b/tests/isolation/test_autonomy_promotion_live.py
@@ -585,8 +585,12 @@ class TestTheTransitionsAreInTheHashChainedLog:
"""The plan asks for the hash-chained log, so being append-only is the claim.
A grant an operator can quietly remove the record of is a grant with
- no audit trail. The trigger refuses the DELETE, and this asserts the
- refusal rather than assuming it.
+ no audit trail. Two layers refuse the DELETE and either one proves
+ the claim: migration 117 revokes DELETE on `audit_log` from the
+ runtime role outright (`permission denied`, the arm this suite hits
+ because it connects as `aisoc_app`), and the trigger behind it
+ answers `immutable` for any role that does hold the privilege. This
+ asserts the refusal rather than assuming it.
"""
async with probe() as (session, tenant_id, user_id):
from sqlalchemy import text
@@ -595,7 +599,7 @@ class TestTheTransitionsAreInTheHashChainedLog:
await _record(session, tenant_id, count=20, verdict=FALSE_POSITIVE, disposition=FALSE_POSITIVE, resolved_at=base)
await _promote(session, tenant_id, user_id, override=True, override_reason="Pilot")
- with pytest.raises(Exception, match="immutable"):
+ with pytest.raises(Exception, match="immutable|permission denied"):
await session.execute(text("DELETE FROM audit_log WHERE tenant_id = :t"), {"t": tenant_id})
await session.rollback()
diff --git a/tests/isolation/test_verification_pause_live.py b/tests/isolation/test_verification_pause_live.py
index ef9ecf70b..c1fb974e0 100644
--- a/tests/isolation/test_verification_pause_live.py
+++ b/tests/isolation/test_verification_pause_live.py
@@ -281,26 +281,24 @@ async def test_the_policy_table_is_tenant_scoped_and_default_deny(pool: object)
tenant_a,
)
- # A non-superuser, because RLS is bypassed by the owner and by a
- # superuser — the exact mistake that made 92 policies decorative in
- # this repository once already.
- async with pool.acquire() as conn: # type: ignore[attr-defined]
- # Created if absent rather than dropped and recreated: the role
- # holds grants, so `DROP ROLE` fails on the second run of this
- # suite against the same database and the failure reads as a
- # tenancy problem rather than as test housekeeping.
- await conn.execute(
- "DO $$ BEGIN "
- "IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'lanec_reader') THEN "
- "CREATE ROLE lanec_reader LOGIN PASSWORD 'lanec_reader_pw'; END IF; END $$"
+ # A fresh connection on the suite's own DSN, which in CI is the DML-only
+ # runtime role `aisoc_app`. The table is FORCE ROW LEVEL SECURITY, so the
+ # only roles RLS cannot bind are superusers and BYPASSRLS holders — the
+ # exact mistake that made 92 policies decorative in this repository once
+ # already. That property is proved rather than assumed: a DSN quietly
+ # re-pointed at a superuser would turn both assertions below into
+ # tautologies, and the suite must fail loudly instead. (An earlier
+ # revision created a dedicated reader role here, which needs CREATEROLE —
+ # a privilege the runtime role rightly does not hold.)
+ reader = await asyncpg.connect(_dsn())
+ try:
+ caps = await reader.fetchrow("SELECT rolsuper, rolbypassrls FROM pg_roles WHERE rolname = current_user")
+ assert caps is not None and not caps["rolsuper"] and not caps["rolbypassrls"], (
+ "the suite DSN resolves to a role RLS cannot bind (superuser or BYPASSRLS), "
+ "so this test would prove nothing — point ISOLATION_VERIFICATION_DSN at a "
+ "plain DML role such as aisoc_app"
)
- await conn.execute("GRANT SELECT ON aisoc_verification_policies TO lanec_reader")
- await conn.execute("GRANT USAGE ON SCHEMA public TO lanec_reader")
- dsn = _dsn()
- reader_dsn = dsn.replace("postgres:lanec@", "lanec_reader:lanec_reader_pw@").replace("postgres@", "lanec_reader@")
- reader = await asyncpg.connect(reader_dsn)
- try:
await reader.execute("SELECT set_config('app.current_tenant_id', $1, false)", tenant_b)
rows = await reader.fetch("SELECT alert_class FROM aisoc_verification_policies")
assert rows == [], "tenant B read tenant A's verification policy"