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(deploy)!: make every documented path production-class by default (#1074)

Beenu Arora48234dc57694
diff --git a/.env.example b/.env.example
index 92bdee4fc..5c1a782ca 100644
--- a/.env.example
+++ b/.env.example
@@ -47,7 +47,11 @@ AISOC_VERSION=latest
# `development` enables the dev auth bypass in services/api/app/api/v1/dev_auth.py.
# Set `production` for anything network-reachable; docker-compose.yml reads this
# value, so changing it here is enough.
-ENVIRONMENT=development
+# Production is the default because the value of this variable used to
+# decide whether an uncredentialed request was served as an administrator.
+# For the developer conveniences, layer the overlay rather than editing
+# this line: docker compose -f docker-compose.yml -f infra/compose/docker-compose.dev.yml up -d
+ENVIRONMENT=production
LOG_LEVEL=info
# HS256 signing key for console sessions, shared by the API and the connectors
@@ -101,6 +105,14 @@ AISOC_DEMO_MODE=false
# read, so that constant was the effective key in every deployment. Unset, the
# ticket endpoint fails closed (503) and realtime rejects every connection.
AISOC_REALTIME_JWT_SECRET=
+
+# HS256 key for the session tokens the SAML and OIDC callbacks issue, and the
+# bearer that guards /metrics. Both are generated by `make env`. The API
+# refuses to boot without them now that ENVIRONMENT defaults to production:
+# in a development-class environment `enforce_secure_defaults` only warns,
+# which is why neither was generated before.
+JWT_SECRET=
+METRICS_TOKEN=
# Time-to-live (seconds) for minted realtime tickets. Kept short so a leaked
# ticket is only briefly useful; the frontend re-mints on every (re)connect.
# Clamped to a 60s ceiling by the ticket endpoint regardless of this value.
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 9ce70e3d8..b6602b2e1 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -377,6 +377,22 @@ jobs:
run: python3 scripts/check_console_auth_headers.py --self-test
- name: Verify every console API call carries a credential
run: python3 scripts/check_console_auth_headers.py
+ # The console half proves a credential is sent and the route gates prove
+ # the server requires one. Neither asks the question that actually bit:
+ # what posture does a documented `make up` produce? ENVIRONMENT
+ # defaulted to `development` in the compose file and in `.env.example`,
+ # and in a development-class environment the API served an
+ # uncredentialed request as an administrator. So the default value of a
+ # string decided whether a host was anonymous, and no test read it.
+ #
+ # Static, with no Docker, so it runs in the jobs that matter. It also
+ # checks the opposite direction: the developer overlay must still turn
+ # the conveniences on, because four of its five rules are satisfied by
+ # deleting the developer path rather than making it explicit.
+ - name: Deployment posture gate — self-test
+ run: python3 scripts/check_deployment_auth_posture.py --self-test
+ - name: Verify every documented path is production-class
+ run: python3 scripts/check_deployment_auth_posture.py
# Sending a customer file to a third party is a disclosure, and for the
# first commercial provider wired here it is a disclosure to the public
# internet: a stored report carries `visibility: "public"` and
diff --git a/.github/workflows/compose-smoke.yml b/.github/workflows/compose-smoke.yml
index 1e6574414..37223314e 100644
--- a/.github/workflows/compose-smoke.yml
+++ b/.github/workflows/compose-smoke.yml
@@ -209,6 +209,16 @@ jobs:
fi
echo "Resolved AISOC_VERSION=${AISOC_VERSION}"
+ # `make up` runs this, and the stack now needs it to boot: with
+ # ENVIRONMENT defaulting to production, ingest refuses to start
+ # without a JWT_SECRET and the API refuses without METRICS_TOKEN.
+ # That is the services being right — ingest previously started on a
+ # literal published in this repository — but a workflow that copies
+ # `.env.example` and stops has provisioned an environment no real
+ # deployment ever has.
+ python3 scripts/ensure_env.py
+ python3 scripts/ensure_env.py --check
+
- name: Validate compose file
if: steps.relevant.outputs.run == 'true' || github.event_name == 'push'
run: docker compose config --quiet
@@ -238,12 +248,21 @@ jobs:
} > /tmp/prod-real.env
test "$(wc -l < /tmp/prod-real.env)" -gt 10 \
|| { echo "::error::no guarded variables were derived"; exit 1; }
- sed 's|^POSTGRES_PASSWORD=.*|POSTGRES_PASSWORD=aisoc_dev_secret|' /tmp/prod-real.env > /tmp/prod-published.env
+ # Derived from the compose file, not typed here. This step now sits
+ # in a workflow that also runs ensure_env.py, and a workflow that
+ # generates secrets must not also carry the literals the generator
+ # replaces: a hardcoded one could be the value that wins. Reading it
+ # from the compose default also means this negative control follows
+ # the literal if it is ever changed.
+ published="$(grep -oE 'POSTGRES_PASSWORD:-[^}]+' docker-compose.yml | head -1 | cut -d- -f2-)"
+ test -n "$published" \
+ || { echo "::error::no POSTGRES_PASSWORD default found to test against"; exit 1; }
+ sed "s|^POSTGRES_PASSWORD=.*|POSTGRES_PASSWORD=$published|" /tmp/prod-real.env > /tmp/prod-published.env
echo "::group::published credential — must refuse"
if docker compose --env-file /tmp/prod-published.env -f docker-compose.yml -f docker-compose.prod.yml \
up --no-build --exit-code-from preflight-secrets preflight-secrets; then
- echo "::error::the production stack started on aisoc_dev_secret"
+ echo "::error::the production stack started on the published development default"
exit 1
fi
docker compose --env-file /tmp/prod-published.env -f docker-compose.yml -f docker-compose.prod.yml down -v
diff --git a/.github/workflows/golden-pipeline.yml b/.github/workflows/golden-pipeline.yml
index ed40f18f7..552bf5066 100644
--- a/.github/workflows/golden-pipeline.yml
+++ b/.github/workflows/golden-pipeline.yml
@@ -57,6 +57,20 @@ jobs:
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc || true
echo "after: $(df -h / | awk 'NR==2{print $4}') free"
+ - name: Generate the secrets the stack needs
+ run: |
+ set -euo pipefail
+ cp .env.example .env
+ # `make up` runs this, and the stack now needs it to boot: with
+ # ENVIRONMENT defaulting to production, ingest refuses to start
+ # without a JWT_SECRET and the API refuses without METRICS_TOKEN.
+ # That is the services being right — ingest previously started on a
+ # literal published in this repository — but a workflow that copies
+ # `.env.example` and stops has provisioned an environment no real
+ # deployment ever has.
+ python3 scripts/ensure_env.py
+ python3 scripts/ensure_env.py --check
+
- name: Build the CORE images from this commit
run: |
set -euo pipefail
diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml
index 8a3cce8fe..a03041db7 100644
--- a/.github/workflows/integration.yml
+++ b/.github/workflows/integration.yml
@@ -319,6 +319,39 @@ jobs:
fi
echo "confirmed: /v1/ingest refused an unauthenticated push with $code"
+ # The spine test reads the API and mints a realtime ticket. Both used
+ # to succeed with no credential, because an uncredentialed request
+ # resolved to a demo administrator and the compose file defaulted to a
+ # development-class environment. It no longer does, so they need one.
+ #
+ # Obtained by signing in rather than by `mint_api_token`, because this
+ # job deliberately pulls the API image from GHCR `:main` (it builds only
+ # fusion and ingest-worker from PR source) and a command added in this
+ # pull request is not in that image. Logging in works against any API
+ # image, which is the property that matters for a job whose images are
+ # deliberately mixed.
+ - name: Sign in for the credential the spine test needs
+ run: |
+ set -euo pipefail
+ password="ci-$(openssl rand -hex 16)"
+ echo "::add-mask::$password"
+ AISOC_ADMIN_PASSWORD="$password" docker compose run --rm -T \
+ -e AISOC_ADMIN_PASSWORD="$password" api \
+ python -m app.scripts.bootstrap_admin --reset-password >/dev/null 2>&1 || \
+ AISOC_ADMIN_PASSWORD="$password" docker compose run --rm -T \
+ -e AISOC_ADMIN_PASSWORD="$password" api \
+ python -m app.scripts.bootstrap_admin >/dev/null 2>&1
+ token="$(curl -sf -X POST http://localhost:8000/api/v1/auth/login \
+ -H 'Content-Type: application/json' \
+ -d "{\"email\":\"[email protected]\",\"password\":\"$password\"}" \
+ | python3 -c 'import json,sys; print(json.load(sys.stdin)["access_token"])')"
+ if [ -z "$token" ]; then
+ echo "::error::could not sign in for an API token"
+ exit 1
+ fi
+ echo "::add-mask::$token"
+ echo "AISOC_API_TOKEN=$token" >> "$GITHUB_ENV"
+
- name: Run spine test
run: python3 scripts/integration/spine_test.py
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c02a3597d..56ac37637 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -28,6 +28,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### BREAKING
+- **`make up` now starts a production-class stack, and `AISOC_DEV_MODE` no longer defaults to on.** The value of `ENVIRONMENT` used to decide whether an uncredentialed request was served as an administrator, and it defaulted to `development` in `docker-compose.yml`, in `.env.example`, and therefore in the `.env` that `make env` writes. Nobody chose that; it was a fallback.
+
+ | Path | Before | Now |
+ |---|---|---|
+ | `make up`, `install.sh`, `install.ps1`, `docker compose up -d` | `ENVIRONMENT=development`, anonymous access on | `ENVIRONMENT=production`, anonymous access off |
+ | `AISOC_DEV_MODE` on ten services | `1` | `0` |
+ | Signing in | automatic, as a demo administrator | the account `make bootstrap` printed |
+ | The developer experience | the default | `make up-dev` |
+
+ `make up-dev` layers `infra/compose/docker-compose.dev.yml`, which sets `ENVIRONMENT=development`, `AISOC_DEV_MODE=1` and `AISOC_DEV_AUTH_BYPASS=1`. That file used to be a fifteen-line `include` alias that set nothing; `include` imports a model whose services may not be overridden, so it could never have carried an override. It is an ordinary two-`-f` overlay now, and the six documented commands that passed it with a single `-f` were corrected.
+
+ **Two more secrets are generated**, taking `make env` from twelve to fourteen: `METRICS_TOKEN` and `JWT_SECRET`. `enforce_secure_defaults` refuses to boot without either once `ENVIRONMENT` is production, and it only warns in a development-class environment — so flipping the default without generating them would have turned "anonymous administrator" into "the API will not start", which is a worse first run and not a fix. This was found by booting the stack, not by a test.
+
+
- **An unauthenticated request is no longer an administrator, and `AISOC_DEV_MODE` no longer admits an uncredentialed caller.** If you rely on either, here is what changes and how to get it back.
| What used to work | What happens now | How to restore it |
@@ -62,6 +76,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
The gate that keeps it closed is wired into `ci.yml` beside the sample-data gate, and runs `--self-test` first. Three blind spots in its own first draft are pinned as cases, each of which had made it silently miss real findings: a generic type argument (`useSWR<Role[]>(...)`) hid both settings SWR sites, a multi-line arrow fetcher was truncated at the first newline so nine calls on the honeytokens and purple-team pages read as "imported, judged elsewhere", and an inline fetcher whose URL is the SWR key has no API path at the call site to match on at all.
+- **Every documented way to start AiSOC produced the anonymous posture, and `docker-compose.prod.yml` was selected by nothing.** The file exists and is correct: `ENVIRONMENT: production` and `AISOC_DEV_MODE: 0` as literals on all six Python services. But `Makefile` `up:` and `up-full:` never passed `-f docker-compose.prod.yml`, and `install.sh` and `install.ps1` contain zero occurrences of either variable. So the fix was never "write a production compose"; it was that the default had to be the safe one.
+
+ `scripts/check_deployment_auth_posture.py` keeps it that way. It resolves `${VAR:-default}` against the env file each documented path uses, for every service in the compose file, with no Docker — a gate that needs a daemon does not run in the jobs that matter. It found **28 findings** before this change, across every service that reads the bypass flags. It also checks the opposite direction, that the developer overlay still sets all three flags, because four of its five rules are satisfied by deleting the developer path rather than making it explicit, and a gate that can be satisfied by deletion is not measuring what it claims to.
+
+ Compose now passes `AISOC_PUBLISHED_BIND_ADDRS` to all twelve services that read the bypass flags, derived from `AISOC_CONSOLE_BIND_ADDR` and `AISOC_BIND_ADDR`. A container binds `0.0.0.0` internally and cannot tell whether anyone else can reach it, so a service that is never told cannot refuse. The consequence is that following the single-host guide, which instructs `AISOC_CONSOLE_BIND_ADDR=0.0.0.0`, now switches the shim off by itself.
+
+ **Verified live, against a rebuilt image rather than the cached one.** Three postures on a real container: `make up` answers 401 to every anonymous request with no bypass variable set at all; `make up-dev` on loopback answers 200 and logs `ANONYMOUS ACCESS IS ENABLED … in tenant …00de`, the demo tenant rather than the operator's; and `make up-dev` with the console published on `0.0.0.0` answers 401 and logs the refusal naming the address. The first run of that probe graded a cached pre-fix image and had to be discarded, which is the reason the image is rebuilt rather than reused.
+
+- **`make smoke` now proves an anonymous write is refused**, on the API port and through the console proxy. Two doors, and only one was ever described: the proxy forwards `/api/v1/*`, so a stack that refuses on `:8000` and serves on `:3000` is still anonymous to anyone with a browser, and `:3000` is the port the single-host guide tells operators to publish. A connection error is reported as a skip rather than a pass, because "nothing answered" and "the right thing answered" must not print the same word.
+
+- **Two workflows booted the stack without generating any secrets, which only worked because the secrets did not matter.** `golden-pipeline.yml` seeded no `.env` at all and `compose-smoke.yml` copied `.env.example` and stopped, leaving every generated secret empty. That was survivable while `ENVIRONMENT` defaulted to `development`: `ingest` started on a `JWT_SECRET` literal published in this repository and the API's production checks only warned. With the default flipped, `ingest` refuses to start without `JWT_SECRET` and the API without `METRICS_TOKEN` — both services being right — and CI provisioned an environment no real deployment ever has.
+
+ Both now run `scripts/ensure_env.py`, which is what `make up` does. And `check_deployment_auth_posture.py` was extended to catch the class rather than the two instances: a workflow that runs `docker compose up` on the real compose file and never generates the secrets is a finding, with three self-test cases including a control for a workflow that only mentions the command in prose.
+
+- **`ingest-worker` shipped a published secret as a bare literal.** `JWT_SECRET: dev_secret_key_change_in_production` was hardcoded in `docker-compose.yml`, and that value is in `INSECURE_SECRET_KEY_DEFAULTS` — so anyone who read this repository held the key the service verified with, and no `.env` value could displace it. It is interpolated now and `make env` generates it. Found while wiring the two missing secrets into the API, which had the mirror-image defect: neither was declared on the `api` service at all, so a value in `.env` could not reach the container.
+
+- **Two stale claims on the single-host guide.** It said the datastores keep "the development passwords this repository ships in `.env.example`" and that `AISOC_BIND_ADDR` "hands out the shipped development passwords". `.env.example` ships those fields empty and `make env` generates a real password for each, so both sentences described a state that no longer existed. The `AISOC_BIND_ADDR` warning is still a warning, for the reason that is actually true: it makes the datastores reachable from the network rather than from this host alone.
+
- **An anonymous caller was an administrator in the operator's own tenant, on every documented deployment.** Three things had to be true at once and all three were, by default:
1. `ENVIRONMENT` defaulted to `development` in `docker-compose.yml`, in `.env.example`, and therefore in the `.env` that `scripts/ensure_env.py` copies verbatim on first run. `development` is in `AUTH_BYPASS_ENVIRONMENTS`, so `get_current_user` resolved a request with no bearer token to a demo user whose role is `admin`.
diff --git a/Makefile b/Makefile
index 6a3451304..30f569724 100644
--- a/Makefile
+++ b/Makefile
@@ -44,7 +44,7 @@ PROFILE_ARG := $(if $(PROFILE),--profile $(PROFILE),)
CONSOLE_URL = $(shell sed -n 's/^AISOC_CONSOLE_URL=//p' .env 2>/dev/null | tail -n1 | tr -d '\r')
console_url = $(if $(strip $(CONSOLE_URL)),$(strip $(CONSOLE_URL)),http://localhost:3000)
-.PHONY: help install env up up-full pull down restart status doctor smoke demo logs clean \
+.PHONY: help install env up up-dev up-full pull down restart status doctor smoke _anonymous_write_is_refused demo logs clean \
bootstrap ingest-token api-token test test-unit test-integration test-e2e stats papers \
papers-install demo-script
@@ -139,6 +139,29 @@ bootstrap:
# 8123 stopped the stack after eight containers had already started, with
# `Bind for 0.0.0.0:8123 failed: port is already allocated` naming neither the
# process holding it nor what to do.
+# The developer path, explicit. `make up` is production-class now: an
+# uncredentialed request gets a 401, because the value of ENVIRONMENT used to
+# decide whether a host was anonymous and it defaulted to `development`.
+# This target layers the overlay that turns the conveniences back on.
+#
+# Two `-f` flags rather than `include:`, which imports a model whose services
+# may not be overridden. The overlay was written that way and could therefore
+# never have carried an override, which is why it carried nothing.
+#
+# The bypass is still refused if the stack publishes a non-loopback address,
+# so this makes a laptop convenient rather than a server open.
+up-dev: env _ports _refresh
+ $(COMPOSE) -f docker-compose.yml -f infra/compose/docker-compose.dev.yml up -d
+ @$(MAKE) --no-print-directory _wait
+ @echo ""
+ @echo " Console: $(console_url)"
+ @echo " API: http://localhost:8000/api/docs"
+ @echo ""
+ @echo " Anonymous access is ON. This overlay is for a laptop, not a host"
+ @echo " anyone else can reach."
+ @echo ""
+ @$(MAKE) --no-print-directory bootstrap
+
up-full: env _ports _refresh
AISOC_LAKE_WRITER_ENABLED=true AISOC_GRAPH_ENABLED=true $(COMPOSE) --profile full up -d
@$(MAKE) --no-print-directory _wait PROFILE=full
@@ -277,7 +300,7 @@ api-token:
# The token is minted first because ingest is authenticated: the endpoint
# takes a credential that carries its own tenant rather than a header
# naming one. Minting here keeps `make smoke` a single command.
-smoke:
+smoke: _anonymous_write_is_refused
@token="$$($(COMPOSE) run --rm -T api python -m app.scripts.mint_ingest_token --quiet)" || { \
echo "Could not mint an ingest token — is the stack up? Try 'make doctor'."; \
exit 1; \
@@ -288,6 +311,33 @@ smoke:
}; \
AISOC_INGEST_TOKEN="$$token" AISOC_API_TOKEN="$$api" $(PYTHON) tests/e2e/golden_pipeline/run_golden_pipeline.py
+# Both surfaces, because they are different doors and only one of them was
+# ever described. The console proxy forwards /api/v1/* to the API, so a stack
+# that refuses on :8000 and serves on :3000 is still anonymous to anyone with
+# a browser — and :3000 is the one the single-host guide tells operators to
+# publish.
+#
+# A connection error is a skip, not a pass: "nothing answered" and "the right
+# thing answered" must not print the same word.
+_anonymous_write_is_refused:
+ @echo "Checking that an unauthenticated write is refused…"
+ @for target in "http://localhost:8000/api/v1/cases" "http://localhost:3000/api/v1/cases"; do \
+ code=$$(curl -s -o /dev/null -w '%{http_code}' -X POST "$$target" \
+ -H 'Content-Type: application/json' -d '{"title":"anonymous write probe"}' \
+ --max-time 10 2>/dev/null || echo 000); \
+ if [ "$$code" = "000" ]; then \
+ echo " SKIP $$target did not answer (not running?)"; \
+ elif [ "$$code" = "401" ] || [ "$$code" = "403" ]; then \
+ echo " OK $$target refused with $$code"; \
+ else \
+ echo " FAIL $$target answered $$code to a request carrying no credential."; \
+ echo " An uncredentialed caller must never be served. If you meant to"; \
+ echo " run the developer overlay, that is 'make up-dev' and it is not"; \
+ echo " safe on a host anyone else can reach."; \
+ exit 1; \
+ fi; \
+ done
+
demo:
@echo "Loading synthetic demo data. Every row is tagged is_synthetic=true"
@echo "and the console labels it. See 'Real vs synthetic data' in README.md."
diff --git a/PARITY_PROGRESS.md b/PARITY_PROGRESS.md
index f7f817405..93c731f58 100644
--- a/PARITY_PROGRESS.md
+++ b/PARITY_PROGRESS.md
@@ -24,8 +24,13 @@ finding, and the console suite is 816 tests green with a clean type-check.
Numbers re-derived at the start, to be used instead of the plan's:
-- **CORE is 17 compose services**, being those with no `profiles:` key, which
- is what `make up` starts. 16 if one-shot `ollama-pull` is excluded. See D3.
+- **CORE is 16 compose services**, and the tree already has an authoritative
+ answer: `scripts/check_profile_service_counts.py` reports `core 16, full 22`
+ and validates every published figure against `docker-compose.yml`. 16 counts
+ the long-running services and excludes the one-shot `ollama-pull`, which is
+ the right convention. Parity 1.2 is therefore not "derive the count" but
+ "point the four disagreeing strings at the gate that already derives it".
+ See D3.
- Claim matrix: **241 rows, 241 GATED, 0 PARTIAL, 0 NO GATE**.
- `scripts/` holds 183 `.py` files, 84 of them named `check_*.py`.
- Next migration number: **076**. Next ADR: **0009**.
@@ -64,19 +69,23 @@ against `ROUTER_PREFIX_DEFAULT = "/investigations"`, with a bidirectional
server-only allowlist. It is a working pattern to widen, not a greenfield
build. `scripts/check_sdk_surface.py` is SDK-only as the plan says.
-### D3. There is no `core` profile, so the CORE count has no single source
+### D3. There is no `core` profile, and the count already has a source
Plan item 1.2 says to "take the real count from `docker compose config` for the
CORE profile". There is no `core` profile in `docker-compose.yml`, so that
-command cannot answer the question. CORE is the set of services declaring no
-profile, which is 17 of the 32 declared: actions, agents, api, connectors,
-fusion, ingest-worker, kafka, litellm, ollama, ollama-pull, postgres, qdrant,
-realtime, redis, threatintel, web, zookeeper.
-
-Four places in the tree disagree with each other about it: `install.sh:784`
-says 10 while naming 9 on the next line, `walkthrough.mdx:80` says fifteen,
-`Makefile:157` says fifteen, and `scripts/generate_slo_alerts.py:5` says 17. So
-1.2 needs one derivation the others read from, not four string edits.
+command cannot answer the question — CORE is the set of services declaring no
+profile.
+
+But the derivation the plan asks for already exists.
+`scripts/check_profile_service_counts.py` reports `core 16, full 22`, holds 18
+published figures against the compose file, and refuses any new figure that no
+`CLAIM_SITES` entry validates. It refused one during this batch, correctly: a
+claim-matrix row published a service count that nothing checked.
+
+So 1.2 is not "derive the count". It is "point the four disagreeing strings at
+the gate that already derives it": `install.sh:784` says 10 while naming 9 on
+the next line, `walkthrough.mdx:80` says fifteen, `Makefile:157` says fifteen,
+and `scripts/generate_slo_alerts.py:5` says 17.
### D4. Three counts in 1.1 and 1.2 are wrong in different directions
diff --git a/README.md b/README.md
index 2046f3239..a50ed0731 100644
--- a/README.md
+++ b/README.md
@@ -57,7 +57,7 @@ Needs Docker Compose v2 with **8 GB memory and 20 GB free disk in the Docker VM*
was measured against. The first run downloads a ~2 GB language model into a named volume; only
`make clean` fetches it again.
-`make up` also creates `.env` and generates the **twelve** secrets in it — the credential vault,
+`make up` also creates `.env` and generates the **fourteen** secrets in it — the credential vault,
the session signing key, the five service-to-service credentials and the four datastore passwords — then
creates an administrator and prints its password. That password is generated on your machine, shown once, and stored nowhere:
copy it, or mint a new one with `make bootstrap ARGS=--reset-password`.
diff --git a/ROADMAP.md b/ROADMAP.md
index 85474e479..f9efe105c 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -44,7 +44,7 @@ A proof-first, security-first program to make every README claim gate-backed, cl
- **Phase D (breadth):** D1 eight connectors (QRadar/Exabeam/Securonix/Devo/Netskope/Windows-Sysmon/Zeek-Suricata/syslog-CEF) · D2 AI/LLM-usage audit connector + `llm-*` detections + hot/cold lake tiering · D3 live-vendor mock-server smoke.
- **Phase E (prove it):** E1 CI-gated benchmark scoreboard tied to a deterministic live-agent MITRE-accuracy run.
-The claim-to-gate matrix stands at **244 rows — 244 GATED / 0 PARTIAL / 0 NO GATE** — **every product claim is backed by a failing test**, none is a named deferral either, and the ratchet (`MAX_NO_GATE=0`) forbids any regression. Every PARTIAL row was closed by building the gate it named, never by relabelling. The last two rested on the live-agent eval workflow, which this file said had simply never run: the real reason was that its live path imported a class that exists nowhere in `services/agents`, so its first dispatch failed in 92 seconds and every later one would have. With that fixed the workflow measures, and the groundedness floor is **0.40 over a deterministic 10-incident slice**, derived from ten runs across two environments rather than chosen — seven local runs returning 0.5561 to four decimal places, three GitHub-runner runs returning 0.5821, 0.5329 and 0.5933. Every one is a locally-served `qwen2.5:0.5b`; no hosted provider has been exercised and the floor describes none. Count the table rows with `python3 scripts/check_claim_gate_matrix.py` rather than trusting a figure quoted in prose — this line has gone stale before. The six lettered deferrals are scoped in [`docs/audit/DEFERRED_SUBPHASES.md`](docs/audit/DEFERRED_SUBPHASES.md).
+The claim-to-gate matrix stands at **245 rows — 245 GATED / 0 PARTIAL / 0 NO GATE** — **every product claim is backed by a failing test**, none is a named deferral either, and the ratchet (`MAX_NO_GATE=0`) forbids any regression. Every PARTIAL row was closed by building the gate it named, never by relabelling. The last two rested on the live-agent eval workflow, which this file said had simply never run: the real reason was that its live path imported a class that exists nowhere in `services/agents`, so its first dispatch failed in 92 seconds and every later one would have. With that fixed the workflow measures, and the groundedness floor is **0.40 over a deterministic 10-incident slice**, derived from ten runs across two environments rather than chosen — seven local runs returning 0.5561 to four decimal places, three GitHub-runner runs returning 0.5821, 0.5329 and 0.5933. Every one is a locally-served `qwen2.5:0.5b`; no hosted provider has been exercised and the floor describes none. Count the table rows with `python3 scripts/check_claim_gate_matrix.py` rather than trusting a figure quoted in prose — this line has gone stale before. The six lettered deferrals are scoped in [`docs/audit/DEFERRED_SUBPHASES.md`](docs/audit/DEFERRED_SUBPHASES.md).
## v4.0 — Shipped
diff --git a/SECURITY_BATCH_PROGRESS.md b/SECURITY_BATCH_PROGRESS.md
index 56fef105c..66cb30756 100644
--- a/SECURITY_BATCH_PROGRESS.md
+++ b/SECURITY_BATCH_PROGRESS.md
@@ -151,10 +151,7 @@ bootstrapped into.
identity has its own tenant ([#1070](https://github.com/beenuar/AiSOC/pull/1072))
- [x] **S1b** The nine vendored shims, the three `require_service_auth` copies, slack-bot and
realtime push ([#1070](https://github.com/beenuar/AiSOC/pull/1072))
-- [ ] **S1d** Production-class defaults on every documented path: `install.sh`, `install.ps1`,
- `make up`, the dev overlay, the single-host guide, the walkthrough, `make smoke` asserting an
- anonymous write returns 401, and the gate that resolves the environment each documented path
- produces
+- [x] **S1d** Production-class defaults on every documented path ([#1073](https://github.com/beenuar/AiSOC/pull/1074))
## S2 to S13
@@ -182,6 +179,37 @@ bootstrapped into.
belongs to an unrelated project).
- [ ] File the advisories against the release once the batch has landed.
+### D9. Flipping the default to production stops the API booting, until two more secrets exist
+
+Found by starting the stack, not by a test. `enforce_secure_defaults` refuses
+to boot when `METRICS_TOKEN` or `JWT_SECRET` is empty and the environment is
+not development-class, and `ensure_env.py` generated neither, because in a
+development-class environment that check only warns. So the posture change on
+its own would have turned "anonymous administrator" into "the API will not
+start". Both are generated now, taking `make env` from twelve secrets to
+fourteen.
+
+Two adjacent defects surfaced in the same hour, both of the same shape as one
+this repository has hit before — a value in `.env` that cannot reach the
+container that needs it:
+
+* neither secret was declared on the `api` service in `docker-compose.yml`, so
+ generating them was not sufficient;
+* `ingest-worker` hardcoded `JWT_SECRET: dev_secret_key_change_in_production`
+ as a bare literal. That value is in `INSECURE_SECRET_KEY_DEFAULTS`, so
+ anyone who read this repository held the key the service verified with, and
+ no `.env` value could displace it.
+
+### D10. The first live verification graded a cached image
+
+The probe stack came up from `ghcr.io/beenuar/aisoc-core-api:latest`, which
+was already on the machine, so the first three posture results described the
+pre-fix API rather than this branch. They looked plausible: production refused
+and development admitted, which is true of both trees. The tell was the third
+case, where a published bind address failed to refuse — a control that does
+not exist in the old code. Rebuild before probing, and prefer a probe that has
+a case the old code cannot pass.
+
### D8. Two documents publish the claim-matrix row count in prose
`ROADMAP.md` and `apps/docs/docs/compliance/evidence-pack.md` both state the
diff --git a/apps/docs/docs/compliance/evidence-pack.md b/apps/docs/docs/compliance/evidence-pack.md
index 8bf97e4b0..ff2fec84b 100644
--- a/apps/docs/docs/compliance/evidence-pack.md
+++ b/apps/docs/docs/compliance/evidence-pack.md
@@ -33,7 +33,7 @@ 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: 244 rows
+The last row is the one worth reading first. It is the honest index: 245 rows
`GATED`, 0 `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
diff --git a/apps/docs/docs/deployment/docker.md b/apps/docs/docs/deployment/docker.md
index f1022a497..5cbb831f4 100644
--- a/apps/docs/docs/deployment/docker.md
+++ b/apps/docs/docs/deployment/docker.md
@@ -117,7 +117,7 @@ COMPOSE_PROFILES=connectors,osquery,slack docker compose up -d
## Production
```bash
-make env # generates the twelve secrets the stack needs
+make env # generates the fourteen secrets the stack needs
docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d
```
diff --git a/apps/docs/docs/deployment/single-host.md b/apps/docs/docs/deployment/single-host.md
index fe5033cbb..88e6d292b 100644
--- a/apps/docs/docs/deployment/single-host.md
+++ b/apps/docs/docs/deployment/single-host.md
@@ -35,8 +35,30 @@ The console is the **only** port a browser needs. The bundle it serves calls
same-origin paths — `/api/v1/alerts`, `/ws/…` — and the Next.js server
forwards them to the API, the agents service and the realtime gateway over the
internal Docker network. Publishing one port therefore exposes one service,
-and Postgres, Redis, Kafka and Neo4j stay on loopback with the development
-passwords this repository ships in `.env.example`.
+and Postgres, Redis, Kafka and Neo4j stay on loopback with the credentials
+`make env` generated for this install.
+
+:::info Publishing the console also switches off anonymous access
+`docker compose up -d` runs production-class: `ENVIRONMENT` defaults to
+`production` and `AISOC_DEV_MODE` to `0`, so a request carrying no bearer
+token gets a `401`. You do not have to set anything for that.
+
+Setting `AISOC_CONSOLE_BIND_ADDR=0.0.0.0` reinforces it. Compose passes the
+published addresses to each service as `AISOC_PUBLISHED_BIND_ADDRS`, and a
+service refuses the development auth shim outright when any of them is not
+loopback — even if someone sets `AISOC_DEV_AUTH_BYPASS=1` by hand. A container
+binds `0.0.0.0` internally and cannot work this out for itself, which is why
+the addresses are passed in rather than inferred.
+
+This used to be the other way round. `ENVIRONMENT` defaulted to `development`
+here and in `.env.example`, and in a development-class environment the API
+resolved an uncredentialed request to a demo user with the `admin` role whose
+tenant was the same one `make bootstrap` put your real account in. Following
+this page therefore published an anonymous administrator over your own data.
+If you are upgrading, nothing is required: the default changed. What changed
+for you is that `make up` no longer signs you in automatically — use
+`make up-dev` on a laptop if you want that back.
+:::
```bash
docker compose up -d
@@ -53,8 +75,9 @@ readable by anything on the path.
There is a second variable, `AISOC_BIND_ADDR`, which moves **every** binding
including the datastores. It exists for an isolated network where you want
-`psql` from another machine. On a routable network it hands out the shipped
-development passwords, so rotate them first, or leave it alone and use an SSH
+`psql` from another machine. `make env` generates a real password for each
+datastore, so these are not shipped literals any more, but they are now
+reachable from the network rather than from this host alone. Prefer an SSH
tunnel.
### Also set the console's own address
diff --git a/apps/docs/docs/deployment/walkthrough.mdx b/apps/docs/docs/deployment/walkthrough.mdx
index 01bffd438..1c7f186cc 100644
--- a/apps/docs/docs/deployment/walkthrough.mdx
+++ b/apps/docs/docs/deployment/walkthrough.mdx
@@ -61,6 +61,20 @@ the only port a browser needs — its Next.js server proxies same-origin paths t
the API, the agents service and the realtime gateway over the internal network
— so publishing one port exposes one service and the datastores stay private.
+Publishing it also hardens authentication rather than weakening it. The stack
+runs production-class by default, so a request with no bearer token gets a
+`401`; and because compose passes the published addresses to each service as
+`AISOC_PUBLISHED_BIND_ADDRS`, a non-loopback value makes every service refuse
+the development auth shim outright, even if somebody sets
+`AISOC_DEV_AUTH_BYPASS=1` by hand.
+
+That is the opposite of how this page used to read. `ENVIRONMENT` defaulted to
+`development` in the compose file and in `.env.example`, and in a
+development-class environment an uncredentialed request resolved to a demo
+user carrying the `admin` role, in the same tenant your real administrator was
+about to be created in. If you want the signed-in-automatically experience on
+a laptop, that is now `make up-dev`.
+
The second decides which address AiSOC *tells* people to use. `make up` and
`make bootstrap` both print it when the administrator is created. Leave it at
the default and a server deployment prints `http://localhost:3000`, which
diff --git a/apps/docs/docs/detections/hello-hunt.md b/apps/docs/docs/detections/hello-hunt.md
index 448ffcea0..bcd0c9843 100644
--- a/apps/docs/docs/detections/hello-hunt.md
+++ b/apps/docs/docs/detections/hello-hunt.md
@@ -282,7 +282,7 @@ If you have a running AiSOC dev stack and want to see the rule fire end to end:
```bash
# 1. Restart the API so it reloads the detection corpus from disk.
-docker compose -f infra/compose/docker-compose.dev.yml restart api
+docker compose -f docker-compose.yml -f infra/compose/docker-compose.dev.yml restart api
# 2. Replay the positive fixture into the ingest pipeline.
curl -X POST http://localhost:8000/v1/ingest/batch \
diff --git a/apps/docs/docs/intro.md b/apps/docs/docs/intro.md
index 6489b5204..b648137df 100644
--- a/apps/docs/docs/intro.md
+++ b/apps/docs/docs/intro.md
@@ -120,7 +120,7 @@ See the full [Architecture](./architecture) page for the detailed service map an
### Get started
- [One-click install](./installation) — zero-prerequisite bootstrap for Linux, macOS, and Windows
-- [Quick Start](./quickstart) — `pnpm aisoc:demo`, under 5 minutes to a live investigation. The **Path C — founder-style CLI** flow (`docker compose -f infra/compose/docker-compose.dev.yml up -d` → `aisoc db upgrade` → `aisoc serve` → `aisoc submit examples/alerts/lateral-movement.json`) goes from fresh clone to a live alert at `http://localhost:3000/alerts` in under 90 seconds, with no Kafka / Fusion required for the first alert.
+- [Quick Start](./quickstart) — `pnpm aisoc:demo`, under 5 minutes to a live investigation. The **Path C — founder-style CLI** flow (`docker compose -f docker-compose.yml -f infra/compose/docker-compose.dev.yml up -d` → `aisoc db upgrade` → `aisoc serve` → `aisoc submit examples/alerts/lateral-movement.json`) goes from fresh clone to a live alert at `http://localhost:3000/alerts` in under 90 seconds, with no Kafka / Fusion required for the first alert.
- [Architecture](./architecture) — service map and data flow
- [Glossary](./glossary) — security and AiSOC-specific terminology in one place
- [FAQ](./operations/faq) — common questions about scope, deployment, data, and licensing
diff --git a/apps/docs/docs/operations/upgrades.md b/apps/docs/docs/operations/upgrades.md
index 5d80da716..6ba8c213e 100644
--- a/apps/docs/docs/operations/upgrades.md
+++ b/apps/docs/docs/operations/upgrades.md
@@ -79,7 +79,7 @@ aisoc db upgrade
# which ships a partially-applied schema silently.
# 5. Start the API service back up.
-docker compose -f infra/compose/docker-compose.dev.yml up -d api
+docker compose -f docker-compose.yml -f infra/compose/docker-compose.dev.yml up -d api
# 6. Verify health and remove the maintenance gate.
curl -fsS http://localhost:8000/healthz
@@ -120,7 +120,7 @@ pnpm install --frozen-lockfile
# Additive migrations (the common case) are backward compatible, so the previous
# code runs against the newer schema. If a migration was destructive, restore the
# snapshot instead — the CHANGELOG flags those as irreversible.
-docker compose -f infra/compose/docker-compose.dev.yml up -d api
+docker compose -f docker-compose.yml -f infra/compose/docker-compose.dev.yml up -d api
```
Major releases occasionally ship one-way migrations (e.g. column drops). When that's the case, the CHANGELOG flags the migration as "irreversible" and the only rollback is restoring from the database snapshot you took in step 2 of the pre-upgrade checklist.
diff --git a/apps/docs/docs/quickstart.md b/apps/docs/docs/quickstart.md
index 3ac887565..dc4e33119 100644
--- a/apps/docs/docs/quickstart.md
+++ b/apps/docs/docs/quickstart.md
@@ -429,7 +429,7 @@ You should see the operator commands: `serve`, `db`, `mcp`, `submit`,
aisoc serve
```
-Under the hood this runs `docker compose -f infra/compose/docker-compose.dev.yml up -d`
+Under the hood this runs `docker compose -f docker-compose.yml -f infra/compose/docker-compose.dev.yml up -d`
against the dev profile. The command resolves the repo root automatically, so
it works from any subdirectory.
@@ -559,7 +559,7 @@ run `pnpm build`.
### 7. Tear down
```bash
-docker compose -f infra/compose/docker-compose.dev.yml down
+docker compose -f docker-compose.yml -f infra/compose/docker-compose.dev.yml down
```
Or keep the stack running and re-submit different fixtures — `aisoc
diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml
index 4c4de2ac8..7bd2dca1d 100644
--- a/docker-compose.prod.yml
+++ b/docker-compose.prod.yml
@@ -15,10 +15,12 @@
# A standalone copy would have drifted from the base within a release, which is
# the failure this repository keeps finding.
#
-# It was written with the Compose Spec `include` directive and a single `-f`,
-# which is how `infra/compose/docker-compose.dev.yml` pulls the base in. That
-# does not work here: `include` imports a model, and overriding a service it
+# It was written with the Compose Spec `include` directive and a single `-f`.
+# That does not work: `include` imports a model, and overriding a service it
# imported is rejected with `services.<name> conflicts with imported resource`.
+# `infra/compose/docker-compose.dev.yml` had the same shape and has since
+# moved to a two-`-f` overlay for the same reason — it could never have
+# carried an override, which is why it carried nothing.
# Measured rather than assumed — `-f docker-compose.prod.yml` alone fails on
# Compose v2.29.7 and v2.39.4 and resolves only on 5.1.3, so the documented
# production command worked on almost no installation. Two `-f` flags are the
diff --git a/docker-compose.yml b/docker-compose.yml
index 809e8effb..af9431c5b 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -404,6 +404,12 @@ services:
# was passed to either side before, which is why both guards there were
# running on a published constant or not running at all.
AISOC_REALTIME_JWT_SECRET: ${AISOC_REALTIME_JWT_SECRET:-}
+ # Both are required for the API to boot now that ENVIRONMENT defaults
+ # to production, and neither was interpolated here — so a value in .env
+ # could not reach the container, which is the same shape that once left
+ # AISOC_SERVICE_TOKEN unreachable to this one service.
+ METRICS_TOKEN: ${METRICS_TOKEN:-}
+ JWT_SECRET: ${JWT_SECRET:-}
REALTIME_INTERNAL_TOKEN: ${REALTIME_INTERNAL_TOKEN:-}
# The credential this service presents when it proxies the connector
# catalog and "Test connection" to the connectors service.
@@ -440,7 +446,11 @@ services:
# Was a bare literal, so `.env`'s documented ENVIRONMENT was ignored and
# `production` changed nothing — including the dev auth bypass in
# app/api/v1/dev_auth.py, which could not be switched off from .env at all.
- ENVIRONMENT: ${ENVIRONMENT:-development}
+ ENVIRONMENT: ${ENVIRONMENT:-production}
+ # What this deployment published, so the service can refuse the
+ # anonymous auth shim on an address someone else can reach. It
+ # binds 0.0.0.0 inside the container and cannot tell otherwise.
+ AISOC_PUBLISHED_BIND_ADDRS: ${AISOC_CONSOLE_BIND_ADDR:-${AISOC_BIND_ADDR:-127.0.0.1}},${AISOC_BIND_ADDR:-127.0.0.1}
LOG_LEVEL: ${LOG_LEVEL:-info}
# Issue #478 — LiteLLM gateway. This service's live LLM endpoints
# (translation, hunts, KB, phishing, NL-detection) route here by default:
@@ -502,7 +512,11 @@ services:
# operator set it, and `JWT_SECRET must be set in non-development
# environments` never fired on the one service taking events off the
# network.
- ENV: ${ENVIRONMENT:-development}
+ ENV: ${ENVIRONMENT:-production}
+ # What this deployment published, so the service can refuse the
+ # anonymous auth shim on an address someone else can reach. It
+ # binds 0.0.0.0 inside the container and cannot tell otherwise.
+ AISOC_PUBLISHED_BIND_ADDRS: ${AISOC_CONSOLE_BIND_ADDR:-${AISOC_BIND_ADDR:-127.0.0.1}},${AISOC_BIND_ADDR:-127.0.0.1}
HTTP_PORT: 8080
METRICS_PORT: 9090
KAFKA_BOOTSTRAP_SERVERS: kafka:29092
@@ -514,7 +528,11 @@ services:
# DATABASE_URL the Python services use.
DATABASE_DSN: postgres://aisoc_app:${AISOC_APP_DB_PASSWORD:-aisoc_app_dev_secret}@postgres:5432/aisoc?sslmode=disable
LOG_LEVEL: info
- JWT_SECRET: dev_secret_key_change_in_production
+ # A bare literal, and a published one: `dev_secret_key_change_in_production`
+ # is in INSECURE_SECRET_KEY_DEFAULTS, so anyone who read this repository
+ # held the key this service verified with. Interpolated now, and `make
+ # env` generates it.
+ JWT_SECRET: ${JWT_SECRET:-}
# /v1/ingest requires a credential. Two shapes are accepted: a
# per-tenant push token minted with `make ingest-token` (resolved
# through DATABASE_DSN above), and this shared service token, which
@@ -589,7 +607,11 @@ services:
# service token is configured and dev mode is off, and this service
# received none of the three — the same trio `connectors` and
# `threatintel` already carry.
- AISOC_DEV_MODE: ${AISOC_DEV_MODE:-1}
+ AISOC_DEV_MODE: ${AISOC_DEV_MODE:-0}
+ # What this deployment published, so the service can refuse the
+ # anonymous auth shim on an address someone else can reach. It
+ # binds 0.0.0.0 inside the container and cannot tell otherwise.
+ AISOC_PUBLISHED_BIND_ADDRS: ${AISOC_CONSOLE_BIND_ADDR:-${AISOC_BIND_ADDR:-127.0.0.1}},${AISOC_BIND_ADDR:-127.0.0.1}
SECRET_KEY: ${SECRET_KEY:-}
AISOC_SERVICE_TOKEN: ${AISOC_SERVICE_TOKEN:-}
DATABASE_URL: postgresql+asyncpg://aisoc_app:${AISOC_APP_DB_PASSWORD:-aisoc_app_dev_secret}@postgres:5432/aisoc
@@ -674,7 +696,11 @@ services:
# configured *and* dev mode is off — which is what every tenant-scoped
# route here answered: 503, with no credential material to verify
# against and nothing in the image supplying any.
- AISOC_DEV_MODE: ${AISOC_DEV_MODE:-1}
+ AISOC_DEV_MODE: ${AISOC_DEV_MODE:-0}
+ # What this deployment published, so the service can refuse the
+ # anonymous auth shim on an address someone else can reach. It
+ # binds 0.0.0.0 inside the container and cannot tell otherwise.
+ AISOC_PUBLISHED_BIND_ADDRS: ${AISOC_CONSOLE_BIND_ADDR:-${AISOC_BIND_ADDR:-127.0.0.1}},${AISOC_BIND_ADDR:-127.0.0.1}
SECRET_KEY: ${SECRET_KEY:-}
AISOC_SERVICE_TOKEN: ${AISOC_SERVICE_TOKEN:-}
# The agents service's own service credential, used in both directions:
@@ -861,7 +887,11 @@ services:
# service token is configured and dev mode is off, and this service
# received none of the three — the same trio `connectors` and
# `threatintel` already carry.
- AISOC_DEV_MODE: ${AISOC_DEV_MODE:-1}
+ AISOC_DEV_MODE: ${AISOC_DEV_MODE:-0}
+ # What this deployment published, so the service can refuse the
+ # anonymous auth shim on an address someone else can reach. It
+ # binds 0.0.0.0 inside the container and cannot tell otherwise.
+ AISOC_PUBLISHED_BIND_ADDRS: ${AISOC_CONSOLE_BIND_ADDR:-${AISOC_BIND_ADDR:-127.0.0.1}},${AISOC_BIND_ADDR:-127.0.0.1}
SECRET_KEY: ${SECRET_KEY:-}
AISOC_SERVICE_TOKEN: ${AISOC_SERVICE_TOKEN:-}
# The ingest service is registered as `ingest-worker` in this compose
@@ -921,7 +951,11 @@ services:
# require_service_auth returns 503 on every mutating route without it
# in any other environment, which is the intended failure.
AISOC_ACTIONS_SERVICE_TOKEN: ${AISOC_ACTIONS_SERVICE_TOKEN:-}
- AISOC_DEV_MODE: ${AISOC_DEV_MODE:-1}
+ AISOC_DEV_MODE: ${AISOC_DEV_MODE:-0}
+ # What this deployment published, so the service can refuse the
+ # anonymous auth shim on an address someone else can reach. It
+ # binds 0.0.0.0 inside the container and cannot tell otherwise.
+ AISOC_PUBLISHED_BIND_ADDRS: ${AISOC_CONSOLE_BIND_ADDR:-${AISOC_BIND_ADDR:-127.0.0.1}},${AISOC_BIND_ADDR:-127.0.0.1}
networks:
- aisoc
restart: unless-stopped
@@ -974,8 +1008,12 @@ services:
# purple-team and slack-bot, and not on connectors. Dev mode only applies
# when nothing is configured, so once `make env` generates a real
# AISOC_SERVICE_TOKEN this flag stops having any effect.
- AISOC_DEV_MODE: ${AISOC_DEV_MODE:-1}
- ENVIRONMENT: ${ENVIRONMENT:-development}
+ AISOC_DEV_MODE: ${AISOC_DEV_MODE:-0}
+ # What this deployment published, so the service can refuse the
+ # anonymous auth shim on an address someone else can reach. It
+ # binds 0.0.0.0 inside the container and cannot tell otherwise.
+ AISOC_PUBLISHED_BIND_ADDRS: ${AISOC_CONSOLE_BIND_ADDR:-${AISOC_BIND_ADDR:-127.0.0.1}},${AISOC_BIND_ADDR:-127.0.0.1}
+ ENVIRONMENT: ${ENVIRONMENT:-production}
KAFKA_BOOTSTRAP_SERVERS: kafka:29092
REDIS_URL: redis://:${REDIS_PASSWORD:-redis_dev_secret}@redis:6379/6
DATABASE_URL: postgresql+asyncpg://aisoc_app:${AISOC_APP_DB_PASSWORD:-aisoc_app_dev_secret}@postgres:5432/aisoc
@@ -1050,7 +1088,11 @@ services:
# Same credential the API presents when it proxies /threat-intel/indicators.
SECRET_KEY: ${SECRET_KEY:-dev_secret_key_change_in_production}
AISOC_SERVICE_TOKEN: ${AISOC_SERVICE_TOKEN:-}
- AISOC_DEV_MODE: ${AISOC_DEV_MODE:-1}
+ AISOC_DEV_MODE: ${AISOC_DEV_MODE:-0}
+ # What this deployment published, so the service can refuse the
+ # anonymous auth shim on an address someone else can reach. It
+ # binds 0.0.0.0 inside the container and cannot tell otherwise.
+ AISOC_PUBLISHED_BIND_ADDRS: ${AISOC_CONSOLE_BIND_ADDR:-${AISOC_BIND_ADDR:-127.0.0.1}},${AISOC_BIND_ADDR:-127.0.0.1}
MISP_URL: ${MISP_URL:-}
MISP_API_KEY: ${MISP_API_KEY:-}
OTX_API_KEY: ${OTX_API_KEY:-}
@@ -1096,7 +1138,11 @@ services:
CLICKHOUSE_URL: http://aisoc:${CLICKHOUSE_PASSWORD:-clickhouse_dev_secret}@clickhouse:8123/aisoc
CORE_API_URL: http://api:8000
AISOC_SERVICE_TOKEN: ${AISOC_SERVICE_TOKEN:-}
- AISOC_DEV_MODE: ${AISOC_DEV_MODE:-1}
+ AISOC_DEV_MODE: ${AISOC_DEV_MODE:-0}
+ # What this deployment published, so the service can refuse the
+ # anonymous auth shim on an address someone else can reach. It
+ # binds 0.0.0.0 inside the container and cannot tell otherwise.
+ AISOC_PUBLISHED_BIND_ADDRS: ${AISOC_CONSOLE_BIND_ADDR:-${AISOC_BIND_ADDR:-127.0.0.1}},${AISOC_BIND_ADDR:-127.0.0.1}
# A detached consumer used to read as `running`. /readyz answers 503 when
# the subscription is gone or the schema is not at head, so `docker compose
# ps` and `make _wait` now see the difference.
@@ -1151,7 +1197,11 @@ services:
KAFKA_BOOTSTRAP_SERVERS: kafka:29092
CORE_API_URL: http://api:8000
AISOC_SERVICE_TOKEN: ${AISOC_SERVICE_TOKEN:-}
- AISOC_DEV_MODE: ${AISOC_DEV_MODE:-1}
+ AISOC_DEV_MODE: ${AISOC_DEV_MODE:-0}
+ # What this deployment published, so the service can refuse the
+ # anonymous auth shim on an address someone else can reach. It
+ # binds 0.0.0.0 inside the container and cannot tell otherwise.
+ AISOC_PUBLISHED_BIND_ADDRS: ${AISOC_CONSOLE_BIND_ADDR:-${AISOC_BIND_ADDR:-127.0.0.1}},${AISOC_BIND_ADDR:-127.0.0.1}
# A detached consumer used to read as `running`. /readyz answers 503 when
# the subscription is gone or the schema is not at head, so `docker compose
# ps` and `make _wait` now see the difference.
@@ -1204,7 +1254,11 @@ services:
CORE_API_URL: http://api:8000
ATTCK_DATA_PATH: /app/data/enterprise-attack.json
AISOC_SERVICE_TOKEN: ${AISOC_SERVICE_TOKEN:-}
- AISOC_DEV_MODE: ${AISOC_DEV_MODE:-1}
+ AISOC_DEV_MODE: ${AISOC_DEV_MODE:-0}
+ # What this deployment published, so the service can refuse the
+ # anonymous auth shim on an address someone else can reach. It
+ # binds 0.0.0.0 inside the container and cannot tell otherwise.
+ AISOC_PUBLISHED_BIND_ADDRS: ${AISOC_CONSOLE_BIND_ADDR:-${AISOC_BIND_ADDR:-127.0.0.1}},${AISOC_BIND_ADDR:-127.0.0.1}
# A detached consumer used to read as `running`. /readyz answers 503 when
# the subscription is gone or the schema is not at head, so `docker compose
# ps` and `make _wait` now see the difference.
@@ -1284,7 +1338,11 @@ services:
SLACK_APPROVALS_CHANNEL: ${SLACK_APPROVALS_CHANNEL:-}
# Shared with the agents service, which calls /internal/approval-card.
AISOC_INTERNAL_TOKEN: ${AISOC_INTERNAL_TOKEN:-}
- AISOC_DEV_MODE: ${AISOC_DEV_MODE:-1}
+ AISOC_DEV_MODE: ${AISOC_DEV_MODE:-0}
+ # What this deployment published, so the service can refuse the
+ # anonymous auth shim on an address someone else can reach. It
+ # binds 0.0.0.0 inside the container and cannot tell otherwise.
+ AISOC_PUBLISHED_BIND_ADDRS: ${AISOC_CONSOLE_BIND_ADDR:-${AISOC_BIND_ADDR:-127.0.0.1}},${AISOC_BIND_ADDR:-127.0.0.1}
networks:
- aisoc
restart: unless-stopped
diff --git a/docs/audit/CLAIM_TO_GATE_MATRIX.md b/docs/audit/CLAIM_TO_GATE_MATRIX.md
index 5c5713370..5b907698b 100644
--- a/docs/audit/CLAIM_TO_GATE_MATRIX.md
+++ b/docs/audit/CLAIM_TO_GATE_MATRIX.md
@@ -251,11 +251,12 @@ Statuses: `GATED` (a CI job fails when the claim stops being true) · `PARTIAL`
| A published Helm chart version names one chart forever | `apps/docs/docs/deployment/kubernetes.md` (The chart's version); `infra/helm/aisoc/Chart.yaml` | `helm.yml :: version` + `release.yml :: chart-publish` (`check_chart_version.py` — four checks that need no network: `appVersion` moved while the chart's own `version` did not, any tracked chart file moved with no version bump (with Chart.yaml's own `version:` masked, so the bump cannot justify itself), a version that moved backward, and one chart version declared at two release tags with differing content. Plus one that asks GHCR: the version about to be pushed already exists holding content this tree does not. The registry comparison is on **unpacked files**, because `helm package` is not byte-reproducible — `Chart.yaml` is compared parsed since helm re-serialises it, and the tracked subchart `.tgz` are expanded the way helm expands them, a mapping measured exact against the published 5.9.2 at 146 files. On a release it runs with `--require-network`, before `helm push`, because the push overwrites silently and there is no after. 16 self-test cases, and the gate refuses a checkout with no tags rather than concluding no release ever declared a version) | GATED | **Proven against the pre-fix tree**: at `2db6ce73` (the v13.0.0 release commit) it exits 1 naming `appversion-moved-alone` — `v12.3.2` -> `v13.0.0` with `version` held at 5.9.2 — and exits 0 at `9d3225c6` after the bump to 6.0.0. **Two things it deliberately does not decide.** Whether a bump is the right *size*: nothing in a diff knows if a renamed `values.yaml` key breaks somebody's values file, so the gate enforces forward, never how far. And the overwrite that already happened: republishing replaced the bytes, so the registry's 5.9.2 and the tree that overwrote it are now byte-identical — measured, 146 files, zero differences — which is why the retro-detection reads git rather than the registry, and why the pre-fix proof runs through the baseline check. `5.9.2` and `5.2.0` are recorded in `KNOWN_COLLISIONS` as unrepairable, checked in both directions so an entry that stops being detectable fails |
| Every console call to an AiSOC API carries a credential | `apps/web/src/lib/api.ts` (the credentialed client); `SECURITY.md` (authentication) | `ci.yml :: Python — Lint & Type-check` (`check_console_auth_headers.py` — parses every `fetch(` and `useSWR(` call under `apps/web/src` and requires the credential to be visible on the same expression, so hiding it behind a local `const headers` a few lines up does not count. `X-Tenant-Id` alone and `credentials: 'include'` are both findings, because neither authenticates against a bearer-token API. 15 self-test cases, of which three pin blind spots in the gate's own first draft — a generic type argument hid both real SWR sites, a multi-line arrow fetcher was truncated at the first newline, and an inline fetcher whose URL is the SWR key has no API path at the call site — and four are controls that must not fire. It refuses a tree with no console sources, and separately refuses one where the console makes no API call at all, since a broken matcher and a console that stopped calling the API print the same clean line) | GATED | **Proven against the pre-fix tree**: 61 findings across 21 files at `079fdb69` (45 bare fetches, 16 SWR fetchers), 0 after. One allowlisted exception, the public `/r/<slug>` replay permalink, which is unauthenticated by design and is kept safe by `replay_redaction.py` rather than by a header; the allowlist may only shrink and a stale entry fails the gate. One limit stated rather than implied: the gate reads the console, so it proves the credential is sent, not that the server requires it — `check_route_auth.py` and `check_route_authz.py` are the other half |
| An unauthenticated request is never an administrator, and never acts in a real tenant | `SECURITY.md` (authentication); `apps/docs/docs/deployment/single-host.md` | `ci.yml :: Python — Tests` (`services/api/tests/test_anonymous_bypass_requires_optin.py`, 36 cases: the four names in `AUTH_BYPASS_ENVIRONMENTS` each refuse on their own; the explicit `AISOC_DEV_AUTH_BYPASS` opt-in admits; five truthy and five falsy spellings of it; the flag does not re-enable the shim outside a dev environment; five reachable published addresses refuse and five loopback forms admit; one reachable address among several refuses; the demo tenant is not the bootstrap tenant and the canonical id did not move; and every refusal names the condition that withheld it) + the nine vendored copies of `services/fusion/tests/test_tenant_scope.py` kept in lockstep by `sync_vendored_tenant_scope.py --check` + `services/realtime/test/push-tenant.test.ts` | GATED | **Proven against the pre-fix tree**: 35 of 36 API cases fail at `079fdb69` and all 36 pass after, with the tenant-sharing assertion failing as `assert UUID('…0001') != UUID('…0001')`; 4 of 8 realtime cases fail pre-fix, the other 4 being controls that must pass both ways. Two limits stated rather than implied. The loopback check is only as good as what compose passes in `AISOC_PUBLISHED_BIND_ADDRS`: an unset list is treated as a local run, because refusing on an empty list would break `uvicorn app.main:app` for contributors, which is the case the shim exists for — the deployment-path gate is what stops a published stack leaving it unset. And a hostname that is not obviously loopback is treated as reachable, so a DNS name resolving to 127.0.0.1 refuses the bypass; that is the safe direction for an undecidable question, and it is a false refusal, never a false admission |
+| Every documented way to start AiSOC produces a production-class posture | `README.md` (quick start); `apps/docs/docs/deployment/single-host.md`; `apps/docs/docs/deployment/walkthrough.mdx` | `ci.yml :: Python — Lint & Type-check` (`check_deployment_auth_posture.py` — resolves `${VAR:-default}` against the env file each documented path uses, for every service in the compose file, with no Docker, and fails on a development-class `ENV`/`ENVIRONMENT`, a truthy `AISOC_DEV_MODE`, `AISOC_DEV_AUTH_BYPASS` outside the overlay, a service that reads the flags without being told its published addresses, or an entry point that exports any of them. 13 self-test cases, three of them controls) + `ci.yml :: Python — Tests` (`tests/test_compose_environment_gate.py`, `tests/test_production_compose_gate.py`) + `make smoke`, which answers 401 to an anonymous write on the API port and through the console proxy | GATED | **Proven against the pre-fix tree**: 28 findings at `03e923f3`, across every service that reads the bypass flags; 0 after. **And verified live on a rebuilt image**, three postures on a real container: `make up` answers 401 with no bypass variable set; `make up-dev` on loopback answers 200 and logs the activation warning naming the demo tenant; `make up-dev` with the console on `0.0.0.0` answers 401 and logs the refusal naming the address. The first probe run graded a cached pre-fix image and was discarded, which is why the claim says rebuilt. One limit stated rather than implied: the gate reads declarations, so it proves the *shipped* default is production-class, not that a particular operator's `.env` is — an operator who writes `ENVIRONMENT=development` and `AISOC_DEV_AUTH_BYPASS=1` by hand has asked for it, and the loopback refusal is what still stands between that and a reachable host |
| Repeated credential failures are throttled and eventually locked out | `SECURITY.md` (what to review) | `ci.yml :: Python — Tests` (`services/api/tests/test_login_throttle.py`, 18 cases, and `services/api/tests/test_login_route_throttled.py`, 4 that drive the real route — because a gate on the limiter alone passes over a route that never calls it, and that was the defect: three limiters existed in this service and login consulted none of them. Asserted in both directions: a success clears the account counter and not the source counter; password spraying trips the source counter without ever tripping an account counter; an address that does not exist is refused identically to one that does; and Redis being down degrades to per-replica counting rather than locking everyone out) | GATED | **Proven against the pre-fix tree**: the four route cases fail at `4f4ba326` as `assert 429 in [401, 401, 401, ...]`, and the control — the first two attempts still answering 401 — passes on both trees, so the suite cannot be satisfied by a route that refuses everyone. Two limits stated rather than implied. The source counter is evadable where `X-Forwarded-For` is not stripped by a trusted proxy, since an attacker can rotate it for a fresh bucket per request; that is why the account counter is the primary control, and why the source counter is aimed at spraying, where per-request rotation is not something an attacker expects to need. And the fallback is per-replica, so an attacker spread across replicas gets one budget per replica — weaker than shared counting, and recorded as weaker |
## Summary
-- GATED: 244
+- GATED: 245
- PARTIAL: 0
- NO GATE: 0 (**every claim is backed by a failing test, and none is now a named deferral either.** The last NO GATE — the weekly benchmark scoreboard running live against `main` — closed in Phase E1: `scripts/check_scoreboard.py` ties the published scoreboard to a deterministic per-PR live-agent MITRE-accuracy run, while the funded weekly `wet-eval.yml` appends the LLM-tier rows. The last two PARTIAL rows closed with `scripts/check_live_agent_floor.py` and a floor derived from ten runs across two environments, not by relabelling. Recount with `scripts/check_claim_gate_matrix.py` rather than trusting these three numbers: they move weekly, and a count copied into prose goes stale in silence.)
diff --git a/infra/compose/docker-compose.dev.yml b/infra/compose/docker-compose.dev.yml
index a998de03b..4f0334f2e 100644
--- a/infra/compose/docker-compose.dev.yml
+++ b/infra/compose/docker-compose.dev.yml
@@ -1,15 +1,106 @@
-# AiSOC — developer compose entrypoint.
+# AiSOC — the developer overlay.
#
-# This file is a thin alias over `docker-compose.yml` so that the Quickstart
-# guide and demo scripts can use a stable, dev-flavoured command:
+# Layer this on top of the root compose file to turn on the conveniences a
+# contributor wants on a laptop and nobody wants on a reachable host:
#
-# docker compose -f infra/compose/docker-compose.dev.yml up -d
+# docker compose -f docker-compose.yml -f infra/compose/docker-compose.dev.yml up -d
#
-# It uses the Compose Spec `include` directive (Docker Compose v2.20+) to
-# pull in the full stack from the repo-root `docker-compose.yml` without
-# duplicating any service definitions. Override files (e.g.
-# `docker-compose.local.yml`) can still be layered on top with additional
-# `-f` flags.
+# or simply `make up-dev`, which passes both files for you.
+#
+# Two `-f` flags, not `include:`. This file used to be a fifteen-line alias
+# that pulled the root file in through the Compose Spec `include` directive
+# and added nothing at all. `include` imports a *model* whose services may not
+# be overridden, so it could never have carried the overrides below; an
+# ordinary overlay can, and works on every Compose v2 the project supports.
+#
+# What it turns on, and why each is off by default
+# ------------------------------------------------
+# `ENVIRONMENT=development` selects table autocreate, the docs UI, relaxed
+# `/metrics`, human-readable logs, GraphiQL and an ephemeral credential-vault
+# key. It also used to be the single condition under which the API served a
+# request with no bearer token as an administrator, and it defaulted to this
+# value in the root compose file and in `.env.example`. So every stock
+# `docker compose up` ran anonymous, and nobody chose it.
+#
+# `AISOC_DEV_MODE=1` is the same story on the other nine services: it lets
+# them admit an uncredentialed caller when neither `SECRET_KEY` nor a service
+# token is configured.
+#
+# `AISOC_DEV_AUTH_BYPASS=1` is the flag that actually enables the anonymous
+# path now. It exists because the two above mean nine other things between
+# them, and a flag that means nine things cannot be refused for one of them.
+# It is set here and nowhere else in the repository.
+#
+# The bypass is still refused on a published address
+# --------------------------------------------------
+# Even with all three set, a service declines to serve an anonymous caller
+# when `AISOC_PUBLISHED_BIND_ADDRS` names anything that is not loopback. The
+# root compose file derives that from `AISOC_CONSOLE_BIND_ADDR` and
+# `AISOC_BIND_ADDR`, so publishing the console on `0.0.0.0` turns the bypass
+# off by itself. That is deliberate: this overlay makes a laptop convenient,
+# not a server open.
+
+services:
+ api:
+ environment:
+ ENVIRONMENT: development
+ AISOC_DEV_MODE: 1
+ AISOC_DEV_AUTH_BYPASS: 1
+
+ ingest-worker:
+ environment:
+ ENV: development
+ ENVIRONMENT: development
+ AISOC_DEV_MODE: 1
+ AISOC_DEV_AUTH_BYPASS: 1
+
+ fusion:
+ environment:
+ AISOC_DEV_MODE: 1
+ AISOC_DEV_AUTH_BYPASS: 1
+
+ agents:
+ environment:
+ AISOC_DEV_MODE: 1
+ AISOC_DEV_AUTH_BYPASS: 1
+
+ actions:
+ environment:
+ AISOC_DEV_MODE: 1
+ AISOC_DEV_AUTH_BYPASS: 1
+
+ connectors:
+ environment:
+ AISOC_DEV_MODE: 1
+ AISOC_DEV_AUTH_BYPASS: 1
+ ENVIRONMENT: development
+
+ threatintel:
+ environment:
+ AISOC_DEV_MODE: 1
+ AISOC_DEV_AUTH_BYPASS: 1
+
+ osquery-tls:
+ environment:
+ AISOC_DEV_MODE: 1
+ AISOC_DEV_AUTH_BYPASS: 1
+
+ ueba:
+ environment:
+ AISOC_DEV_MODE: 1
+ AISOC_DEV_AUTH_BYPASS: 1
+
+ honeytokens:
+ environment:
+ AISOC_DEV_MODE: 1
+ AISOC_DEV_AUTH_BYPASS: 1
+
+ purple-team:
+ environment:
+ AISOC_DEV_MODE: 1
+ AISOC_DEV_AUTH_BYPASS: 1
-include:
- - ../../docker-compose.yml
+ slack-bot:
+ environment:
+ AISOC_DEV_MODE: 1
+ AISOC_DEV_AUTH_BYPASS: 1
diff --git a/scripts/check_deployment_auth_posture.py b/scripts/check_deployment_auth_posture.py
new file mode 100644
index 000000000..82a724fdd
--- /dev/null
+++ b/scripts/check_deployment_auth_posture.py
@@ -0,0 +1,557 @@
+#!/usr/bin/env python3
+"""Every documented way to start AiSOC produces a production-class posture.
+
+Why this exists
+---------------
+The API resolves a request with no bearer token to a demo administrator when
+three conditions hold, and the fix for that made two of them explicit. This
+gate answers the remaining question, which is the one that actually bit:
+*what do the documented paths produce?*
+
+They produced the worst answer available. ``ENVIRONMENT`` defaulted to
+``development`` in ``docker-compose.yml`` and in ``.env.example``, which
+``scripts/ensure_env.py`` copies verbatim into ``.env`` on first run, so
+``make up`` and both installers started a stack in a development-class
+environment without anyone choosing one. ``AISOC_DEV_MODE`` defaulted to ``1``
+on ten services. And ``docker-compose.prod.yml``, which sets all of it
+correctly, was selected by nothing: the Makefile never passes ``-f`` and
+neither installer mentions either variable.
+
+So the defect was never in the code that reads these flags. It was that the
+default value of a string decided whether a host was anonymous, and no test
+asked what the default was.
+
+What it checks
+--------------
+Statically, with no Docker, because a gate that needs a daemon does not run in
+the jobs that matter. It resolves ``${VAR:-default}`` against the env file the
+documented path uses, for every service in the compose file, and requires:
+
+* no service resolves a development-class ``ENV`` or ``ENVIRONMENT``;
+* no service resolves a truthy ``AISOC_DEV_MODE``;
+* nothing sets ``AISOC_DEV_AUTH_BYPASS`` outside the dev overlay;
+* every service that reads the bypass is told its published bind addresses,
+ since a service that is never told cannot refuse;
+* and, in the other direction, the dev overlay *does* set all three, so this
+ cannot pass on a tree where the developer path was deleted rather than
+ made explicit.
+
+The last one matters more than it looks. Four of the five rules here are
+satisfied by removing the feature, and a gate that can be satisfied by
+deletion is not measuring what it claims to.
+"""
+
+from __future__ import annotations
+
+import argparse
+import pathlib
+import re
+import sys
+import tempfile
+from dataclasses import dataclass, field
+
+# `scripts/` is on sys.path when this file is run as a program, but not when a
+# test loads it by path with importlib. gate_toolkit sits beside it either way.
+sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
+
+from gate_toolkit import SELF_TEST_FLAG, repo_root, self_test_main # noqa: E402
+
+#: Mirrors ``AUTH_BYPASS_ENVIRONMENTS`` in services/api/app/core/config.py.
+#: Restated rather than imported because this gate runs on a bare interpreter
+#: with no service on the path; `test_deployment_auth_posture.py` asserts the
+#: two agree, so the copy cannot drift silently.
+DEV_ENVIRONMENTS = frozenset({"development", "dev", "local", "demo"})
+
+TRUTHY = frozenset({"1", "true", "yes", "on"})
+
+#: The variable that enables the anonymous shim. Only the dev overlay may set
+#: it, and it must.
+BYPASS_VAR = "AISOC_DEV_AUTH_BYPASS"
+
+#: The variable that tells a service where the deployment published it.
+PUBLISHED_VAR = "AISOC_PUBLISHED_BIND_ADDRS"
+
+#: The compose file every documented path starts from.
+BASE_COMPOSE = "docker-compose.yml"
+
+#: The overlay that turns the developer conveniences back on, deliberately.
+DEV_OVERLAY = "infra/compose/docker-compose.dev.yml"
+
+#: The env file `scripts/ensure_env.py` copies into `.env` on first run.
+ENV_TEMPLATE = ".env.example"
+
+#: Workflows exempt from the "generate the secrets before booting" rule,
+#: with the reason. Only for a job that boots nothing real.
+WORKFLOW_BOOT_EXEMPT: dict[str, str] = {}
+
+#: Files that start the stack for a reader following the documentation.
+#: Each is scanned for an assignment that would put a documented path back
+#: into a development-class environment.
+ENTRY_POINTS = ("Makefile", "install.sh", "install.ps1")
+
+
+@dataclass
+class Finding:
+ where: str
+ detail: str
+
+ def render(self) -> str:
+ return f"{self.where}: {self.detail}"
+
+
+@dataclass
+class Report:
+ findings: list[Finding] = field(default_factory=list)
+ services_scanned: int = 0
+ variables_resolved: int = 0
+
+
+def _env_file_values(text: str) -> dict[str, str]:
+ """The uncommented assignments in a dotenv file."""
+ values: dict[str, str] = {}
+ for line in text.splitlines():
+ stripped = line.strip()
+ if not stripped or stripped.startswith("#") or "=" not in stripped:
+ continue
+ key, _, value = stripped.partition("=")
+ values[key.strip()] = value.strip().strip("\"'")
+ return values
+
+
+_INTERPOLATION = re.compile(r"\$\{([A-Za-z_][A-Za-z0-9_]*)(?::?-((?:[^{}]|\{[^{}]*\})*))?\}")
+
+
+def resolve(expression: str, env: dict[str, str], depth: int = 0) -> str:
+ """What compose would substitute, given ``env``.
+
+ Handles the nested form the console binding uses,
+ ``${AISOC_CONSOLE_BIND_ADDR:-${AISOC_BIND_ADDR:-127.0.0.1}}``, which is
+ why this is a small recursive resolver rather than one regex pass.
+ """
+ if depth > 8:
+ return expression
+
+ def substitute(match: re.Match[str]) -> str:
+ name, default = match.group(1), match.group(2)
+ value = env.get(name, "")
+ if value:
+ return value
+ return resolve(default or "", env, depth + 1)
+
+ return _INTERPOLATION.sub(substitute, expression).strip()
+
+
+def _compose_environments(text: str) -> dict[str, dict[str, str]]:
+ """Each service's ``environment:`` block, as raw (unresolved) strings.
+
+ A hand-rolled scan rather than a YAML parse: this gate has to run on a
+ bare interpreter in jobs that install nothing, and the shape it needs is
+ two levels of indentation under a known key.
+ """
+ services: dict[str, dict[str, str]] = {}
+ current: str | None = None
+ in_services = False
+ in_environment = False
+ for line in text.splitlines():
+ if not line.strip() or line.lstrip().startswith("#"):
+ continue
+ indent = len(line) - len(line.lstrip())
+ if indent == 0:
+ # A top-level key. Only `services:` holds services; counting the
+ # entries under `volumes:` and `networks:` as well reported 45
+ # where the file declares 32, and a gate whose corpus count is
+ # wrong cannot be trusted when it says it scanned enough.
+ in_services = line.strip().rstrip(":") == "services"
+ current = None
+ in_environment = False
+ continue
+ if not in_services:
+ continue
+ if indent == 2 and line.rstrip().endswith(":"):
+ current = line.strip().rstrip(":")
+ services.setdefault(current, {})
+ in_environment = False
+ continue
+ if current is None:
+ continue
+ if indent == 4:
+ in_environment = line.strip() == "environment:"
+ continue
+ if in_environment and indent >= 6 and ":" in line:
+ key, _, value = line.strip().partition(":")
+ services[current][key.strip()] = value.strip()
+ return services
+
+
+def _is_dev_environment(value: str) -> bool:
+ return value.strip().lower() in DEV_ENVIRONMENTS
+
+
+def _is_truthy(value: str) -> bool:
+ return value.strip().lower() in TRUTHY
+
+
+def inspect(root: pathlib.Path) -> Report:
+ report = Report()
+ compose_path = root / BASE_COMPOSE
+ if not compose_path.is_file():
+ return report
+
+ compose = compose_path.read_text(encoding="utf-8", errors="replace")
+ template = root / ENV_TEMPLATE
+ env = _env_file_values(template.read_text(encoding="utf-8", errors="replace")) if template.is_file() else {}
+
+ services = _compose_environments(compose)
+ report.services_scanned = len(services)
+
+ for service, variables in sorted(services.items()):
+ for key in ("ENV", "ENVIRONMENT"):
+ if key not in variables:
+ continue
+ report.variables_resolved += 1
+ value = resolve(variables[key], env)
+ if _is_dev_environment(value):
+ report.findings.append(
+ Finding(
+ f"{BASE_COMPOSE} :: {service}",
+ f"{key} resolves to {value!r} with {ENV_TEMPLATE} as the env file, "
+ "which permits the anonymous auth shim. Default it to 'production' "
+ f"and put the development value in {DEV_OVERLAY}.",
+ )
+ )
+
+ if "AISOC_DEV_MODE" in variables:
+ report.variables_resolved += 1
+ value = resolve(variables["AISOC_DEV_MODE"], env)
+ if _is_truthy(value):
+ report.findings.append(
+ Finding(
+ f"{BASE_COMPOSE} :: {service}",
+ f"AISOC_DEV_MODE resolves to {value!r}. It selects several unrelated "
+ "development behaviours and must not be on by default.",
+ )
+ )
+
+ if BYPASS_VAR in variables:
+ report.variables_resolved += 1
+ value = resolve(variables[BYPASS_VAR], env)
+ if _is_truthy(value):
+ report.findings.append(
+ Finding(
+ f"{BASE_COMPOSE} :: {service}",
+ f"{BYPASS_VAR} resolves to {value!r}. Only {DEV_OVERLAY} may set it.",
+ )
+ )
+
+ # A service that reads the bypass has to know whether anyone else can
+ # reach it. It binds 0.0.0.0 inside its container, so it cannot work
+ # that out alone, and one that is never told cannot refuse.
+ reads_bypass = "AISOC_DEV_MODE" in variables or "ENVIRONMENT" in variables or "ENV" in variables
+ if reads_bypass and PUBLISHED_VAR not in variables:
+ report.findings.append(
+ Finding(
+ f"{BASE_COMPOSE} :: {service}",
+ f"reads the auth-bypass flags but is not given {PUBLISHED_VAR}, so it cannot refuse the bypass on a published address.",
+ )
+ )
+
+ for name in ENTRY_POINTS:
+ path = root / name
+ if not path.is_file():
+ continue
+ text = path.read_text(encoding="utf-8", errors="replace")
+ for match in re.finditer(
+ r"^[^#\n]*?\b(?:export\s+|\$env:)?(ENV|ENVIRONMENT|AISOC_DEV_MODE|AISOC_DEV_AUTH_BYPASS)\s*=\s*[\"']?([A-Za-z0-9_]+)",
+ text,
+ re.M,
+ ):
+ key, value = match.group(1), match.group(2)
+ report.variables_resolved += 1
+ bad = _is_dev_environment(value) if key in ("ENV", "ENVIRONMENT") else _is_truthy(value)
+ if bad:
+ line = text[: match.start()].count("\n") + 1
+ report.findings.append(
+ Finding(
+ f"{name}:{line}",
+ f"sets {key}={value}, which puts a documented path into a development-class posture.",
+ )
+ )
+
+ # A workflow that boots the stack without generating secrets provisions an
+ # environment no real deployment has. With ENVIRONMENT defaulting to
+ # production, ingest refuses to start without JWT_SECRET and the API
+ # refuses without METRICS_TOKEN — which is the services being right, and
+ # exactly why a copied `.env.example` is no longer enough.
+ workflows = root / ".github" / "workflows"
+ if workflows.is_dir():
+ for path in sorted(workflows.glob("*.yml")):
+ text = path.read_text(encoding="utf-8", errors="replace")
+ # Only a real invocation counts; the phrase appears in prose too.
+ boots = any(
+ line.strip().startswith(("docker compose", "- run: docker compose", "$(COMPOSE)"))
+ and " up" in line
+ and not line.lstrip().startswith("#")
+ for line in text.splitlines()
+ )
+ if not boots:
+ continue
+ report.variables_resolved += 1
+ if "ensure_env.py" in text or "make env" in text or "make up" in text:
+ continue
+ if path.name in WORKFLOW_BOOT_EXEMPT:
+ continue
+ report.findings.append(
+ Finding(
+ f".github/workflows/{path.name}",
+ "boots the stack but never runs scripts/ensure_env.py, so it provisions "
+ "an environment with every generated secret empty. ingest refuses to "
+ "start without JWT_SECRET and the API without METRICS_TOKEN.",
+ )
+ )
+
+ overlay = root / DEV_OVERLAY
+ if not overlay.is_file():
+ report.findings.append(
+ Finding(
+ DEV_OVERLAY,
+ "the developer overlay is missing. Four of the five rules here are "
+ "satisfied by deleting the developer path rather than making it "
+ "explicit, so its absence is a finding.",
+ )
+ )
+ else:
+ text = overlay.read_text(encoding="utf-8", errors="replace")
+ for required, predicate, description in (
+ ("ENVIRONMENT", _is_dev_environment, "a development-class environment"),
+ ("AISOC_DEV_MODE", _is_truthy, "AISOC_DEV_MODE on"),
+ (BYPASS_VAR, _is_truthy, f"{BYPASS_VAR} on"),
+ ):
+ found = re.search(rf"^\s*{required}\s*:\s*[\"']?([^\"'\s#]+)", text, re.M)
+ report.variables_resolved += 1
+ if found is None or not predicate(found.group(1)):
+ report.findings.append(
+ Finding(
+ DEV_OVERLAY,
+ f"does not set {description}. The overlay is what makes the "
+ "developer experience deliberate instead of default; without it "
+ "this gate would pass on a tree where the shim was simply removed.",
+ )
+ )
+
+ return report
+
+
+def _verdict(report: Report) -> int:
+ if report.services_scanned == 0:
+ print(
+ f"check_deployment_auth_posture: no services found in {BASE_COMPOSE} — refusing to report a tree with nothing in it as clean",
+ file=sys.stderr,
+ )
+ return 2
+ if report.variables_resolved == 0:
+ print(
+ "check_deployment_auth_posture: scanned "
+ f"{report.services_scanned} service(s) and resolved no auth-posture variable at "
+ "all. Either the compose file stopped declaring them or the scanner broke; "
+ "both need a human.",
+ file=sys.stderr,
+ )
+ return 2
+
+ if report.findings:
+ print(
+ f"check_deployment_auth_posture: {len(report.findings)} documented path(s) produce a development-class posture:",
+ file=sys.stderr,
+ )
+ for finding in report.findings:
+ print(f" {finding.render()}", file=sys.stderr)
+ return 1
+
+ print(
+ f"check_deployment_auth_posture: OK — {report.variables_resolved} variable(s) across "
+ f"{report.services_scanned} service(s); every documented path is production-class and "
+ f"{DEV_OVERLAY} turns the developer conveniences back on deliberately."
+ )
+ return 0
+
+
+# ── Self-test ───────────────────────────────────────────────────────────────
+
+
+@dataclass(frozen=True)
+class Case:
+ description: str
+ compose: str
+ env_example: str = "ENVIRONMENT=production\n"
+ overlay: str | None = None
+ makefile: str = "up:\n\tdocker compose up -d\n"
+ workflow: str | None = None
+ expect: str | None = None
+
+
+_GOOD_OVERLAY = f"services:\n api:\n environment:\n ENVIRONMENT: development\n AISOC_DEV_MODE: 1\n {BYPASS_VAR}: 1\n"
+
+_GOOD_COMPOSE = (
+ "services:\n"
+ " api:\n"
+ " environment:\n"
+ " ENVIRONMENT: ${ENVIRONMENT:-production}\n"
+ f" {PUBLISHED_VAR}: ${{AISOC_BIND_ADDR:-127.0.0.1}}\n"
+)
+
+
+def self_test_cases() -> tuple[Case, ...]:
+ return (
+ Case(
+ "the shipped default: ENVIRONMENT falls through to development",
+ f"services:\n api:\n environment:\n ENVIRONMENT: ${{ENVIRONMENT:-development}}\n {PUBLISHED_VAR}: 127.0.0.1\n",
+ # No ENVIRONMENT in the env file, so the compose fallback is what
+ # the service sees. That is the case this rule is about, and an
+ # earlier draft of it set the variable here, which made the
+ # fallback unreachable and the case vacuous.
+ env_example="POSTGRES_PASSWORD=x\n",
+ overlay=_GOOD_OVERLAY,
+ expect="resolves to 'development'",
+ ),
+ Case(
+ "the env template supplying the development value, with a safe compose default",
+ f"services:\n api:\n environment:\n ENVIRONMENT: ${{ENVIRONMENT:-production}}\n {PUBLISHED_VAR}: 127.0.0.1\n",
+ env_example="ENVIRONMENT=development\n",
+ overlay=_GOOD_OVERLAY,
+ expect="resolves to 'development'",
+ ),
+ Case(
+ "AISOC_DEV_MODE defaulting to 1",
+ f"services:\n fusion:\n environment:\n AISOC_DEV_MODE: ${{AISOC_DEV_MODE:-1}}\n {PUBLISHED_VAR}: 127.0.0.1\n",
+ overlay=_GOOD_OVERLAY,
+ expect="AISOC_DEV_MODE resolves to '1'",
+ ),
+ Case(
+ "the bypass flag set in the base compose file rather than the overlay",
+ "services:\n api:\n environment:\n ENVIRONMENT: production\n"
+ f" {BYPASS_VAR}: 1\n {PUBLISHED_VAR}: 127.0.0.1\n",
+ overlay=_GOOD_OVERLAY,
+ expect=f"{BYPASS_VAR} resolves to '1'",
+ ),
+ Case(
+ "a service that reads the flags but is never told where it is published",
+ "services:\n api:\n environment:\n ENVIRONMENT: ${ENVIRONMENT:-production}\n",
+ overlay=_GOOD_OVERLAY,
+ expect=f"not given {PUBLISHED_VAR}",
+ ),
+ Case(
+ "an installer exporting a development environment",
+ _GOOD_COMPOSE,
+ overlay=_GOOD_OVERLAY,
+ makefile="up:\n\texport ENVIRONMENT=development\n\tdocker compose up -d\n",
+ expect="puts a documented path into a development-class posture",
+ ),
+ Case(
+ "the developer overlay deleted rather than made explicit",
+ _GOOD_COMPOSE,
+ overlay=None,
+ expect="the developer overlay is missing",
+ ),
+ Case(
+ "an overlay that no longer turns the bypass on",
+ _GOOD_COMPOSE,
+ overlay="services:\n api:\n environment:\n ENVIRONMENT: development\n AISOC_DEV_MODE: 1\n",
+ expect=f"does not set {BYPASS_VAR} on",
+ ),
+ # ── and the direction it must not fire in ───────────────────────────
+ Case(
+ "a production-class default with a deliberate developer overlay",
+ _GOOD_COMPOSE,
+ overlay=_GOOD_OVERLAY,
+ expect=None,
+ ),
+ Case(
+ "the nested console binding, which a single regex pass cannot resolve",
+ "services:\n api:\n environment:\n ENVIRONMENT: ${ENVIRONMENT:-production}\n"
+ f" {PUBLISHED_VAR}: ${{AISOC_CONSOLE_BIND_ADDR:-${{AISOC_BIND_ADDR:-127.0.0.1}}}}\n",
+ overlay=_GOOD_OVERLAY,
+ expect=None,
+ ),
+ Case(
+ "a workflow that boots the stack without generating the secrets",
+ _GOOD_COMPOSE,
+ overlay=_GOOD_OVERLAY,
+ workflow="jobs:\n smoke:\n steps:\n - run: cp .env.example .env\n - run: docker compose up -d\n",
+ expect="never runs scripts/ensure_env.py",
+ ),
+ Case(
+ "the same workflow, generating them",
+ _GOOD_COMPOSE,
+ overlay=_GOOD_OVERLAY,
+ workflow="jobs:\n smoke:\n steps:\n - run: python3 scripts/ensure_env.py\n - run: docker compose up -d\n",
+ expect=None,
+ ),
+ Case(
+ "a workflow that only mentions the command in prose",
+ _GOOD_COMPOSE,
+ overlay=_GOOD_OVERLAY,
+ workflow="# what `docker compose up -d` pulls for the console\njobs:\n build:\n steps:\n - run: echo hi\n",
+ expect=None,
+ ),
+ Case(
+ "a comment mentioning ENVIRONMENT=development in an entry point",
+ _GOOD_COMPOSE,
+ overlay=_GOOD_OVERLAY,
+ makefile="up:\n\t# ENVIRONMENT=development is the overlay's job\n\tdocker compose up -d\n",
+ expect=None,
+ ),
+ )
+
+
+def _case_results(tmp: pathlib.Path) -> list[tuple[str, bool]]:
+ results: list[tuple[str, bool]] = []
+ for index, case in enumerate(self_test_cases()):
+ tree = tmp / f"case{index}"
+ (tree / "infra" / "compose").mkdir(parents=True)
+ (tree / BASE_COMPOSE).write_text(case.compose, encoding="utf-8")
+ (tree / ENV_TEMPLATE).write_text(case.env_example, encoding="utf-8")
+ (tree / "Makefile").write_text(case.makefile, encoding="utf-8")
+ if case.overlay is not None:
+ (tree / DEV_OVERLAY).write_text(case.overlay, encoding="utf-8")
+ if case.workflow is not None:
+ (tree / ".github" / "workflows").mkdir(parents=True, exist_ok=True)
+ (tree / ".github" / "workflows" / "probe.yml").write_text(case.workflow, encoding="utf-8")
+ report = inspect(tree)
+ blob = " | ".join(f.render() for f in report.findings)
+ if case.expect is None:
+ passed = not report.findings
+ detail = f"expected nothing, got: {blob}" if not passed else ""
+ else:
+ passed = case.expect in blob
+ detail = f"expected {case.expect!r}, got: {blob or '(nothing)'}" if not passed else ""
+ results.append((f"{case.description}{f' — {detail}' if detail else ''}", passed))
+ return results
+
+
+def _corpus_result(root: pathlib.Path) -> tuple[str, bool]:
+ report = inspect(root)
+ return (
+ f"counts what it scanned ({report.variables_resolved} variables across {report.services_scanned} services)",
+ report.services_scanned > 0 and report.variables_resolved > 0,
+ )
+
+
+def self_test() -> int:
+ with tempfile.TemporaryDirectory(prefix="aisoc-posture-") as tmp:
+ extra = _case_results(pathlib.Path(tmp))
+ extra.append(_corpus_result(repo_root()))
+ return self_test_main(pathlib.Path(__file__).name, ["--check"], extra)
+
+
+def main() -> int:
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument("--check", action="store_true", help="render a verdict (default)")
+ parser.add_argument(SELF_TEST_FLAG, action="store_true", dest="self_test")
+ args = parser.parse_args()
+ if args.self_test:
+ return self_test()
+ return _verdict(inspect(repo_root()))
+
+
+if __name__ == "__main__":
+ raise SystemExit(main())
diff --git a/scripts/ensure_env.py b/scripts/ensure_env.py
index 7fe0448bc..0174122d7 100644
--- a/scripts/ensure_env.py
+++ b/scripts/ensure_env.py
@@ -147,6 +147,20 @@ GENERATED: dict[str, tuple[Callable[[], str], str]] = {
lambda: secrets.token_urlsafe(32),
"Bearer for slack-bot's /internal/approval-card (agents -> slack-bot). Sent as X-AiSOC-Internal-Token.",
),
+ # The two `enforce_secure_defaults` refuses to boot without once
+ # ENVIRONMENT is production, which it now is by default. Neither was
+ # generated while `development` was the default, because in a
+ # development-class environment the check only warns. So flipping the
+ # default without adding these would have turned "anonymous admin" into
+ # "the API will not start", which is a worse first run and not a fix.
+ "METRICS_TOKEN": (
+ lambda: secrets.token_urlsafe(32),
+ "Bearer for /metrics. Prometheus sends it; without it the endpoint is unauthenticated.",
+ ),
+ "JWT_SECRET": (
+ lambda: secrets.token_urlsafe(32),
+ "HS256 key for the session tokens the SAML and OIDC callbacks issue.",
+ ),
# The datastore passwords. `.env.example` shipped these as
# `aisoc_dev_secret` / `aisoc_app_dev_secret` / `redis_dev_secret` /
# `clickhouse_dev_secret`, and `docker-compose.prod.yml` guarded each one
diff --git a/scripts/integration/spine_test.py b/scripts/integration/spine_test.py
index b8f425ff6..6b47d8fa5 100644
--- a/scripts/integration/spine_test.py
+++ b/scripts/integration/spine_test.py
@@ -65,6 +65,19 @@ def log(msg: str) -> None:
print(f"[{time.strftime('%H:%M:%S')}] {msg}", flush=True)
+#: The bearer the API reads and the realtime ticket need. These calls used
+#: to carry no credential at all and succeeded, because an uncredentialed
+#: request resolved to a demo administrator and every documented path
+#: produced one. Minted by `app.scripts.mint_api_token`; the workflow sets it.
+API_TOKEN = os.environ.get("AISOC_API_TOKEN", "").strip()
+
+
+def api_headers() -> dict[str, str]:
+ """Headers for a call to the API. Empty when no token was supplied, so a
+ 401 names the missing variable rather than looking like an outage."""
+ return {"Authorization": f"Bearer {API_TOKEN}"} if API_TOKEN else {}
+
+
def ingest_headers() -> dict[str, str]:
"""Credential plus the tenant the credential is expected to cover.
@@ -180,14 +193,14 @@ async def post_detection_event(client: httpx.AsyncClient) -> None:
async def count_alerts_titled(client: httpx.AsyncClient, title: str) -> int:
- r = await client.get(f"{API}/api/v1/alerts", params={"page_size": 200}, timeout=10)
+ r = await client.get(f"{API}/api/v1/alerts", params={"page_size": 200}, headers=api_headers(), timeout=10)
r.raise_for_status()
items = r.json().get("items", [])
return sum(1 for a in items if a.get("title") == title)
async def get_alert_titled(client: httpx.AsyncClient, title: str) -> dict | None:
- r = await client.get(f"{API}/api/v1/alerts", params={"page_size": 200}, timeout=10)
+ r = await client.get(f"{API}/api/v1/alerts", params={"page_size": 200}, headers=api_headers(), timeout=10)
r.raise_for_status()
for a in r.json().get("items", []):
if a.get("title") == title:
@@ -196,7 +209,7 @@ async def get_alert_titled(client: httpx.AsyncClient, title: str) -> dict | None
async def mint_ws_ticket(client: httpx.AsyncClient) -> str:
- r = await client.post(f"{API}/api/v1/realtime/ticket", timeout=10)
+ r = await client.post(f"{API}/api/v1/realtime/ticket", headers=api_headers(), timeout=10)
r.raise_for_status()
return r.json()["token"]
diff --git a/tests/test_compose_environment_gate.py b/tests/test_compose_environment_gate.py
index 0553fb979..93adcbf5d 100644
--- a/tests/test_compose_environment_gate.py
+++ b/tests/test_compose_environment_gate.py
@@ -70,14 +70,34 @@ class TestTheDocumentedSwitchReachesEveryService:
f"these services hardcode a dev-class environment, so `ENVIRONMENT=production` in .env does not reach them: {offenders}"
)
+ #: The one file whose job is to be development, so the one file allowed
+ #: to pin it. Everything else must interpolate, or an operator's
+ #: `ENVIRONMENT=production` does not reach the service.
+ DEV_OVERLAY_NAME = "docker-compose.dev.yml"
+
@pytest.mark.parametrize("path", COMPOSE_FILES, ids=lambda p: p.name)
def test_no_tracked_compose_file_pins_one(self, path: pathlib.Path) -> None:
- """The dev overlay is allowed to *be* development — by interpolation.
+ """Every compose file except the developer overlay interpolates.
Included because the next service to hardcode one is as likely to land
- in the overlay as in the root file, and a gate that reads one file is
+ in an overlay as in the root file, and a gate that reads one file is
the shape that let this through.
+
+ The developer overlay is exempt, and pins the literal deliberately.
+ This assertion used to exempt it on the grounds that it interpolated
+ too, which was true only because the file was a fifteen-line `include`
+ alias that set nothing at all. Now that it carries the switch, an
+ interpolated value there would let a stray `ENVIRONMENT=production` in
+ `.env` silently defeat the overlay an operator passed on purpose.
"""
+ if path.name == self.DEV_OVERLAY_NAME:
+ offenders = _literal_dev_envs(path)
+ assert offenders, (
+ f"{path.name} is the developer overlay and no longer pins a dev-class "
+ "environment, so `make up-dev` would produce the same posture as `make up` "
+ "and this suite would still be green"
+ )
+ return
assert not _literal_dev_envs(path)
def test_the_gate_detects_the_literal_it_was_written_for(self, tmp_path: pathlib.Path) -> None:
diff --git a/tests/test_production_compose_gate.py b/tests/test_production_compose_gate.py
index 8d5cba81b..939e60526 100644
--- a/tests/test_production_compose_gate.py
+++ b/tests/test_production_compose_gate.py
@@ -181,12 +181,19 @@ class TestTheBypassIsUnreachable:
def test_no_service_runs_in_a_dev_class_environment(self, prod: dict) -> None:
assert not _dev_environments(prod)
- def test_the_development_file_would_fail_this(self) -> None:
- """The contrast is the point: this is what production differs from."""
- assert _dev_environments(_services(DEV)), (
- "docker-compose.yml no longer resolves to a dev-class environment with an empty "
- ".env, so this gate is comparing production against nothing and proves less than "
- "it claims"
+ def test_the_developer_overlay_would_fail_this(self) -> None:
+ """The contrast is the point: this is what production differs from.
+
+ It used to compare against `docker-compose.yml`, because that file
+ resolved to a dev-class environment with an empty `.env` — which was
+ the defect, not a baseline. The base is production now, so comparing
+ against it would prove nothing, and this test said so itself rather
+ than passing vacuously. The developer overlay is the honest contrast.
+ """
+ overlay = REPO / "infra" / "compose" / "docker-compose.dev.yml"
+ assert _dev_environments(_services(overlay)), (
+ f"{overlay.name} no longer resolves to a dev-class environment, so this gate is "
+ "comparing production against nothing and proves less than it claims"
)
def test_environment_and_dev_mode_are_literals_not_variables(self, prod: dict) -> None: