Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Microsoft-Defender status read more robust #1771

Merged
merged 1 commit into from Mar 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -23,6 +23,7 @@
import java.nio.file.Path;
import java.util.Base64;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
Expand Down Expand Up @@ -313,11 +314,11 @@ private static boolean isWindowsDefenderActive(IProgressMonitor monitor) throws
try {
List<String> lines = runProcess(command, monitor);
String onlyLine = lines.size() == 1 ? lines.get(0) : ""; //$NON-NLS-1$
return switch (onlyLine) {
return switch (onlyLine.toLowerCase(Locale.ENGLISH)) {
// Known values as listed in
// https://learn.microsoft.com/en-us/microsoft-365/security/defender-endpoint/microsoft-defender-antivirus-windows#use-powershell-to-check-the-status-of-microsoft-defender-antivirus
case "SxS Passive Mode", "Passive mode" -> false; //$NON-NLS-1$ //$NON-NLS-2$
case "Normal", "EDR Block Mode" -> true; //$NON-NLS-1$//$NON-NLS-2$
case "sxs passive mode", "passive mode" -> false; //$NON-NLS-1$ //$NON-NLS-2$
case "normal", "edr block mode" -> true; //$NON-NLS-1$//$NON-NLS-2$
default -> throw new IOException("Process terminated with unexpected result:\n" + String.join("\n", lines)); //$NON-NLS-1$//$NON-NLS-2$
};
} catch (IOException e) {
Expand Down