Skip to content

Commit 9ad96ea

Browse files
authored
Merge pull request DeusData#1282 from DeusData/feat/local-remote-parity
ci: revert runner-side Defender gating (RTP policy-locked off on hosted images)
2 parents 6d7bc80 + c1425d2 commit 9ad96ea

8 files changed

Lines changed: 56 additions & 69 deletions

File tree

‎.github/workflows/_smoke.yml‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,6 @@ jobs:
172172
steps:
173173
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
174174

175-
- name: Ensure Windows Defender is active (venue parity)
176-
shell: pwsh
177-
run: scripts/ci/ensure-defender.ps1
178-
179175
- uses: msys2/setup-msys2@66cd2cce69caa17b53920067426061ca1de3a884 # v2
180176
with:
181177
msystem: ${{ matrix.arch == 'arm64' && 'CLANGARM64' || 'CLANG64' }}
@@ -258,9 +254,7 @@ jobs:
258254
if ($code -eq 2) {
259255
Write-Host "BLOCKED: Windows Defender flagged $binary!"; exit 1
260256
} elseif ($code -ne 0) {
261-
# ensure-defender gates this job earlier, so the engine MUST be
262-
# available here: an engine failure is a red gate, never a skip.
263-
Write-Host "BLOCKED: Defender scan engine could not run for $binary (exit $code) - Defender-ON parity violated"; exit 1
257+
Write-Host "::warning::Windows Defender scan could not run for $binary (exit $code) - skipping AV gate on this runner"
264258
} else {
265259
Write-Host "=== Windows Defender: $binary clean ==="
266260
}

‎.github/workflows/_soak.yml‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@ jobs:
9393
steps:
9494
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
9595

96-
- name: Ensure Windows Defender is active (venue parity)
97-
shell: pwsh
98-
run: scripts/ci/ensure-defender.ps1
9996
- uses: msys2/setup-msys2@66cd2cce69caa17b53920067426061ca1de3a884 # v2
10097
with:
10198
msystem: CLANG64
@@ -153,9 +150,6 @@ jobs:
153150
steps:
154151
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
155152

156-
- name: Ensure Windows Defender is active (venue parity)
157-
shell: pwsh
158-
run: scripts/ci/ensure-defender.ps1
159153
- uses: msys2/setup-msys2@66cd2cce69caa17b53920067426061ca1de3a884 # v2
160154
with:
161155
msystem: CLANGARM64
@@ -271,9 +265,6 @@ jobs:
271265
steps:
272266
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
273267

274-
- name: Ensure Windows Defender is active (venue parity)
275-
shell: pwsh
276-
run: scripts/ci/ensure-defender.ps1
277268
- uses: msys2/setup-msys2@66cd2cce69caa17b53920067426061ca1de3a884 # v2
278269
with:
279270
msystem: CLANG64

‎.github/workflows/_test.yml‎

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,12 @@ jobs:
154154
with:
155155
name: shard-manifest-${{ matrix.os }}-${{ matrix.cc }}-${{ strategy.job-index }}
156156
path: build/c/test-logs/shard-manifest.txt
157-
if-no-files-found: error
157+
# The harness writes the manifest BEFORE any suite runs, so a
158+
# missing file here means the job died before the harness started
159+
# (contract step / build) — that failure is already the job's red;
160+
# warn instead of stacking a second error on top of it. The
161+
# shard-completeness job still gates the cross-shard union.
162+
if-no-files-found: warn
158163

159164
- name: Compiler cache (save)
160165
if: always() && (matrix.shard == null || startsWith(matrix.shard, '1/'))
@@ -247,11 +252,12 @@ jobs:
247252
steps:
248253
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
249254

250-
# Defender parity: every Windows venue (local VM and runner alike) tests
251-
# with real-time protection ACTIVE — enabled + verified, never skipped.
252-
- name: Ensure Windows Defender is active (venue parity)
253-
shell: pwsh
254-
run: scripts/ci/ensure-defender.ps1
255+
# Defender posture: real-time protection is POLICY-LOCKED OFF on hosted
256+
# Windows images (verified 2026-07-27: WinDefend starts and
257+
# Set-MpPreference accepts, but RTP stays off — untamperable from the
258+
# job). The local VM leg enforces Defender-ON via the canonical Defender
259+
# preflight script, so AV-interaction coverage lives there; runners run
260+
# without RTP by platform constraint.
255261

256262
- uses: msys2/setup-msys2@66cd2cce69caa17b53920067426061ca1de3a884 # v2
257263
with:
@@ -329,7 +335,12 @@ jobs:
329335
with:
330336
name: shard-manifest-${{ matrix.os }}-${{ matrix.msystem }}-${{ strategy.job-index }}
331337
path: build/c/test-logs/shard-manifest.txt
332-
if-no-files-found: error
338+
# The harness writes the manifest BEFORE any suite runs, so a
339+
# missing file here means the job died before the harness started
340+
# (contract step / build) — that failure is already the job's red;
341+
# warn instead of stacking a second error on top of it. The
342+
# shard-completeness job still gates the cross-shard union.
343+
if-no-files-found: warn
333344

334345
# Shard 1 (or the unsharded job) saves the compiler cache; every shard
335346
# builds the identical runner, so one cache carries the full object set.
@@ -381,10 +392,6 @@ jobs:
381392
steps:
382393
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
383394

384-
- name: Ensure Windows Defender is active (venue parity)
385-
shell: pwsh
386-
run: scripts/ci/ensure-defender.ps1
387-
388395
- uses: msys2/setup-msys2@66cd2cce69caa17b53920067426061ca1de3a884 # v2
389396
with:
390397
msystem: CLANG64

‎.github/workflows/pr.yml‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@ jobs:
8484
steps:
8585
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
8686

87-
- name: Ensure Windows Defender is active (venue parity)
88-
if: matrix.os == 'windows-latest'
89-
shell: pwsh
90-
run: scripts/ci/ensure-defender.ps1
91-
9287
- name: Install deps (Ubuntu)
9388
if: matrix.os == 'ubuntu-latest'
9489
run: sudo apt-get update && sudo apt-get install -y zlib1g-dev ccache

‎.gitignore‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,7 @@ graph-ui/.npm-cache-local/
6666
# Python bytecode from tests/windows/ harness
6767
__pycache__/
6868
*.pyc
69+
70+
# Local soak-leg outputs (uploaded as CI artifacts, never committed)
71+
soak-results/
72+
soak-results-query-leak/

‎scripts/run-tests-parallel.sh‎

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,22 @@ shard_filter < "$SER_FILE" > "$SER_FILE.shard" && mv "$SER_FILE.shard" "$SER_FIL
195195
SHARD_EXPECT="$LOGDIR/suites-shard.txt"
196196
cat "$PAR_FILE" "$SER_FILE" > "$SHARD_EXPECT"
197197
NSHARD=$(wc -l < "$SHARD_EXPECT" | tr -d ' ')
198+
199+
# Machine-checkable manifest for CI's cross-shard completeness job: it
200+
# proves at runtime that the shards of one leg agree on N and on the full
201+
# suite list, and that the union of their slices IS that list — the guard
202+
# against a mis-plumbed CBM_TEST_SHARD (two jobs running the same slice
203+
# passes every per-shard check but silently drops a slice; only a
204+
# cross-shard view catches it). Written BEFORE any suite runs: the slice is
205+
# fully determined here, and a red run's manifest is exactly as load-bearing
206+
# as a green one's — CI uploads it if: always().
207+
{
208+
echo "leg=${CBM_TEST_LEG:-local}"
209+
echo "shard=${SHARD_INDEX}/${SHARD_TOTAL}"
210+
echo "list_sha256=$(sort "$SUITES_FILE" | { sha256sum 2>/dev/null || shasum -a 256; } | awk '{print $1}')"
211+
echo "--- slice ---"
212+
cat "$SHARD_EXPECT"
213+
} > "$LOGDIR/shard-manifest.txt"
198214
echo "=== parallel test run: $NSHARD of $NSUITES suites (shard ${SHARD_INDEX}/${SHARD_TOTAL}, $(wc -l < "$SER_FILE" | tr -d ' ') serial-tail), $JOBS jobs ==="
199215

200216
# Per-suite wall-clock ceilings make a wedged child fail loudly. The
@@ -255,20 +271,6 @@ stamp_windows_build_dir pre-tail
255271
run_wave "$FLEX_FILE" "${CBM_TAIL_JOBS:-2}"
256272
run_wave "$EXCL_FILE" 1
257273

258-
# Machine-checkable manifest for CI's cross-shard completeness job: it
259-
# proves at runtime that the shards of one leg agree on N and on the full
260-
# suite list, and that the union of their slices IS that list — the guard
261-
# against a mis-plumbed CBM_TEST_SHARD (two jobs running the same slice
262-
# passes every per-shard check but silently drops a slice; only a
263-
# cross-shard view catches it).
264-
{
265-
echo "leg=${CBM_TEST_LEG:-local}"
266-
echo "shard=${SHARD_INDEX}/${SHARD_TOTAL}"
267-
echo "list_sha256=$(sort "$SUITES_FILE" | { sha256sum 2>/dev/null || shasum -a 256; } | awk '{print $1}')"
268-
echo "--- slice ---"
269-
cat "$SHARD_EXPECT"
270-
} > "$LOGDIR/shard-manifest.txt"
271-
272274
# ── Union guard: every suite in this shard's slice produced exactly one
273275
# result. The slice is deterministic, so N green shard jobs = full coverage;
274276
# a shard that ran anything more, less, or twice fails here. ──

‎test-infrastructure/vm/README.md‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,12 @@ documented honestly where not:
119119

120120
- **Preflight, every venue-grade command:** `clean-test-residue.ps1` sweeps
121121
temp roots/staged binaries and asserts a runner-like free-disk floor, then
122-
`scripts/ci/ensure-defender.ps1` (the SAME script every Windows CI job runs)
123-
enables + verifies Defender real-time protection. Defender posture is
124-
matched ON on all venues — the runners enable it too; a venue where it
125-
cannot be activated goes red, never silently tests a different OS shape.
122+
`scripts/ci/ensure-defender.ps1` enables + verifies Defender real-time
123+
protection ON THIS VM (fail-closed: a drifted-off Defender goes red).
124+
Hosted GitHub runners CANNOT match this posture — RTP is policy-locked off
125+
on their images (verified 2026-07-27: WinDefend starts, Set-MpPreference
126+
accepts, RTP stays off) — so AV-interaction coverage is a deliberate LOCAL
127+
superset, and runner release scans stay on-demand (MpCmdRun, fail-soft).
126128
- **Snapshot-revert is NOT scriptable via utmctl** (its verb set is
127129
version/list/status/start/suspend/stop — no snapshot support), so per-run
128130
revert-to-clean is not wired. The honest fallback is the sweep preflight

‎tests/test_venue_parity_contract.sh‎

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -249,32 +249,24 @@ REQUIRED = [
249249
("pr.yml", r"vm-smoke\.sh", "PR CI smokes through the shared wrapper"),
250250
("_build.yml", r"scripts/package-release\.sh",
251251
"release archives are produced by the canonical packaging entry"),
252-
("_test.yml", r"scripts/ci/ensure-defender\.ps1",
253-
"Windows test legs enable+verify Defender (venue parity)"),
254-
("_smoke.yml", r"scripts/ci/ensure-defender\.ps1",
255-
"Windows release smoke enables+verifies Defender (venue parity)"),
256-
("_soak.yml", r"scripts/ci/ensure-defender\.ps1",
257-
"Windows soak legs enable+verify Defender (venue parity)"),
258-
("pr.yml", r"scripts/ci/ensure-defender\.ps1",
259-
"PR Windows smoke enables+verifies Defender (venue parity)"),
260252
]
261253
for name, pattern, why in REQUIRED:
262254
path = workflows / name
263255
if path.exists() and not re.search(pattern, path.read_text()):
264256
failures.append(f"{name}: missing required `{pattern}` — {why}")
265257
266-
# Defender-ON parity: EVERY Windows job in every venue workflow enables and
267-
# verifies real-time protection — a single job dropping the step must fail,
268-
# so the expectation is an exact per-file count, not mere presence.
269-
DEFENDER_STEPS = {"_test.yml": 2, "_soak.yml": 3, "_smoke.yml": 1, "pr.yml": 1}
270-
for name, expected in DEFENDER_STEPS.items():
258+
# Defender posture: hosted Windows runners have real-time protection
259+
# POLICY-LOCKED OFF (verified 2026-07-27: WinDefend starts, Set-MpPreference
260+
# accepts, RTP stays off), so runner jobs must NOT gate on enabling it; the
261+
# LOCAL VM leg enforces Defender-ON via the same canonical script in its
262+
# preflight (see LOCAL_REQUIRED below) — superset coverage where the platform
263+
# allows it.
264+
for name in ("_test.yml", "_soak.yml", "_smoke.yml", "pr.yml"):
271265
path = workflows / name
272-
if path.exists():
273-
got = path.read_text().count("scripts/ci/ensure-defender.ps1")
274-
if got != expected:
275-
failures.append(
276-
f"{name}: expected {expected} ensure-defender.ps1 step(s) "
277-
f"(one per Windows job), found {got}")
266+
if path.exists() and "ensure-defender.ps1" in path.read_text():
267+
failures.append(
268+
f"{name}: ensure-defender.ps1 must not gate hosted runners — RTP is "
269+
f"policy-locked off there; the VM preflight owns Defender-ON coverage")
278270
279271
# ── Layer 4: the local venues route through the same entries ──
280272
compose = root / "test-infrastructure" / "docker-compose.yml"

0 commit comments

Comments
 (0)