Commit 9d1ae4e
fix(install): detect Windows Defender AV block and emit specific guidance (#1408)
* fix(install): detect Windows Defender AV block and emit specific guidance
The Windows installer (and 'apm self-update') failed on hosts where
Defender or another real-time scanner flags the unsigned PyInstaller
apm.exe as potentially unwanted software (HRESULT 0x800700E1). The
binary smoke test threw 'Operation did not complete successfully
because the file contains a virus or potentially unwanted software',
which Test-AccessDeniedError did not match, so the installer fell
through to a generic 'failed to run' message and a pip fallback that
itself died on hosts running an unsupported Python (e.g. 3.14).
Changes:
- install.ps1: add Test-AntivirusBlockError mirroring the existing
Test-AccessDeniedError contract. Matches the Defender PUA message,
the generic 'contains a virus' / 'potentially unwanted software'
phrasing, and HRESULTs 0x800700E1 and 0x800704EC.
- install.ps1: add Write-AntivirusGuidance with three actionable
options - Add-MpPreference -ExclusionPath on the install root,
pip --user fallback, and the Microsoft false-positive submission
URL. Wired into the testFailure branch ahead of the AppLocker
guidance check; the two error classes are distinct.
- docs/installation.md: add a troubleshooting subsection mirroring
the existing AppLocker/WDAC one, documenting the same three
recovery options.
- scripts/windows/test-install-script.ps1: add Test-AntivirusDetector
covering real Defender output, generic PUA text, both HRESULTs, the
cross-class case (access-denied must not be classified as AV), and
empty/benign strings. Cases verified locally against the install.ps1
functions.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fixup(windows-installer): correct AV vs policy HRESULT classification
Address review feedback on PR #1408:
1. CRITICAL: 0x800704EC is ERROR_ACCESS_DISABLED_BY_POLICY (GPO/SRP),
NOT ERROR_VIRUS_DELETED. The correct deleted-by-AV HRESULT is
0x800700E2. Misclassifying a policy block as AV would prompt users
to add a Defender exclusion to fix what is actually a Group Policy
rule -- net regression vs pre-PR generic handler.
- Test-AntivirusBlockError: drop 0x800704EC, add 0x800700E2.
- Test-AccessDeniedError: add 0x800704EC and the standard SRP/GPO
'blocked by group policy' message string. These belong in the
AppControl/AppLocker guidance bucket.
2. Soften 'not actually malicious' framing. In a real supply-chain
compromise this code path would still fire; an unconditional safety
claim is poor security hygiene. Reword conditionally and tell users
to verify the published .sha256 sidecar BEFORE excluding the binary.
3. Single-quote-escape $TargetInstallDir in the printed
Add-MpPreference command so the suggestion stays valid for paths
containing a single quote.
4. Stop leaking GetTempFileName() zero-byte companions in the test
harness. Use GetRandomFileName under $env:TEMP for both .ps1 temp
files in scripts/windows/test-install-script.ps1.
5. Replace brittle 'Select-Object -Last 1' JSON parsing with explicit
---APM-JSON-BEGIN---/---APM-JSON-END--- sentinels so child-pwsh
profile output cannot corrupt the parsed JSON.
6. Expand Test-AntivirusDetector cases to cover both corrected AV
HRESULTs (0x800700E1, 0x800700E2) and the GPO/SRP cross-class
disambiguation (0x800704EC must route to AccessDenied, not AV).
Validated locally with pwsh: 9/9 cross-class detector cases pass.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Daniel Meppiel <copilot-rework@github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent d1b64f8 commit 9d1ae4e
2 files changed
Lines changed: 160 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
278 | | - | |
279 | | - | |
280 | | - | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
281 | 285 | | |
282 | 286 | | |
283 | | - | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
284 | 311 | | |
285 | 312 | | |
286 | 313 | | |
| |||
309 | 336 | | |
310 | 337 | | |
311 | 338 | | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
312 | 377 | | |
313 | 378 | | |
314 | 379 | | |
| |||
645 | 710 | | |
646 | 711 | | |
647 | 712 | | |
| 713 | + | |
648 | 714 | | |
649 | | - | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
650 | 718 | | |
651 | 719 | | |
652 | 720 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
148 | 233 | | |
149 | 234 | | |
150 | 235 | | |
| |||
392 | 477 | | |
393 | 478 | | |
394 | 479 | | |
| 480 | + | |
395 | 481 | | |
396 | 482 | | |
397 | 483 | | |
| |||
0 commit comments