Skip to content

Commit d911d94

Browse files
committed
test(srt): guard srt-settings.json against drifting off the pack
Two static checks. The provenance marker check needs no pack checkout so it always runs; the byte-for-byte drift check needs one and reports SKIP (exit 93) without it, so a developer machine without the sibling clone does not go red. CI now checks out cheshirecode/srt-policy-packs into .srt-policy-packs and passes SRT_POLICY_PACKS, so the drift check actually runs there. A check nothing runs is not coverage. Proved red three ways before landing: del(._source) -> 2 fail (marker + drift) allowedDomains += evil.example -> 1 fail (drift), marker still PASS no pack checkout -> SKIP, 9 pass 0 fail
1 parent d7a662d commit d911d94

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,18 @@ jobs:
1313
timeout-minutes: 3
1414
steps:
1515
- uses: actions/checkout@v4
16+
# srt-settings.json is a vendored render of the srt-policy-packs
17+
# generic-agent pack. Without this checkout the drift check SKIPs and
18+
# a hand-edit of the policy would sail through CI unnoticed.
19+
- uses: actions/checkout@v4
20+
with:
21+
repository: cheshirecode/srt-policy-packs
22+
path: .srt-policy-packs
1623
- name: Install shellcheck
1724
run: sudo apt-get update -qq && sudo apt-get install -y shellcheck
1825
- name: Run static suite
26+
env:
27+
SRT_POLICY_PACKS: ${{ github.workspace }}/.srt-policy-packs
1928
run: ./tests/run.sh static
2029

2130
build-and-functional:

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ id_ecdsa
1818

1919
# macOS
2020
.DS_Store
21+
.srt-policy-packs/

‎tests/run.sh‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,26 @@ json.loads(t)
9595
else
9696
fail "mounts.env references no seccomp profile"
9797
fi
98+
99+
# srt policy provenance. srt-settings.json is a vendored render of the
100+
# srt-policy-packs generic-agent pack; a hand-edit here silently forks the
101+
# sandbox off the pack. The marker check needs no pack checkout, so it
102+
# always runs; the drift check needs one and SKIPs (exit 93) without it.
103+
if jq -e '._source | strings | contains("srt-policy-packs")' srt-settings.json >/dev/null 2>&1; then
104+
ok "srt-settings.json declares its pack provenance"
105+
else
106+
fail "srt-settings.json lost its _source provenance marker"
107+
fi
108+
srt_sync_rc=0
109+
srt_sync_out=$(./tools/sync-srt-policy.sh --check 2>&1) || srt_sync_rc=$?
110+
if [ $srt_sync_rc -eq 0 ]; then
111+
ok "srt-settings.json matches the generic-agent pack + overlay"
112+
elif [ $srt_sync_rc -eq 93 ]; then
113+
say SKIP "no srt-policy-packs checkout (set SRT_POLICY_PACKS to drift-check)"
114+
else
115+
printf '%s\n' "$srt_sync_out"
116+
fail "srt-settings.json drifted from the pack (run tools/sync-srt-policy.sh)"
117+
fi
98118
}
99119

100120
# --- Build -----------------------------------------------------------------

0 commit comments

Comments
 (0)