@@ -21,10 +21,22 @@ type WindowsRunner struct{}
21
21
22
22
// Prepare the test
23
23
func (WindowsRunner ) Prepare (ctx context.Context , sshClient SSHClient , logger Logger , arch string , goVersion string ) error {
24
+ // Adding the user directory as an exception to Windows Defender, so it does not detect
25
+ // temporary mage binaries as malware.
26
+ //
27
+ // https://github.com/elastic/elastic-agent/issues/4355
28
+ // https://learn.microsoft.com/en-us/powershell/module/defender/set-mppreference?view=windowsserver2022-ps
29
+ logger .Logf ("Adding exception in Windows Defender..." )
30
+ defenderException := `Set-MpPreference -Force -ExclusionPath $env:USERPROFILE`
31
+ stdOut , errOut , err := sshRunPowershell (ctx , sshClient , defenderException )
32
+ if err != nil {
33
+ return fmt .Errorf ("failed to add exception in Windows Defender: %w (stdout: %s, stderr: %s)" , err , stdOut , errOut )
34
+ }
35
+
24
36
// install chocolatey
25
37
logger .Logf ("Installing chocolatey" )
26
38
chocoInstall := `"[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))"`
27
- stdOut , errOut , err : = sshRunPowershell (ctx , sshClient , chocoInstall )
39
+ stdOut , errOut , err = sshRunPowershell (ctx , sshClient , chocoInstall )
28
40
if err != nil {
29
41
return fmt .Errorf ("failed to install chocolatey: %w (stdout: %s, stderr: %s)" , err , stdOut , errOut )
30
42
}
0 commit comments