From a552c8f60978a34d58938ead7ca1cd07f35d71f4 Mon Sep 17 00:00:00 2001 From: Hannes Wellmann Date: Sat, 23 Mar 2024 00:21:29 +0100 Subject: [PATCH] Make Microsoft-Defender status read more robust Fixes https://github.com/eclipse-platform/eclipse.platform.ui/issues/1758 --- .../eclipse/ui/internal/WindowsDefenderConfigurator.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WindowsDefenderConfigurator.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WindowsDefenderConfigurator.java index 0c6ca0d1e37..b76d1f77790 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WindowsDefenderConfigurator.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WindowsDefenderConfigurator.java @@ -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; @@ -313,11 +314,11 @@ private static boolean isWindowsDefenderActive(IProgressMonitor monitor) throws try { List 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) {