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 fifth grading's residue — four cross-PR interactions the union exposed

beenuare957aef4cac2
diff --git a/scripts/check_raw_sql_columns.py b/scripts/check_raw_sql_columns.py
index 0ef0059a7..98ff4bca6 100644
--- a/scripts/check_raw_sql_columns.py
+++ b/scripts/check_raw_sql_columns.py
@@ -240,6 +240,14 @@ PARSER_ARTEFACTS: dict[tuple[str, str], str] = {
"services/actions/app/live_actions/builtins.py",
"the",
): "Prose in the module docstring, not a statement. The word follows `SELECT` in an English sentence.",
+ (
+ "services/api/app/services/lake_query_runner.py",
+ "elapsed",
+ ): (
+ "Prose in the module docstring, not a statement: \"Nothing here derives a percentage "
+ "from elapsed time\" puts the word after `from` in an English sentence. The module's "
+ "real statements are SQLAlchemy Core, not raw strings."
+ ),
(
"services/api/app/services/alert_bulk_close.py",
"a",
@@ -281,6 +289,15 @@ DYNAMIC_SQL: dict[tuple[str, str], str] = {
"('aisoc._migrations'), interpolated, and this module creates it. Same reason as "
"`aisoc_schema_migrations` above, one store over."
),
+ (
+ "services/connectors/app/leader_lease.py",
+ "scheduler_leases",
+ ): (
+ "The module docstring's illustrative fragment — `UPDATE scheduler_leases SET ... WHERE "
+ "scope = :scope AND expires_at < now()` — whose literal ellipsis is unparsable on "
+ "purpose. The five statements the module actually sends all parse and are compared "
+ "against migration 115 (`--credits` names each one)."
+ ),
(
"services/api/app/services/alert_bulk_close.py",
"alerts",
diff --git a/scripts/check_session_projection.py b/scripts/check_session_projection.py
index a466d5001..0eb88eb4e 100644
--- a/scripts/check_session_projection.py
+++ b/scripts/check_session_projection.py
@@ -86,9 +86,37 @@ SESSION_FIELD_PATTERNS: tuple[tuple[str, str], ...] = (
#: Files that read these fields for a reason other than deriving a session.
#: Each entry needs a reason; an empty allowlist is the goal and the list is
#: never a convenient place to put a new violation.
+#:
+#: The distinction that keeps the list honest: the hazard this gate exists for
+#: is a **consumer of the session projection** — `sessions.py` (Postgres),
+#: `lake_writer.py` (ClickHouse) or the Neo4j writer in Go — re-deriving the
+#: key, after which the three stores disagree about which session an event
+#: belongs to. A *connector* that lifts the vendor's session field into its
+#: own normalized output is not that: it runs upstream of the one producer,
+#: it writes nothing into `activity.session`, and the field it produces feeds
+#: the detection engine's namespace, which `windowed_detection._fields()`
+#: builds from the connector's `raw_data`/`raw_event` and **never** from
+#: `activity.session`. So the AiTM rules cannot read the projection even in
+#: principle, and the lift is the only way the session id reaches them. None
+#: of the three store-consumers is on this list, and each would still trip.
ALLOWED: dict[str, str] = {
"scripts/check_session_projection.py": "this gate, which has to name the patterns it looks for",
"services/ingest/internal/activity/session_test.go": "the producer's own tests, which assert on these fields by name",
+ "services/connectors/app/connectors/okta.py": (
+ "the Okta connector lifts authenticationContext.externalSessionId to a top-level "
+ "`session_id` in normalize() so the windowed AiTM rules (depth 7.3) can group on it — "
+ "the detection namespace is built from the connector's output, not from activity.session, "
+ "so this is detection-field normalization upstream of the producer, not a second consumer "
+ "re-deriving the projection key. session.go stays the sole producer of activity.session."
+ ),
+ "services/connectors/tests/connectors/test_aitm_session_fields_reach_detection.py": (
+ "asserts the connector's session_id lift reaches the detection engine; names the vendor "
+ "field by name to build the fixture, same reason as the producer's own tests"
+ ),
+ "services/fusion/tests/test_okta_identity_rules_are_reachable.py": (
+ "builds Okta fixtures that carry externalSessionId to prove the identity rules fire; "
+ "names the vendor field to construct the event, not to derive a projection key"
+ ),
}
#: A consumer that falls back to building a key when the block is absent.
diff --git a/scripts/generate_connector_docs.py b/scripts/generate_connector_docs.py
index 315175c60..61498e751 100644
--- a/scripts/generate_connector_docs.py
+++ b/scripts/generate_connector_docs.py
@@ -417,6 +417,12 @@ SIDEBAR_PREAMBLE = (
# pick up and the page has to be named here or it drops out of
# navigation on the next regeneration.
"connectors/syslog-listener",
+ # The same reason, for the two receivers depth 4.2 added: the OTLP log
+ # endpoint and the Kafka input are transports in services/ingest with no
+ # schema() either, so they have to be named here or the generator drops
+ # their hand-written pages from navigation.
+ "connectors/otlp-logs",
+ "connectors/kafka-input",
# Not a connector, so the generated list below does not cover it.
"connectors/osquery-extensions",
)
diff --git a/services/agents/app/playbook/packs/v1/suspicious-signin/user-verification-containment.playbook.json b/services/agents/app/playbook/packs/v1/suspicious-signin/user-verification-containment.playbook.json
new file mode 100644
index 000000000..2f9317017
--- /dev/null
+++ b/services/agents/app/playbook/packs/v1/suspicious-signin/user-verification-containment.playbook.json
@@ -0,0 +1,111 @@
+{
+ "id": "user-verification-containment-v1",
+ "name": "Suspicious Sign-In: Ask the User, Then Their Manager",
+ "description": "Asks the person whose account signed in whether they recognise it, escalates to their manager from the directory when nobody answers, and branches on the signed answer. 'No, that wasn't me' and 'nobody answered' both reach containment behind an analyst approval; 'yes, that was me' closes the case. Never asked on a confirmed true positive, and auto-sent only for alert classes the tenant opted into.",
+ "version": "1.0.0",
+ "author": "AiSOC",
+ "tags": [
+ "suspicious-signin",
+ "identity",
+ "verification",
+ "mitre.t1078",
+ "mitre.t1556"
+ ],
+ "trigger": {
+ "on": "alert",
+ "severity": ["medium", "high"],
+ "tags": ["suspicious-signin", "impossible-travel", "new-device"]
+ },
+ "enabled": true,
+ "dry_run_support": true,
+ "created_at": "2026-10-11T00:00:00+00:00",
+ "updated_at": "2026-10-11T00:00:00+00:00",
+ "inputs": {
+ "user": {
+ "description": "The account the suspicious sign-in was for",
+ "field": "alert.user",
+ "required": true
+ },
+ "source_ip": {
+ "description": "Where the sign-in came from, quoted back to the person being asked",
+ "field": "alert.source_ip",
+ "required": false
+ }
+ },
+ "steps": [
+ {
+ "id": "ask",
+ "name": "Ask the account holder",
+ "type": "verify_user",
+ "params": {
+ "user": "{{alert.user}}",
+ "channel": "slack",
+ "message_template": "AiSOC saw a sign-in to your account from {{alert.source_ip}}. Was this you?",
+ "expires_in_hours": 24
+ },
+ "on_failure": "abort",
+ "retry_max": 0,
+ "timeout_seconds": 30
+ },
+ {
+ "id": "approve_contain",
+ "name": "Approve containment",
+ "type": "approval",
+ "params": {
+ "prompt": "{{alert.user}} did not confirm this sign-in. Disable the account and revoke its sessions?",
+ "expires_in_hours": 4
+ },
+ "condition": "verification_outcome != 'acknowledged'",
+ "on_failure": "abort",
+ "retry_max": 0,
+ "timeout_seconds": 30
+ },
+ {
+ "id": "disable",
+ "name": "Disable the account",
+ "type": "disable_user",
+ "params": {
+ "user": "{{alert.user}}"
+ },
+ "condition": "verification_outcome != 'acknowledged'",
+ "on_failure": "abort",
+ "retry_max": 0,
+ "timeout_seconds": 30
+ },
+ {
+ "id": "revoke",
+ "name": "Revoke the account's sessions",
+ "type": "revoke_session",
+ "params": {
+ "user": "{{alert.user}}"
+ },
+ "condition": "verification_outcome != 'acknowledged'",
+ "on_failure": "abort",
+ "retry_max": 0,
+ "timeout_seconds": 30
+ },
+ {
+ "id": "notify_soc",
+ "name": "Tell the SOC what the answer was",
+ "type": "notify",
+ "params": {
+ "channel": "slack",
+ "message_template": "Verification for {{alert.user}} came back '{{verification_outcome}}' (asked: {{verification.stage}}). Containment {{verification_outcome}} != acknowledged.",
+ "webhook_env": "SLACK_SOC_WEBHOOK"
+ },
+ "on_failure": "continue",
+ "retry_max": 0,
+ "timeout_seconds": 10
+ },
+ {
+ "id": "close",
+ "name": "Close the case when the user confirmed it was them",
+ "type": "close_case",
+ "params": {},
+ "condition": "verification_outcome == 'acknowledged'",
+ "on_failure": "continue",
+ "retry_max": 0,
+ "timeout_seconds": 20
+ }
+ ]
+}