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"
|
description: "Exact reviewed commit SHA"
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
runner_image_sha256:
|
||||||
|
description: "Pinned VM base-image digest (evidence, not a secret)"
|
||||||
|
required: false
|
||||||
|
default: "unrecorded"
|
||||||
|
type: string
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
@@ -73,17 +78,37 @@ jobs:
|
|||||||
MARQDO_STRICT_EVIDENCE: ${{ runner.temp }}/strict-evidence.json
|
MARQDO_STRICT_EVIDENCE: ${{ runner.temp }}/strict-evidence.json
|
||||||
MARQDO_STRICT_LANE_LOG: ${{ runner.temp }}/gc-lane.log
|
MARQDO_STRICT_LANE_LOG: ${{ runner.temp }}/gc-lane.log
|
||||||
MARQDO_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
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_KIND: disposable-vm
|
||||||
|
MARQDO_RUNNER_IMAGE_SHA256: ${{ inputs.runner_image_sha256 || 'unrecorded' }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
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"
|
./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
|
- name: Upload strict evidence
|
||||||
if: always()
|
if: always()
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: strict-evidence-${{ env.TESTED_SHA || github.sha }}
|
name: strict-evidence-${{ inputs.source_sha || github.sha }}
|
||||||
path: |
|
path: |
|
||||||
${{ runner.temp }}/strict-evidence.json
|
${{ runner.temp }}/strict-evidence.json
|
||||||
${{ runner.temp }}/gc-lane.log
|
${{ 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:
|
`SHA256SUMS`, record the digest, and keep that file immutable:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
export SOURCE_SHA="$(git rev-parse HEAD)" # reviewed commit, clean tree
|
||||||
mkdir -p .tools/vm && cd .tools/vm
|
mkdir -p .tools/vm && cd .tools/vm
|
||||||
# Replace with the reviewed dated release URL, never .../current/...
|
# Replace with the reviewed dated release URL, never .../current/...
|
||||||
curl -L -o ubuntu-base.img \
|
curl -L -o ubuntu-base.img \
|
||||||
|
|||||||
@@ -23,14 +23,18 @@ finish_lane() {
|
|||||||
if [ "$status" -eq 0 ]; then
|
if [ "$status" -eq 0 ]; then
|
||||||
outcome="PASS"
|
outcome="PASS"
|
||||||
fi
|
fi
|
||||||
python3 tools/ci/strict-evidence.py \
|
if ! python3 tools/ci/strict-evidence.py \
|
||||||
--repo "$repo" \
|
--repo "$repo" \
|
||||||
--out "$evidence" \
|
--out "$evidence" \
|
||||||
--outcome "$outcome" \
|
--outcome "$outcome" \
|
||||||
--started "$started_utc" \
|
--started "$started_utc" \
|
||||||
--finished "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
|
--finished "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
|
||||||
--log "${MARQDO_STRICT_LANE_LOG:-}" \
|
--log "${MARQDO_STRICT_LANE_LOG:-}"; then
|
||||||
|| echo "warning: could not write strict evidence" >&2
|
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
|
fi
|
||||||
exit "$status"
|
exit "$status"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user