ci(security): fail the lane when evidence generation fails
CI / fmt + clippy + test (Linux x86_64) (push) Waiting to run
CI / schema instance validation + consumers (push) Waiting to run
CI / runtime contract (macos-latest) (push) Waiting to run
CI / runtime contract (windows-latest) (push) Waiting to run
Linux strict security lane (G-C) / strict isolation escape matrix (push) Waiting to run
ci/woodpecker/push/woodpecker Pipeline was successful
CI / fmt + clippy + test (Linux x86_64) (push) Waiting to run
CI / schema instance validation + consumers (push) Waiting to run
CI / runtime contract (macos-latest) (push) Waiting to run
CI / runtime contract (windows-latest) (push) Waiting to run
Linux strict security lane (G-C) / strict isolation escape matrix (push) Waiting to run
ci/woodpecker/push/woodpecker Pipeline was successful
A green lane without a strict-evidence.json must not count as a gate. The EXIT trap now turns a generator failure into a lane failure. The self-hosted workflow exports the archive path in the run step (env written by GITHUB_ENV is not guaranteed in the env expression context), records the pinned image digest as an input, and verifies schema/outcome/tested_sha/non-root before uploading. Also define SOURCE_SHA before the VM overlay commands.
This commit is contained in:
1 parent
f01e8a9bb0
commit
512b9f5f1d
3 files changed
+35
-5
No files matched your search
@@ -20,6 +20,11 @@ on:
|
||||
description: "Exact reviewed commit SHA"
|
||||
required: true
|
||||
type: string
|
||||
runner_image_sha256:
|
||||
description: "Pinned VM base-image digest (evidence, not a secret)"
|
||||
required: false
|
||||
default: "unrecorded"
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -73,17 +78,37 @@ jobs:
|
||||
MARQDO_STRICT_EVIDENCE: ${{ runner.temp }}/strict-evidence.json
|
||||
MARQDO_STRICT_LANE_LOG: ${{ runner.temp }}/gc-lane.log
|
||||
MARQDO_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
MARQDO_SOURCE_ARCHIVE: ${{ runner.temp }}/marqdo-source-${{ env.TESTED_SHA }}.tar
|
||||
MARQDO_RUNNER_KIND: disposable-vm
|
||||
MARQDO_RUNNER_IMAGE_SHA256: ${{ inputs.runner_image_sha256 || 'unrecorded' }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
export MARQDO_SOURCE_ARCHIVE="$RUNNER_TEMP/marqdo-source-${TESTED_SHA}.tar"
|
||||
./tests/security/run-lane.sh 2>&1 | tee "$MARQDO_STRICT_LANE_LOG"
|
||||
|
||||
- name: Verify strict evidence matches the tested SHA
|
||||
if: success()
|
||||
shell: bash
|
||||
env:
|
||||
MARQDO_STRICT_EVIDENCE: ${{ runner.temp }}/strict-evidence.json
|
||||
run: |
|
||||
set -euo pipefail
|
||||
python3 - <<'PY'
|
||||
import json, os
|
||||
path = os.environ["MARQDO_STRICT_EVIDENCE"]
|
||||
with open(path, encoding="utf-8") as handle:
|
||||
evidence = json.load(handle)
|
||||
assert evidence["schema"] == "marqdo.strict-evidence.v1", evidence
|
||||
assert evidence["run"]["outcome"] == "PASS", evidence
|
||||
assert evidence["tested_sha"] == os.environ["TESTED_SHA"], evidence
|
||||
assert evidence["environment"]["uid"] != 0, evidence
|
||||
print("strict evidence verified for", evidence["tested_sha"])
|
||||
PY
|
||||
|
||||
- name: Upload strict evidence
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: strict-evidence-${{ env.TESTED_SHA || github.sha }}
|
||||
name: strict-evidence-${{ inputs.source_sha || github.sha }}
|
||||
path: |
|
||||
${{ runner.temp }}/strict-evidence.json
|
||||
${{ runner.temp }}/gc-lane.log
|
||||
|
||||
@@ -34,6 +34,7 @@ URL. Download one dated release, verify it against Ubuntu's published
|
||||
`SHA256SUMS`, record the digest, and keep that file immutable:
|
||||
|
||||
```bash
|
||||
export SOURCE_SHA="$(git rev-parse HEAD)" # reviewed commit, clean tree
|
||||
mkdir -p .tools/vm && cd .tools/vm
|
||||
# Replace with the reviewed dated release URL, never .../current/...
|
||||
curl -L -o ubuntu-base.img \
|
||||
|
||||
@@ -23,14 +23,18 @@ finish_lane() {
|
||||
if [ "$status" -eq 0 ]; then
|
||||
outcome="PASS"
|
||||
fi
|
||||
python3 tools/ci/strict-evidence.py \
|
||||
if ! python3 tools/ci/strict-evidence.py \
|
||||
--repo "$repo" \
|
||||
--out "$evidence" \
|
||||
--outcome "$outcome" \
|
||||
--started "$started_utc" \
|
||||
--finished "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
|
||||
--log "${MARQDO_STRICT_LANE_LOG:-}" \
|
||||
|| echo "warning: could not write strict evidence" >&2
|
||||
--log "${MARQDO_STRICT_LANE_LOG:-}"; then
|
||||
echo "error: strict evidence generation failed; a green lane without evidence is not a gate" >&2
|
||||
if [ "$status" -eq 0 ]; then
|
||||
status=1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
exit "$status"
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user