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'" }