Files
Reims-Go/internal/host/defender.go

24 lines
790 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package host
import "strings"
func DefenderExclusionCommand(dataRoot string) string {
var b strings.Builder
b.Grow(len(dataRoot))
for _, r := range dataRoot {
// Strip ASCII control chars and Unicode line/paragraph separators so
// copied PowerShell commands can never break out onto a second line.
if r < 0x20 || r == 0x7f || r == '\u0085' || r == '\u2028' || r == '\u2029' {
continue
}
b.WriteRune(r)
}
path := strings.TrimSpace(b.String())
if path == "" {
return ""
}
// PowerShell also recognizes typographic single quotes as delimiters.
path = strings.NewReplacer("'", "''", "‘", "‘‘", "’", "’’", "‚", "‚‚", "‛", "‛‛").Replace(path)
return "Add-MpPreference -ExclusionPath '" + path + "' -ExclusionProcess 'qemu-system-x86_64.exe'"
}