Repository navigation
153 lines (153 loc) · 7.27 KB
/
Copy pathe2e.yml
File metadata and controls
153 lines (153 loc) · 7.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# This workflow is managed by gh actions-lock.
# SPDX-License-Identifier: MPL-2.0
# This workflow is managed by gh actions-lock.
# This workflow is managed by gh actions-lock.
name: E2E Tests
on:
push:
branches: [main]
pull_request:
branches: ['**']
permissions: {}
jobs:
e2e:
name: E2E tests
permissions:
actions: read
contents: read
needs: pinned-source-closure
if: ${{ always() }}
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Require verified pinned-source closure
env:
CLOSURE_RESULT: ${{ needs.pinned-source-closure.result }}
run: |
if [ "$CLOSURE_RESULT" != success ]; then
echo "Pinned-source closure did not pass: $CLOSURE_RESULT" >&2
exit 1
fi
- uses: actions/checkout@v7.0.1
- name: Audit workflow lock auditor dependencies
run: |
set -euo pipefail
# Official RustSec binary, immutable content hash from its release asset.
archive="$RUNNER_TEMP/cargo-audit.tgz"
curl --proto '=https' --proto-redir '=https' -fsSL --retry 3 https://github.com/rustsec/rustsec/releases/download/cargo-audit/v0.22.2/cargo-audit-x86_64-unknown-linux-gnu-v0.22.2.tgz -o "$archive"
printf '%s %s\n' ab28a1bdb54db4d5d8ad5981cf1f959410370b3d28250dbd35f6a44248620e39 "$archive" | sha256sum -c -
tar -xzf "$archive" -C "$RUNNER_TEMP"
"$RUNNER_TEMP/cargo-audit-x86_64-unknown-linux-gnu-v0.22.2/cargo-audit" audit --file tools/workflow-lock-audit/Cargo.lock --deny warnings
- name: Test workflow lock-map and regeneration audit
run: |
cargo test --locked --manifest-path tools/workflow-lock-audit/Cargo.toml
bash scripts/audit-workflow-lock-map.sh
- name: Test audit workflow diagnostics
run: |
python3 -c 'import yaml' || python3 -m pip install --user --only-binary=:all: --require-hashes -r .github/requirements/e2e.txt
bash scripts/tests/pr-audit-workflows-test.sh
- name: Verify automation quarantine
run: bash tests/automation-quarantine-test.sh
- name: Verify fix-outcome verdicts
run: bash tests/outcome-verdict-test.sh
- name: PA rule IDs agree with panic-attack's table
run: bash tests/panic-attack-rule-ids-test.sh
- name: Run E2E tests
run: bash tests/e2e.sh
- name: Verify canonical descriptile policy repair
run: bash tests/retired-descriptile-policy-test.sh
- name: Verify star-list enrollment discovery
run: bash tests/enroll-discovery-test.sh
- name: Verify the fleet report-back driver (envelope contract)
run: bash tests/fleet-report-back-test.sh
- name: Fleet enrolment fixer (report-back rollout)
run: bash tests/fix-fleet-enrolment-test.sh
pinned-source-closure:
name: Pinned source closure
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
steps:
- uses: actions/checkout@v7.0.1
- name: Set source cache
run: printf 'PINNED_SOURCE_CACHE=%s/fleet-pinned-sources\n' "$RUNNER_TEMP" >> "$GITHUB_ENV"
- name: Test pinned-source failure modes
run: bash scripts/tests/pinned-reusable-sources-test.sh
- name: Authenticate pinned reusable sources
run: bash scripts/audit-pinned-reusable-sources.sh --fetch-sources
- name: Verify live scanner caller and negative controls
run: bash scripts/tests/scanner-caller-contract-test.sh
- name: Authenticate historical scanner source for archived preflight
run: |
set -euo pipefail
tree="$RUNNER_TEMP/historical-scanner-source"
mkdir -p "$tree/scripts/lib"
cp -R .github "$tree/"
cp scripts/lib/{pinned-reusable-sources.json,lock-closure-receipts.tsv} "$tree/scripts/lib/"
bash docs/migrations/secret-scanner-cicd-suite/fixtures/restore-historical-source.sh \
"$tree" docs/migrations/secret-scanner-cicd-suite/fixtures/historical-source.json
bash scripts/audit-pinned-reusable-sources.sh --repo-root "$tree" --fetch-sources
- name: Preserve lock closure contracts
run: bash scripts/tests/lock-closure-test.sh
- name: Audit vendor lock and pinned-source closure
run: ./scripts/audit-lock-closure.sh
- name: Test source closure through migration preflight
run: |
rc=0
bash scripts/tests/pinned-source-entrypoints-test.sh > "$RUNNER_TEMP/preflight-tests.log" 2>&1 || rc=$?
cat "$RUNNER_TEMP/preflight-tests.log"
if [ "$rc" -ne 0 ]; then
detail=$(tail -c 5000 "$RUNNER_TEMP/preflight-tests.log")
detail=${detail//'%'/'%25'}; detail=${detail//$'\r'/'%0D'}; detail=${detail//$'\n'/'%0A'}
echo "::error::Historical preflight tests failed (exit $rc): $detail"
fi
exit "$rc"
- name: Prepared secret-scanner migration stays gated
run: |
# 0 = all preconditions hold; 2 = evidence is unavailable. The
# historical canary receipt is now present, but online/source evidence
# may still be unavailable. Findings (1 or 3) must fail the build.
rc=0
./docs/migrations/secret-scanner-cicd-suite/preflight.sh --quiet || rc=$?
case "$rc" in
0|2) echo "preflight exit $rc (no findings)";;
*) echo "preflight exit $rc: findings in the prepared migration" >&2; exit 1;;
esac
- name: Regenerate vendor lock in a disposable worktree
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
git worktree add --detach "$RUNNER_TEMP/lock-regeneration" HEAD
gh extension install github/gh-actions-lock --pin v0.4.1
cd "$RUNNER_TEMP/lock-regeneration"
gh actions-lock --no-interactive
git diff --stat -- .github/workflows
- name: Compare regenerated and reviewed vendor closures
run: |
set -euo pipefail
bash scripts/audit-lock-regeneration.sh \
.github/workflows/actions.lock "$RUNNER_TEMP/lock-regeneration/.github/workflows/actions.lock"
- name: Verify reviewed source closure against regeneration
run: |
set -euo pipefail
# The regeneration comparison alone covers only shared vendor roots.
# Independently authenticate the job-level reusable closure, including
# the scanner, against the regenerated lock and caller tree.
rc=0
bash scripts/audit-pinned-reusable-sources.sh \
--repo-root "$RUNNER_TEMP/lock-regeneration" \
--lock "$RUNNER_TEMP/lock-regeneration/.github/workflows/actions.lock" \
> "$RUNNER_TEMP/regenerated-source-audit.txt" 2>&1 || rc=$?
cat "$RUNNER_TEMP/regenerated-source-audit.txt"
if [ "$rc" -ne 0 ]; then
# Surface a bounded, escaped diagnostic in the check annotation as
# well as the logs; never turn an incomplete comparison into green.
detail=$(head -c 3000 "$RUNNER_TEMP/regenerated-source-audit.txt")
detail=${detail//'%'/'%25'}
detail=${detail//$'\r'/'%0D'}
detail=${detail//$'\n'/'%0A'}
echo "::error::Regenerated source audit exited $rc: $detail"
exit "$rc"
fi