Skip to content

armgit / AiSOC

Public Imported from GitHub
0

Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.

fix(ci): an image must merge only its own per-architecture digests (#890)

Beenu Arora88d6337ed0b2
diff --git a/.github/workflows/publish-images.yml b/.github/workflows/publish-images.yml
index aab335b07..3a0f04d69 100644
--- a/.github/workflows/publish-images.yml
+++ b/.github/workflows/publish-images.yml
@@ -266,7 +266,7 @@ jobs:
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
- name: digest-${{ matrix.service }}-${{ matrix.platform }}
+ name: digest.${{ matrix.service }}.${{ matrix.platform }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
@@ -339,8 +339,14 @@ jobs:
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
+ # Dot-separated, not hyphen-separated: `digest-web-*` also matches
+ # `digest-web-demo-amd64`, so the console's manifest job downloaded
+ # four digests — two of them the demo bundle — and would have pushed
+ # a mixed manifest as `:latest`. The count check below caught it; the
+ # separator is what stops it happening. `digest.web.*` cannot match
+ # `digest.web-demo.amd64`.
path: /tmp/digests
- pattern: digest-${{ matrix.service }}-*
+ pattern: digest.${{ matrix.service }}.*
merge-multiple: true
- uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 283ae2af1..69fe891e6 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -390,7 +390,7 @@ jobs:
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
- name: digest-${{ matrix.service }}-${{ matrix.platform }}
+ name: digest.${{ matrix.service }}.${{ matrix.platform }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
@@ -458,8 +458,14 @@ jobs:
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
+ # Dot-separated, not hyphen-separated: `digest-web-*` also matches
+ # `digest-web-demo-amd64`, so the console's manifest job downloaded
+ # four digests — two of them the demo bundle — and would have pushed
+ # a mixed manifest as `:latest`. The count check below caught it; the
+ # separator is what stops it happening. `digest.web.*` cannot match
+ # `digest.web-demo.amd64`.
path: /tmp/digests
- pattern: digest-${{ matrix.service }}-*
+ pattern: digest.${{ matrix.service }}.*
merge-multiple: true
- uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 34e361ecb..8580c3d3e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -117,6 +117,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
an existing tag, because the only way to finish a half-published release was
previously to invent a new tag for a commit that had already shipped.
+- **The console's manifest job collected the demo build's digests as well as
+ its own.** `web` and `web-demo` push to the same repository and the digest
+ artefacts were keyed `digest-<service>-<platform>`, downloaded with a
+ `digest-<service>-*` pattern — so `digest-web-*` also matched
+ `digest-web-demo-amd64`, and the console's merge job pulled four digests,
+ two of them the demo bundle. It failed on the merge step's own check that it
+ had exactly one digest per architecture, which is the only reason a mixed
+ manifest did not go out under the tag `make up` pulls. The separator is now
+ a dot, which cannot collide, and `test_one_image_cannot_collect_another_images_digests`
+ replays each service's download pattern against every service's upload name
+ so the ambiguity is caught at review rather than at publish.
+
- **`aisoc-honeytokens`, `aisoc-purple-team` and `aisoc-osquery-tls` are
published.** All three were named by `docker-compose.yml` since it was
written and built by nothing, so `--profile extras` silently compiled them
diff --git a/tests/test_first_run_gate.py b/tests/test_first_run_gate.py
index fe4c80806..1d87bfc4c 100644
--- a/tests/test_first_run_gate.py
+++ b/tests/test_first_run_gate.py
@@ -21,6 +21,7 @@ behavioural coverage is in `services/api/tests/test_bootstrap_admin.py`.
from __future__ import annotations
+import fnmatch
import pathlib
import re
@@ -208,6 +209,51 @@ def test_the_demo_bundle_is_built_by_its_own_matrix_entry(workflow: pathlib.Path
)
+ "workflow",
+ [PUBLISH_WORKFLOW, RELEASE_WORKFLOW],
+ ids=["publish-images", "release"],
+)
+def test_one_image_cannot_collect_another_images_digests(workflow: pathlib.Path) -> None:
+ """The per-architecture digest an image merges must be its own.
+
+ `web` and `web-demo` push to the same repository and differ only in the
+ bundle they contain, and the upload/download pair keyed them
+ `digest-<service>-<platform>` with a `digest-<service>-*` pattern. So the
+ console's merge job collected four digests — two of them the demo build —
+ and would have published a mixed manifest under the tag `make up` pulls.
+ The merge step's count check caught it, but only after both builds had run.
+
+ This is the same question one step earlier: replay each service's download
+ pattern against every service's upload name and require exactly its own.
+ """
+ build = _build_job(workflow)[1]
+ merge = next(
+ job
+ for job in yaml.safe_load(workflow.read_text())["jobs"].values()
+ if any("download-artifact" in str(step.get("uses", "")) for step in job.get("steps", []))
+ )
+ services = [e["service"] for e in build["strategy"]["matrix"]["include"]]
+ platforms = build["strategy"]["matrix"]["platform"]
+
+ upload = next(s for s in build["steps"] if "upload-artifact" in str(s.get("uses", "")))
+ download = next(s for s in merge["steps"] if "download-artifact" in str(s.get("uses", "")))
+ name_template = upload["with"]["name"]
+ pattern_template = download["with"]["pattern"]
+
+ def rendered(template: str, service: str, platform: str = "") -> str:
+ return template.replace("${{ matrix.service }}", service).replace("${{ matrix.platform }}", platform).strip()
+
+ uploaded = {rendered(name_template, s, p): (s, p) for s in services for p in platforms}
+ for service in services:
+ pattern = rendered(pattern_template, service)
+ matched = {uploaded[name] for name in uploaded if fnmatch.fnmatch(name, pattern)}
+ assert matched == {(service, p) for p in platforms}, (
+ f"{workflow.name}: the pattern {pattern!r} for {service!r} collects "
+ f"{sorted(matched)}. An image must merge only its own architectures."
+ )
+
+
def test_publish_images_keeps_demo_off_the_moving_tags() -> None:
text = PUBLISH_WORKFLOW.read_text()
for tag in ("value=main", "value=latest"):