Skip to content

Commit 1015dd2

Browse files
committed
ci(smoke): fail soft when the Windows Defender scan engine can't run
The Defender step treated any non-zero MpCmdRun exit as 'flagged binary!' and failed the job. But MpCmdRun -Scan returns 2 for a real detection and 0 for clean; any other non-zero means the scan engine itself could not run (e.g. hr=0x800106ba: the Defender antimalware service is unavailable on the runner), which is a transient runner-side flake, not a detection. This false-failed the v0.9.0 release on its first attempt. Only exit 2 now hard- blocks; an engine failure emits a warning and continues. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent ee68144 commit 1015dd2

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

‎.github/workflows/_smoke.yml‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,20 @@ jobs:
248248
run: |
249249
& "C:\Program Files\Windows Defender\MpCmdRun.exe" -SignatureUpdate 2>$null
250250
$result = & "C:\Program Files\Windows Defender\MpCmdRun.exe" -Scan -ScanType 3 -File "$PWD\codebase-memory-mcp.exe" -DisableRemediation
251+
$code = $LASTEXITCODE
251252
Write-Host $result
252-
if ($LASTEXITCODE -ne 0) { Write-Host "BLOCKED: Windows Defender flagged binary!"; exit 1 }
253-
Write-Host "=== Windows Defender: clean ==="
253+
# MpCmdRun -Scan exit codes: 0 = clean, 2 = threat found. Any OTHER non-zero
254+
# means the scan engine could not run at all (e.g. hr=0x800106ba: the Defender
255+
# antimalware service is unavailable on the runner) — that is NOT a detection.
256+
# Fail soft on an engine failure so a transient runner-side AV outage can't
257+
# false-fail a release; only a real detection (exit 2) hard-blocks.
258+
if ($code -eq 2) {
259+
Write-Host "BLOCKED: Windows Defender flagged binary!"; exit 1
260+
} elseif ($code -ne 0) {
261+
Write-Host "::warning::Windows Defender scan could not run (exit $code) - skipping AV gate on this runner"
262+
} else {
263+
Write-Host "=== Windows Defender: clean ==="
264+
}
254265
255266
smoke-linux-portable:
256267
needs: setup-matrix

0 commit comments

Comments
 (0)