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(release): the image stable-channel guard fails open when its registry read breaks (#1478)

Beenu Arorab079731462d9
diff --git a/.github/workflows/image-channel.yml b/.github/workflows/image-channel.yml
new file mode 100644
index 000000000..19e6863e8
--- /dev/null
+++ b/.github/workflows/image-channel.yml
@@ -0,0 +1,116 @@
+# Move the image `stable` channel to a named, already-published release.
+#
+# The image half of chart-channel.yml, and built for the same reason one
+# release later: when the release guard's registry read broke (the buildx
+# template stopped resolving on the runner image), two consecutive publishes
+# carried image `stable` across the v19 -> v20 application major — and there
+# was no way to repair the position short of waiting for the next release,
+# which would not have repaired it either. Dispatching this workflow IS the
+# operator decision the guard protects: it re-points every image's `stable`
+# tag at the named version's manifest, byte-identical, in either direction,
+# and says what it did per image.
+#
+# It never republishes a version tag — `vX.Y.Z` is immutable by convention
+# and an overwritten version is unrecoverable — it only moves the mutable
+# channel tag, the same way release.yml promotes on an ordinary release.
+name: Image channel
+
+on:
+ workflow_dispatch:
+ inputs:
+ version:
+ description: 'Published release whose images `stable` should point at (e.g. v19.0.0). Every image must already carry the tag.'
+ required: true
+ type: string
+
+permissions:
+ contents: read
+ packages: write
+
+jobs:
+ move:
+ name: Point every image's `stable` at ${{ inputs.version }}
+ runs-on: ubuntu-latest
+ timeout-minutes: 10
+ steps:
+ - name: Retag `stable`, byte-identical, with before/after evidence
+ env:
+ VERSION: ${{ inputs.version }}
+ GH_TOKEN: ${{ github.token }}
+ run: |
+ set -uo pipefail
+ MEDIA="application/vnd.oci.image.index.v1+json, application/vnd.docker.distribution.manifest.list.v2+json, application/vnd.oci.image.manifest.v1+json, application/vnd.docker.distribution.manifest.v2+json"
+ # The same first-party, non-demo list release.yml publishes. The
+ # demo console is deliberately absent: it never carries a channel.
+ IMAGES="aisoc-core-api aisoc-agents aisoc-realtime aisoc-web aisoc-ingest aisoc-enrichment aisoc-fusion aisoc-actions aisoc-connectors aisoc-threatintel aisoc-ueba aisoc-slack-bot aisoc-teams-bot aisoc-honeytokens aisoc-purple-team aisoc-osquery-tls"
+
+ # image tag -> "digest version-label", via manifest + config blob.
+ describe() {
+ local repo="$1" tag="$2" tok="$3" code digest config version
+ code=$(curl -s -o /tmp/m.json -w '%{http_code}' \
+ -H "Authorization: Bearer ${tok}" -H "Accept: ${MEDIA}" \
+ "https://ghcr.io/v2/beenuar/${repo}/manifests/${tag}" || echo 000)
+ [ "$code" = "200" ] || { echo "(absent: HTTP ${code})"; return 0; }
+ digest=$(python3 -c '
+ import json
+ m = json.load(open("/tmp/m.json"))
+ if "manifests" in m:
+ plats = [x["digest"] for x in m["manifests"] if x.get("platform",{}).get("architecture") in ("amd64","arm64")]
+ print(plats[0] if plats else "")
+ else:
+ print("self")')
+ if [ "$digest" = "self" ]; then
+ cp /tmp/m.json /tmp/mi.json
+ else
+ curl -fsS -H "Authorization: Bearer ${tok}" -H "Accept: ${MEDIA}" \
+ "https://ghcr.io/v2/beenuar/${repo}/manifests/${digest}" > /tmp/mi.json
+ fi
+ config=$(python3 -c 'import json; print(json.load(open("/tmp/mi.json"))["config"]["digest"])')
+ version=$(curl -fsSL -H "Authorization: Bearer ${tok}" \
+ "https://ghcr.io/v2/beenuar/${repo}/blobs/${config}" \
+ | python3 -c 'import json,sys; c=json.load(sys.stdin); print((c.get("config",{}).get("Labels") or {}).get("org.opencontainers.image.version","(no label)"))')
+ echo "${version}"
+ }
+
+ failures=0
+ for repo in $IMAGES; do
+ tok=$(curl -fsS -u "x:${GH_TOKEN}" \
+ "https://ghcr.io/token?scope=repository:beenuar/${repo}:pull,push&service=ghcr.io" \
+ | python3 -c 'import json,sys; print(json.load(sys.stdin)["token"])')
+
+ before=$(describe "$repo" stable "$tok")
+
+ # The target must exist; a channel pointed at nothing is worse
+ # than a channel in the wrong place.
+ tmp_target=$(mktemp)
+ read -r code ctype < <(curl -s -o "$tmp_target" \
+ -w '%{http_code} %{content_type}' \
+ -H "Authorization: Bearer ${tok}" -H "Accept: ${MEDIA}" \
+ "https://ghcr.io/v2/beenuar/${repo}/manifests/${VERSION}")
+ if [ "$code" != "200" ]; then
+ echo "::error::${repo}: ${VERSION} answered HTTP ${code}; stable left at '${before}'"
+ failures=$((failures + 1))
+ continue
+ fi
+
+ put_code=$(curl -s -o /tmp/put-answer.json -w '%{http_code}' -X PUT \
+ -H "Authorization: Bearer ${tok}" -H "Content-Type: ${ctype}" \
+ --data-binary @"$tmp_target" \
+ "https://ghcr.io/v2/beenuar/${repo}/manifests/stable")
+ if [ "$put_code" != "201" ]; then
+ echo "::error::${repo}: PUT stable answered HTTP ${put_code}; stable left at '${before}'"
+ cat /tmp/put-answer.json || true
+ failures=$((failures + 1))
+ continue
+ fi
+
+ after=$(describe "$repo" stable "$tok")
+ echo "${repo}: stable '${before}' -> '${after}'"
+ echo "${repo}: stable \`${before}\` -> \`${after}\`" >> "$GITHUB_STEP_SUMMARY"
+ if [ "$after" != "$VERSION" ]; then
+ echo "::error::${repo}: stable reads '${after}' after the move, expected '${VERSION}'"
+ failures=$((failures + 1))
+ fi
+ done
+
+ [ "$failures" -eq 0 ] || { echo "::error::${failures} image(s) failed to move"; exit 1; }
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 7666604b2..dbfe9e38e 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -663,34 +663,92 @@ jobs:
# Resolved per image because a republish or a half-release can leave one
# image's channel behind the others, and each must be judged on its own.
#
- # A miss is not a failure. No `stable` tag yet is the ordinary state of a
- # first release and must leave the value empty so the channel is taken;
- # a registry hiccup is reported and also leaves it empty, which is the
- # safe direction -- the worst case is `stable` advancing within the major
- # it is already on.
+ # Read through the registry HTTP API — manifest, then config blob —
+ # exactly as the chart half below already does, NEVER through a
+ # `docker buildx imagetools inspect` template. The template's shape is
+ # a property of whatever buildx the runner image ships that day, and
+ # when it broke (`.Image` stopped resolving on multi-arch indexes) the
+ # old read returned empty with stderr discarded, "empty" read as
+ # "first release", and the v20.0.0 and v20.1.0 publishes each carried
+ # `stable` across the v19 -> v20 boundary the guard exists to refuse —
+ # silently, under a green run.
+ #
+ # Three states, not two. A **404** is the ordinary first-release state:
+ # the channel may be taken. A tag that is **present but unreadable** —
+ # a non-404 registry answer, or a manifest whose version label cannot
+ # be resolved — BLOCKS the channel for this release: refusing is
+ # recoverable (the next release or a deliberate promotion moves it),
+ # a wrong crossing is not. That is the same fail-closed reasoning the
+ # chart guard already documents, applied to the read as well as the
+ # decision.
- id: stable-major
env:
IMAGE: ${{ matrix.image }}
IS_DEMO: ${{ matrix.demo }}
+ GH_TOKEN: ${{ github.token }}
run: |
set -uo pipefail
+ MEDIA="application/vnd.oci.image.index.v1+json, application/vnd.docker.distribution.manifest.list.v2+json, application/vnd.oci.image.manifest.v1+json, application/vnd.docker.distribution.manifest.v2+json"
+ repo="${IMAGE#ghcr.io/}"
major=""
+ blocked="false"
if [ "${IS_DEMO}" != "true" ]; then
- current=$(docker buildx imagetools inspect "${IMAGE}:stable" \
- --format '{{ index .Image.Config.Labels "org.opencontainers.image.version" }}' \
- 2>/dev/null || true)
- case "${current}" in
- v[0-9]*|[0-9]*)
- major="${current#v}"
- major="${major%%.*}"
- ;;
- *)
- echo "::notice::no resolvable \`stable\` tag for ${IMAGE} (got '${current}'); treating as a first release"
- ;;
- esac
+ reg_token=$(curl -fsS -u "x:${GH_TOKEN}" \
+ "https://ghcr.io/token?scope=repository:${repo}:pull&service=ghcr.io" \
+ | python3 -c 'import json,sys; print(json.load(sys.stdin)["token"])' || true)
+ code=$(curl -s -o /tmp/stable-manifest.json -w '%{http_code}' \
+ -H "Authorization: Bearer ${reg_token}" -H "Accept: ${MEDIA}" \
+ "https://ghcr.io/v2/${repo}/manifests/stable" || echo "000")
+ if [ "$code" = "404" ]; then
+ echo "::notice::no \`stable\` tag for ${IMAGE} (404); treating as a first release"
+ elif [ "$code" = "200" ]; then
+ # index -> a platform manifest -> config blob -> version label.
+ digest=$(python3 -c '
+ import json,sys
+ m = json.load(open("/tmp/stable-manifest.json"))
+ if "manifests" in m:
+ plats = [x["digest"] for x in m["manifests"] if x.get("platform",{}).get("architecture") in ("amd64","arm64")]
+ print(plats[0] if plats else "")
+ else:
+ print("self")' || true)
+ if [ "$digest" = "self" ]; then
+ cp /tmp/stable-manifest.json /tmp/stable-image.json
+ elif [ -n "$digest" ]; then
+ curl -fsS -H "Authorization: Bearer ${reg_token}" -H "Accept: ${MEDIA}" \
+ "https://ghcr.io/v2/${repo}/manifests/${digest}" > /tmp/stable-image.json || : > /tmp/stable-image.json
+ else
+ : > /tmp/stable-image.json
+ fi
+ config=$(python3 -c '
+ import json,sys
+ try:
+ print(json.load(open("/tmp/stable-image.json"))["config"]["digest"])
+ except Exception:
+ print("")' || true)
+ current=""
+ if [ -n "$config" ]; then
+ current=$(curl -fsSL -H "Authorization: Bearer ${reg_token}" \
+ "https://ghcr.io/v2/${repo}/blobs/${config}" \
+ | python3 -c 'import json,sys; c=json.load(sys.stdin); print((c.get("config",{}).get("Labels") or {}).get("org.opencontainers.image.version",""))' || true)
+ fi
+ case "${current}" in
+ v[0-9]*|[0-9]*)
+ major="${current#v}"
+ major="${major%%.*}"
+ ;;
+ *)
+ blocked="true"
+ echo "::error::\`${IMAGE}:stable\` exists but its version label could not be read (got '${current}'); the channel is held for this release — dispatch image-channel.yml to move it deliberately"
+ ;;
+ esac
+ else
+ blocked="true"
+ echo "::error::reading \`${IMAGE}:stable\` answered HTTP ${code}; the channel is held for this release — a present-but-unreadable channel must never be mistaken for a first release"
+ fi
fi
echo "major=${major}" >> "$GITHUB_OUTPUT"
- echo "stable channel for ${IMAGE} is on major '${major:-<none>}'"
+ echo "blocked=${blocked}" >> "$GITHUB_OUTPUT"
+ echo "stable channel for ${IMAGE} is on major '${major:-<none>}' (blocked=${blocked})"
- id: image-tags
@@ -699,6 +757,7 @@ jobs:
REPUBLISH: ${{ github.event_name == 'workflow_dispatch' }}
PROMOTE_STABLE: ${{ inputs.promote_stable }}
STABLE_MAJOR: ${{ steps.stable-major.outputs.major }}
+ STABLE_BLOCKED: ${{ steps.stable-major.outputs.blocked }}
IMAGE: ${{ matrix.image }}
IS_DEMO: ${{ matrix.demo }}
run: |
@@ -737,7 +796,10 @@ jobs:
# dispatch arm is the only way `stable` ever reaches a major,
# and it is separate from the republish arm above so repairing
# an old tag cannot drag `stable` backwards with it.
- if { [ "$REPUBLISH" != "true" ] && [ "$IS_MAJOR" != "true" ] && [ "$SAME_MAJOR" = "true" ]; } || [ "$PROMOTE_STABLE" = "true" ]; then
+ # STABLE_BLOCKED means the channel exists but could not be
+ # read; moving it then would be a guess, so only the deliberate
+ # promotion arm may move a blocked channel.
+ if { [ "$REPUBLISH" != "true" ] && [ "$IS_MAJOR" != "true" ] && [ "$SAME_MAJOR" = "true" ] && [ "${STABLE_BLOCKED:-false}" != "true" ]; } || [ "$PROMOTE_STABLE" = "true" ]; then
echo "${IMAGE}:stable"
fi
fi
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 97a4f996b..b55a6af9f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
+- **The image `stable` channel guard read the registry through a buildx
+ template, and when the runner's buildx stopped resolving it the guard
+ failed open** — the read returned empty with stderr discarded, "empty" was
+ read as "first release", and the v20.0.0 and v20.1.0 publishes each carried
+ image `stable` across the v19 → v20 application major the guard exists to
+ refuse, silently, under green runs. The read now goes through the registry
+ HTTP API (manifest → config blob → version label), exactly as the chart
+ half always did — which is why the chart channel held while the image
+ channel crossed. Three states instead of two: a 404 is the ordinary
+ first-release state and the channel may be taken; a tag that is **present
+ but unreadable blocks the channel** for that release, because refusing is
+ recoverable and a wrong crossing is not; only the deliberate
+ `promote_stable` dispatch may move a blocked channel.
+ `tests/test_release_channel_tags.py` pins both (the blocked-channel test
+ fails against the pre-fix block). `image-channel.yml` is the image half of
+ the chart's repair tool: a dispatch re-points every image's `stable` at a
+ named published release, byte-identical, with before/after evidence per
+ image — and was dispatched to restore the channel to v19.0.0, the recorded
+ owner decision.
- The nightly reproducible-builds aggregator accepts the lock-only
matrix's **designed** skip — its own condition skips it when every
service ships an image, which has been true since the last image-less
diff --git a/apps/docs/docs/operations/release-policy.md b/apps/docs/docs/operations/release-policy.md
index 2447059ee..2817f0fc6 100644
--- a/apps/docs/docs/operations/release-policy.md
+++ b/apps/docs/docs/operations/release-policy.md
@@ -142,14 +142,23 @@ either major boundary stops promotion until a maintainer dispatches with
### Repairing a channel that is pointing at the wrong version
-`chart-channel.yml` (workflow dispatch) is the deliberate human action the
-guard points at. It re-points the chart `stable` tag at a named,
-**already-published** chart version — byte-identical manifest, either
-direction, with before/after evidence in the log. It never republishes a
-chart *version*: `helm push` overwrites silently and an overwritten version
-tag is unrecoverable, so the repair tool only moves the mutable channel tag.
-Until it existed, the only way `stable` could move was another release tag
-push, which is no tool at all when the channel is already wrong.
+`chart-channel.yml` and `image-channel.yml` (workflow dispatch) are the
+deliberate human action the guards point at — one for the chart, one for the
+sixteen first-party images. Each re-points the `stable` tag at a named,
+**already-published** version — byte-identical manifest, either direction,
+with before/after evidence in the log. Neither ever republishes a *version*
+tag: an overwritten version is unrecoverable, so the repair tools only move
+the mutable channel tag. Until they existed, the only way `stable` could move
+was another release tag push, which is no tool at all when the channel is
+already wrong.
+
+One reading lesson is now encoded in both guards: the release workflow reads
+where a channel *is* through the registry HTTP API, never through a
+`docker buildx imagetools inspect` template — a template's shape is a
+property of whatever buildx the runner ships that day, and when it broke the
+image guard read an existing channel as a first release and moved it across
+an application major. A channel that is **present but unreadable now blocks**
+rather than moves: refusing is recoverable, a wrong crossing is not.
Pin an explicit version in production; a constraint is for the case where you
would otherwise have pinned nothing at all.
diff --git a/tests/test_release_channel_tags.py b/tests/test_release_channel_tags.py
index 7537722fd..71a79517d 100644
--- a/tests/test_release_channel_tags.py
+++ b/tests/test_release_channel_tags.py
@@ -38,7 +38,13 @@ def _tag_script() -> str:
def run_tags(
- *, version: str, republish: bool = False, promote_stable: bool = False, demo: bool = False, stable_major: str = ""
+ *,
+ version: str,
+ republish: bool = False,
+ promote_stable: bool = False,
+ demo: bool = False,
+ stable_major: str = "",
+ stable_blocked: bool = False,
) -> list[str]:
"""Execute the workflow's own tag block and return the tags it emitted."""
script = _tag_script()
@@ -53,6 +59,7 @@ def run_tags(
"IMAGE": IMAGE,
"IS_DEMO": "true" if demo else "false",
"STABLE_MAJOR": stable_major,
+ "STABLE_BLOCKED": "true" if stable_blocked else "false",
"GITHUB_OUTPUT": str(output),
}
done = subprocess.run(["bash", "-c", script], env=env, capture_output=True, text=True)
@@ -87,6 +94,28 @@ def test_a_major_reaches_stable_only_when_promoted_deliberately() -> None:
assert f"{IMAGE}:stable" in run_tags(version="v12.0.0", republish=True, promote_stable=True)
+def test_an_unreadable_channel_is_held_not_taken() -> None:
+ """The v20.0.0/v20.1.0 regression, stated as a rule.
+
+ The runner's buildx template broke, the registry read came back empty
+ with stderr discarded, and "empty" was read as "first release" — so two
+ consecutive publishes carried `stable` across the v19 -> v20 boundary
+ the guard exists to refuse. A channel that is present but unreadable is
+ now a *blocked* state: the minor publishes, `latest` moves, and `stable`
+ stays exactly where it is.
+ """
+ assert run_tags(version="v20.1.0", stable_blocked=True) == [
+ f"{IMAGE}:v20.1.0",
+ f"{IMAGE}:latest",
+ ]
+
+
+def test_a_deliberate_promotion_overrides_a_blocked_channel() -> None:
+ """Dispatching with promote_stable is the human decision; it may move a
+ channel the automatic arm refuses to touch."""
+ assert f"{IMAGE}:stable" in run_tags(version="v21.0.0", promote_stable=True, stable_blocked=True)
+
+
def test_repairing_an_old_tag_moves_neither_channel() -> None:
tags = run_tags(version="v11.0.0", republish=True)
assert tags == [f"{IMAGE}:v11.0.0"], (