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): make cosign image signing idempotent and transient-proof (#1433)

Beenu Arorae460dd9ce97d
diff --git a/.github/workflows/publish-images.yml b/.github/workflows/publish-images.yml
index ace0a95e4..46c0bd4aa 100644
--- a/.github/workflows/publish-images.yml
+++ b/.github/workflows/publish-images.yml
@@ -450,7 +450,45 @@ jobs:
- name: Sign image (cosign keyless)
env:
DIGEST: ${{ steps.manifest.outputs.digest }}
- run: cosign sign --yes "${{ matrix.image }}@${DIGEST}"
+ # Hardened against the two ways one signing can observe itself and
+ # fail, the second of which reddened the 2026-10-21 main publish on
+ # `api` and `honeytokens`:
+ #
+ # * A job rerun after a *later* step failed re-signs a digest that
+ # already carries this repository's valid signature. Verify-first
+ # makes that a skip instead of a second signature.
+ # * Rekor can accept the entry while the client times out and
+ # retries the identical payload, which answers 409
+ # createLogEntryConflict against the step's own first POST and
+ # aborts before the registry attachment is written — measured: the
+ # conflicting entry's integratedTime (17:19:28Z) sat inside the
+ # failing step's own 17:19:24–:56 window, and `cosign verify`
+ # found no registry signature on the digest afterwards. A fresh
+ # attempt uses a fresh ephemeral key and cannot conflict, so retry
+ # once; the trailing verify turns "the artifact ended up signed
+ # anyway" into a pass and anything else stays a hard failure.
+ run: |
+ set -euo pipefail
+ verify() {
+ cosign verify \
+ --certificate-identity-regexp "^https://github.com/${{ github.repository }}/" \
+ --certificate-oidc-issuer https://token.actions.githubusercontent.com \
+ "${{ matrix.image }}@${DIGEST}" >/dev/null 2>&1
+ }
+ if verify; then
+ echo "already signed by this repository's workflows; skipping re-sign of ${DIGEST}"
+ exit 0
+ fi
+ if cosign sign --yes "${{ matrix.image }}@${DIGEST}"; then
+ exit 0
+ fi
+ echo "first sign attempt failed; retrying once with a fresh ephemeral key"
+ sleep 10
+ if cosign sign --yes "${{ matrix.image }}@${DIGEST}"; then
+ exit 0
+ fi
+ echo "second sign attempt failed; accepting only if a valid signature exists"
+ verify
- name: Attach CycloneDX SBOM attestation
env:
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 4fa45cc8c..cba0d162d 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -782,7 +782,44 @@ jobs:
- name: Sign image (cosign keyless)
env:
DIGEST: ${{ steps.manifest.outputs.digest }}
- run: cosign sign --yes "${{ matrix.image }}@${DIGEST}"
+ # Hardened against the two ways one signing can observe itself and
+ # fail (mirrors publish-images.yml, where the second was measured):
+ #
+ # * A job rerun after a *later* step failed re-signs a digest that
+ # already carries this repository's valid signature. Verify-first
+ # makes that a skip instead of a second signature.
+ # * Rekor can accept the entry while the client times out and
+ # retries the identical payload, which answers 409
+ # createLogEntryConflict against the step's own first POST and
+ # aborts before the registry attachment is written (measured on
+ # the 2026-10-21 main publish: the conflicting entry's
+ # integratedTime sat inside the failing step's own window, and the
+ # digest had no registry signature afterwards). A fresh attempt
+ # uses a fresh ephemeral key and cannot conflict, so retry once;
+ # the trailing verify turns "the artifact ended up signed anyway"
+ # into a pass and anything else stays a hard failure.
+ run: |
+ set -euo pipefail
+ verify() {
+ cosign verify \
+ --certificate-identity-regexp "^https://github.com/${{ github.repository }}/" \
+ --certificate-oidc-issuer https://token.actions.githubusercontent.com \
+ "${{ matrix.image }}@${DIGEST}" >/dev/null 2>&1
+ }
+ if verify; then
+ echo "already signed by this repository's workflows; skipping re-sign of ${DIGEST}"
+ exit 0
+ fi
+ if cosign sign --yes "${{ matrix.image }}@${DIGEST}"; then
+ exit 0
+ fi
+ echo "first sign attempt failed; retrying once with a fresh ephemeral key"
+ sleep 10
+ if cosign sign --yes "${{ matrix.image }}@${DIGEST}"; then
+ exit 0
+ fi
+ echo "second sign attempt failed; accepting only if a valid signature exists"
+ verify
- name: Attach CycloneDX SBOM attestation
env: