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.
Python agentic-aiai-securityalert-triageblue-teamcybersecuritydetection-engineeringincident-responselanggraphllm-agentsmcpmitre-attackmodel-context-protocolpurple-teamsecurity-operationsself-hostedsiemsoarsocthreat-detectionthreat-intelligence
fix(deploy): pass the api the two secrets it refuses to boot without (#964)
Beenu Aroraa3efe560fffe
diff --git a/apps/docs/docs/deployment/docker.md b/apps/docs/docs/deployment/docker.mdindex f6b31a057..0f7f2446d 100644--- a/apps/docs/docs/deployment/docker.md+++ b/apps/docs/docs/deployment/docker.md@@ -159,7 +159,8 @@ is 21 rather than 22, the difference being `kafka-ui`.| `POSTGRES_PASSWORD` | no | Postgres owner || `AISOC_APP_DB_PASSWORD` | no | DML-only runtime role || `REDIS_PASSWORD` | no | Redis |-| `JWT_SECRET` | no | Ingest token signing |+| `JWT_SECRET` | no | Ingest token signing, and SAML/OIDC session issuance in the API |+| `METRICS_TOKEN` | no | Bearer required to scrape `/metrics` outside development || `NEO4J_PASSWORD`, `CLICKHOUSE_PASSWORD` | no | `full` profile stores || `GRAFANA_ADMIN_PASSWORD` | no | `monitoring` profile dashboard |diff --git a/docker-compose.prod.yml b/docker-compose.prod.ymlindex 2bde2a6f7..37a88c646 100644--- a/docker-compose.prod.yml+++ b/docker-compose.prod.yml@@ -98,8 +98,29 @@ services:AISOC_ACTIONS_SERVICE_TOKEN: ${AISOC_ACTIONS_SERVICE_TOKEN:?set AISOC_ACTIONS_SERVICE_TOKEN — run `make env` to generate it}AISOC_REALTIME_JWT_SECRET: ${AISOC_REALTIME_JWT_SECRET:?set AISOC_REALTIME_JWT_SECRET — run `make env` to generate it}REALTIME_INTERNAL_TOKEN: ${REALTIME_INTERNAL_TOKEN:?set REALTIME_INTERNAL_TOKEN — run `make env` to generate it}- NEO4J_PASSWORD: ${NEO4J_PASSWORD:?set NEO4J_PASSWORD}- CLICKHOUSE_PASSWORD: ${CLICKHOUSE_PASSWORD:?set CLICKHOUSE_PASSWORD}+ # The remaining two secrets `enforce_secure_defaults` hard-fails on, and+ # the reason this stack could not boot at all: `ENVIRONMENT: production`+ # above turns every entry in `warn_if_insecure_defaults` into a refusal,+ # and these two were the only ones no service block passed through. The+ # API crash-looped on+ #+ # InsecureProductionDefaultsError: Refusing to boot in production with+ # insecure defaults:+ # - METRICS_TOKEN is empty in a non-development environment+ # - JWT_SECRET is empty or set to the well-known placeholder+ #+ # while compose reported the stack up. Declaring them here is what makes+ # the refusal arrive the way the rest of this file's do — before anything+ # starts, naming the variable — rather than as a restart loop behind a+ # console that is already listening.+ #+ # `make env` deliberately does not generate METRICS_TOKEN: a token set+ # anywhere overrides the development exemption on /metrics, so writing+ # one into every `.env` would close the scrape endpoint on development+ # stacks whose Prometheus sends no credential. It is a production secret,+ # set deliberately here.+ METRICS_TOKEN: ${METRICS_TOKEN:?set METRICS_TOKEN — guards /metrics outside development; `openssl rand -hex 32`}+ JWT_SECRET: ${JWT_SECRET:?set JWT_SECRET — signs SAML/OIDC sessions; the same value ingest-worker takes below}ingest-worker:ports: !override ["${AISOC_BIND_ADDR:-127.0.0.1}:8081:8080"]diff --git a/tests/test_production_compose_gate.py b/tests/test_production_compose_gate.pyindex 4af62f605..bc92ef568 100644--- a/tests/test_production_compose_gate.py+++ b/tests/test_production_compose_gate.py@@ -18,6 +18,7 @@ file.from __future__ import annotations+import astimport pathlibimport re@@ -310,6 +311,75 @@ class TestServicesComeBackAfterAReboot:assert str((_merged_services().get("kafka-ui") or {}).get("restart")) == "no"+#: `services/api/app/core/config.py`, whose `warn_if_insecure_defaults` every+#: production boot runs through `enforce_secure_defaults`.+API_CONFIG = REPO / "services" / "api" / "app" / "core" / "config.py"+++def _settings_fatal_when_empty() -> set[str]:+ """Settings whose *emptiness* refuses a production boot.++ Read out of `warn_if_insecure_defaults` rather than listed here, because a+ list here is a second copy of the rule and would drift from the one the+ container actually runs. Every check of the shape ``not s.<NAME>`` means+ "empty is fatal outside development"; the checks comparing against a known+ placeholder are a different rule and are not this gate's business.+ """+ tree = ast.parse(API_CONFIG.read_text(encoding="utf-8"))+ fn = next(node for node in ast.walk(tree) if isinstance(node, ast.FunctionDef) and node.name == "warn_if_insecure_defaults")+ names: set[str] = set()+ for node in ast.walk(fn):+ if (+ isinstance(node, ast.UnaryOp)+ and isinstance(node.op, ast.Not)+ and isinstance(node.operand, ast.Attribute)+ and isinstance(node.operand.value, ast.Name)+ and node.operand.value.id == "s"+ and node.operand.attr.isupper()+ ):+ names.add(node.operand.attr)+ return names+++class TestTheApiCanActuallyBoot:+ """`ENVIRONMENT: production` turns every insecure default into a refusal.++ That is the point of this file, and it is also a trap: a secret the API+ hard-fails on that no service block passes through does not produce a+ compose error, it produces a crash loop. Observed against this stack —+ `docker compose -f docker-compose.prod.yml up -d` reported every container+ started, and the API restarted forever on++ InsecureProductionDefaultsError: Refusing to boot in production with+ insecure defaults:+ - METRICS_TOKEN is empty in a non-development environment+ - JWT_SECRET is empty or set to the well-known placeholder++ because neither was in the api service's `environment`. The sixteen+ assertions already in this file all passed on that tree: they check that+ the secrets the file *does* declare are undefaulted, never that the set is+ complete. This one closes that direction.+ """++ def test_every_secret_the_api_refuses_to_boot_without_is_declared(self, prod: dict) -> None:+ required = _settings_fatal_when_empty()+ assert required, "parsed no settings out of warn_if_insecure_defaults, so this gate checks nothing"++ declared = {key for key, _ in _env_items(prod.get("api") or {})}+ missing = sorted(required - declared)+ assert not missing, (+ f"docker-compose.prod.yml sets ENVIRONMENT=production for api but does not pass {missing}; "+ "the API will crash-loop on InsecureProductionDefaultsError while compose reports it started"+ )++ def test_each_one_is_required_rather_than_defaulted(self, prod: dict) -> None:+ """A default here would boot production on it instead of refusing."""+ required = _settings_fatal_when_empty()+ env = dict(_env_items(prod.get("api") or {}))+ defaulted = sorted(name for name in required if _DEFAULTED.match(env.get(name, "")))+ assert not defaulted, f"these carry a default, so a deployment with no value for them starts anyway: {defaulted}"++class TestNoDatastoreIsBoundToTheHost:def test_production_publishes_no_datastore(self, prod: dict) -> None:assert not _published_datastores(prod)