Detect insufficient permissions when checking Windows Defender status (IDEA-247817)
authorDmitry Jemerov <yole@jetbrains.com>
Thu, 13 Aug 2020 14:10:40 +0000 (16:10 +0200)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Thu, 13 Aug 2020 14:14:10 +0000 (14:14 +0000)
GitOrigin-RevId: b98ba6f64bad8e8bef9fa582c5077b354936ff7f

platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderChecker.java

index aebdd7934893435e2f8f219b4141636e8213958f..90810fe8bde9f3f01171d0812895d676265d5bec 100644 (file)
@@ -97,6 +97,10 @@ public class WindowsDefenderChecker {
         }
         return new CheckResult(scanningStatus, pathStatuses);
       }
+      else {
+        LOG.info("Windows Defender status: Failed to get excluded patterns");
+        return new CheckResult(RealtimeScanningStatus.ERROR, Collections.emptyMap());
+      }
     }
     if (scanningStatus == RealtimeScanningStatus.ERROR) {
       LOG.info("Windows Defender status: failed to detect");
@@ -170,6 +174,13 @@ public class WindowsDefenderChecker {
   private static List<Pattern> getExcludedPatterns() {
     final Collection<String> paths = getWindowsDefenderProperty("ExclusionPath");
     if (paths == null) return null;
+    if (paths.size() > 0) {
+      String path = paths.iterator().next();
+      if (path.length() > 0 && path.indexOf('\\') < 0) {
+        // "N/A: Must be admin to view exclusions"
+        return null;
+      }
+    }
     return ContainerUtil.map(paths, path -> wildcardsToRegex(expandEnvVars(path)));
   }