Files
marqdo-cli/.github/workflows/security-linux.yml
T
cflmy 512b9f5f1d
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(security): fail the lane when evidence generation fails
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.
2026-11-21 17:41:23 +08:00

117 lines
4.3 KiB
YAML

name: Linux strict security lane (G-C)
# This workflow intentionally does NOT run on GitHub-hosted runners. G-C
# requires a disposable Ubuntu VM/self-hosted runner with permitted user,
# mount, PID and network namespaces and the Bubblewrap AppArmor profile.
# A missing runner or a skipped test fails the gate; it is never counted as a
# pass. See docs/security-gate.md and ADR-0021.
#
# Trust model: the runner registration must be issued by a trusted, short-lived
# orchestrator and the VM destroyed after the job. A persistent self-hosted
# runner with GitHub/SSH/cloud credentials is NOT acceptable. The workflow
# records tested_sha separately from workflow_sha and never runs on PRs.
on:
push:
branches: [master]
workflow_dispatch:
inputs:
source_sha:
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
jobs:
strict-security:
name: strict isolation escape matrix
if: github.event_name != 'pull_request'
runs-on: [self-hosted, linux, marqdo-security]
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.source_sha || github.sha }}
persist-credentials: false
- name: Bind tested SHA and archive
shell: bash
run: |
set -euo pipefail
tested_sha="$(git rev-parse HEAD)"
expected="${{ github.event_name == 'workflow_dispatch' && inputs.source_sha || github.sha }}"
if [ "$tested_sha" != "$expected" ]; then
echo "tested SHA $tested_sha does not match expected $expected" >&2
exit 1
fi
printf 'TESTED_SHA=%s\n' "$tested_sha" >> "$GITHUB_ENV"
printf 'WORKFLOW_SHA=%s\n' "$GITHUB_SHA" >> "$GITHUB_ENV"
archive="$RUNNER_TEMP/marqdo-source-$tested_sha.tar"
git archive --format=tar "$tested_sha" > "$archive"
printf 'SOURCE_ARCHIVE_SHA256=%s\n' \
"sha256:$(sha256sum "$archive" | cut -d' ' -f1)" >> "$GITHUB_ENV"
- name: Host capability report
shell: bash
run: |
set -euo pipefail
test "$(id -u)" -ne 0
id
uname -a
systemd-detect-virt --container || true
bwrap --version
cc --version | head -1
rustc -vV
cat /proc/self/uid_map
findmnt -t cgroup2 || true
- name: Run G-C matrix
shell: bash
env:
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_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-${{ inputs.source_sha || github.sha }}
path: |
${{ runner.temp }}/strict-evidence.json
${{ runner.temp }}/gc-lane.log
if-no-files-found: warn
retention-days: 30