From 829deddc1d7690f16d3019fc8ec97aee1c7df464 Mon Sep 17 00:00:00 2001 From: crschnick Date: Mon, 25 Dec 2023 20:09:43 +0000 Subject: [PATCH] Add malwarebytes notice --- .../io/xpipe/app/core/AppSplashScreen.java | 25 -------- .../AppAvBlockCheck.java} | 9 +-- .../app/core/check/AppMalwarebytesCheck.java | 58 +++++++++++++++++++ .../io/xpipe/app/core/check/AppTempCheck.java | 34 +++++++++++ .../AppUserDirectoryCheck.java} | 32 ++-------- .../java/io/xpipe/app/core/mode/BaseMode.java | 5 +- .../io/xpipe/app/core/mode/OperationMode.java | 6 +- app/src/main/java/module-info.java | 1 + .../resources/lang/translations_en.properties | 1 + .../xpipe/app/resources/misc/malwarebytes.md | 12 ++++ 10 files changed, 123 insertions(+), 60 deletions(-) delete mode 100644 app/src/main/java/io/xpipe/app/core/AppSplashScreen.java rename app/src/main/java/io/xpipe/app/core/{AppAntivirusAlert.java => check/AppAvBlockCheck.java} (91%) create mode 100644 app/src/main/java/io/xpipe/app/core/check/AppMalwarebytesCheck.java create mode 100644 app/src/main/java/io/xpipe/app/core/check/AppTempCheck.java rename app/src/main/java/io/xpipe/app/core/{AppChecks.java => check/AppUserDirectoryCheck.java} (51%) create mode 100644 app/src/main/resources/io/xpipe/app/resources/misc/malwarebytes.md diff --git a/app/src/main/java/io/xpipe/app/core/AppSplashScreen.java b/app/src/main/java/io/xpipe/app/core/AppSplashScreen.java deleted file mode 100644 index 1cdf40aab..000000000 --- a/app/src/main/java/io/xpipe/app/core/AppSplashScreen.java +++ /dev/null @@ -1,25 +0,0 @@ -package io.xpipe.app.core; - -import io.xpipe.app.Main; -import javafx.scene.Scene; -import javafx.scene.image.ImageView; -import javafx.scene.layout.Pane; -import javafx.stage.Stage; -import javafx.stage.StageStyle; - -public class AppSplashScreen { - - public static void show() { - var stage = new Stage(); - stage.setWidth(500); - stage.setHeight(500); - stage.setResizable(false); - stage.initStyle(StageStyle.TRANSPARENT); - - var content = new ImageView( - Main.class.getResource("resources/img/loading.gif").toString()); - var scene = new Scene(new Pane(content), -1, -1, false); - stage.setScene(scene); - stage.show(); - } -} diff --git a/app/src/main/java/io/xpipe/app/core/AppAntivirusAlert.java b/app/src/main/java/io/xpipe/app/core/check/AppAvBlockCheck.java similarity index 91% rename from app/src/main/java/io/xpipe/app/core/AppAntivirusAlert.java rename to app/src/main/java/io/xpipe/app/core/check/AppAvBlockCheck.java index 1b2cbbb15..0be41ee9b 100644 --- a/app/src/main/java/io/xpipe/app/core/AppAntivirusAlert.java +++ b/app/src/main/java/io/xpipe/app/core/check/AppAvBlockCheck.java @@ -1,6 +1,7 @@ -package io.xpipe.app.core; +package io.xpipe.app.core.check; import io.xpipe.app.comp.base.MarkdownComp; +import io.xpipe.app.core.*; import io.xpipe.app.core.mode.OperationMode; import io.xpipe.app.util.PlatformState; import io.xpipe.app.util.WindowsRegistry; @@ -13,9 +14,9 @@ import javafx.scene.control.ButtonType; import java.nio.file.Files; import java.util.Optional; -public class AppAntivirusAlert { +public class AppAvBlockCheck { - public static Optional detect() { + private static Optional detect() { var bitdefender = WindowsRegistry.readString(WindowsRegistry.HKEY_LOCAL_MACHINE,"SOFTWARE\\Bitdefender", "InstallDir"); if (bitdefender.isPresent()) { return Optional.of("Bitdefender"); @@ -24,7 +25,7 @@ public class AppAntivirusAlert { return Optional.empty(); } - public static void showIfNeeded() throws Throwable { + public static void check() throws Throwable { // Only show this on first launch on windows if (OsType.getLocal() != OsType.WINDOWS || !AppState.get().isInitialLaunch()) { return; diff --git a/app/src/main/java/io/xpipe/app/core/check/AppMalwarebytesCheck.java b/app/src/main/java/io/xpipe/app/core/check/AppMalwarebytesCheck.java new file mode 100644 index 000000000..664b37a16 --- /dev/null +++ b/app/src/main/java/io/xpipe/app/core/check/AppMalwarebytesCheck.java @@ -0,0 +1,58 @@ +package io.xpipe.app.core.check; + +import io.xpipe.app.comp.base.MarkdownComp; +import io.xpipe.app.core.*; +import io.xpipe.app.util.PlatformState; +import io.xpipe.app.util.WindowsRegistry; +import io.xpipe.core.process.OsType; +import javafx.geometry.Insets; +import javafx.scene.control.Alert; +import javafx.scene.control.ButtonBar; +import javafx.scene.control.ButtonType; + +import java.nio.file.Files; + +public class AppMalwarebytesCheck { + + private static boolean detect() { + var reg = WindowsRegistry.readString(WindowsRegistry.HKEY_LOCAL_MACHINE,"SOFTWARE\\Malwarebytes", "id"); + if (reg.isPresent()) { + return true; + } + + return false; + } + + public static void check() throws Throwable { + // Only show this on first launch on windows + if (OsType.getLocal() != OsType.WINDOWS || AppCache.get("malwarebytesSeen", Boolean.class,() -> false)) { + return; + } + + var found = detect(); + if (!found) { + return; + } + + PlatformState.initPlatformOrThrow(); + AppStyle.init(); + AppImages.init(); + + var a = AppWindowHelper.showBlockingAlert(alert -> { + alert.setTitle(AppI18n.get("malwarebytesNoticeTitle")); + alert.setAlertType(Alert.AlertType.NONE); + AppResources.with( + AppResources.XPIPE_MODULE, + "misc/malwarebytes.md", + file -> { + var markdown = new MarkdownComp(Files.readString(file), s -> s).prefWidth(550).prefHeight(500).createRegion(); + alert.getDialogPane().setContent(markdown); + alert.getDialogPane().setPadding(new Insets(15)); + }); + + alert.getButtonTypes().add(new ButtonType(AppI18n.get("gotIt"), ButtonBar.ButtonData.OK_DONE)); + }); + a.filter(b -> b.getButtonData().isDefaultButton()) + .ifPresentOrElse(buttonType -> {}, () -> AppCache.update("malwarebytesSeen", true)); + } +} diff --git a/app/src/main/java/io/xpipe/app/core/check/AppTempCheck.java b/app/src/main/java/io/xpipe/app/core/check/AppTempCheck.java new file mode 100644 index 000000000..d0b7af27f --- /dev/null +++ b/app/src/main/java/io/xpipe/app/core/check/AppTempCheck.java @@ -0,0 +1,34 @@ +package io.xpipe.app.core.check; + +import io.xpipe.app.issue.ErrorEvent; +import io.xpipe.core.process.OsType; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.InvalidPathException; +import java.nio.file.Path; + +public class AppTempCheck { + + private static void checkTemp(String tmpdir) { + Path dir = null; + try { + dir = Path.of(tmpdir); + } catch (InvalidPathException ignored) { + } + + if (dir == null || !Files.exists(dir) || !Files.isDirectory(dir)) { + ErrorEvent.fromThrowable( + new IOException("Specified temporary directory " + tmpdir + ", set via the environment variable %TEMP% is invalid.")) + .term() + .handle(); + } + } + + public static void check() { + if (OsType.getLocal().equals(OsType.WINDOWS)) { + checkTemp(System.getProperty("java.io.tmpdir")); + checkTemp(System.getenv("TEMP")); + } + } +} diff --git a/app/src/main/java/io/xpipe/app/core/AppChecks.java b/app/src/main/java/io/xpipe/app/core/check/AppUserDirectoryCheck.java similarity index 51% rename from app/src/main/java/io/xpipe/app/core/AppChecks.java rename to app/src/main/java/io/xpipe/app/core/check/AppUserDirectoryCheck.java index 2712b1b0e..e8348d552 100644 --- a/app/src/main/java/io/xpipe/app/core/AppChecks.java +++ b/app/src/main/java/io/xpipe/app/core/check/AppUserDirectoryCheck.java @@ -1,16 +1,14 @@ -package io.xpipe.app.core; +package io.xpipe.app.core.check; +import io.xpipe.app.core.AppProperties; import io.xpipe.app.issue.ErrorEvent; -import io.xpipe.core.process.OsType; import java.io.IOException; import java.nio.file.Files; -import java.nio.file.InvalidPathException; -import java.nio.file.Path; -public class AppChecks { +public class AppUserDirectoryCheck { - public static void checkDirectoryPermissions() { + public static void check() { var dataDirectory = AppProperties.get().getDataDir(); try { @@ -29,26 +27,4 @@ public class AppChecks { .handle(); } } - - private static void checkTemp(String tmpdir) { - Path dir = null; - try { - dir = Path.of(tmpdir); - } catch (InvalidPathException ignored) { - } - - if (dir == null || !Files.exists(dir) || !Files.isDirectory(dir)) { - ErrorEvent.fromThrowable( - new IOException("Specified temporary directory " + tmpdir + ", set via the environment variable %TEMP% is invalid.")) - .term() - .handle(); - } - } - - public static void checkTemp() { - if (OsType.getLocal().equals(OsType.WINDOWS)) { - checkTemp(System.getProperty("java.io.tmpdir")); - checkTemp(System.getenv("TEMP")); - } - } } diff --git a/app/src/main/java/io/xpipe/app/core/mode/BaseMode.java b/app/src/main/java/io/xpipe/app/core/mode/BaseMode.java index e81dae0cd..a9aeb4694 100644 --- a/app/src/main/java/io/xpipe/app/core/mode/BaseMode.java +++ b/app/src/main/java/io/xpipe/app/core/mode/BaseMode.java @@ -3,6 +3,8 @@ package io.xpipe.app.core.mode; import io.xpipe.app.browser.BrowserModel; import io.xpipe.app.comp.store.StoreViewState; import io.xpipe.app.core.*; +import io.xpipe.app.core.check.AppAvBlockCheck; +import io.xpipe.app.core.check.AppMalwarebytesCheck; import io.xpipe.app.ext.ActionProvider; import io.xpipe.app.issue.TrackEvent; import io.xpipe.app.prefs.AppPrefs; @@ -47,7 +49,8 @@ public class BaseMode extends OperationMode { // Also loaded before antivirus alert to localize that AppI18n.init(); LicenseProvider.get().init(); - AppAntivirusAlert.showIfNeeded(); + AppAvBlockCheck.check(); + AppMalwarebytesCheck.check(); LocalShell.init(); XPipeDistributionType.init(); AppPrefs.init(); diff --git a/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java b/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java index 86059e111..98e8e18b7 100644 --- a/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java +++ b/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java @@ -1,6 +1,8 @@ package io.xpipe.app.core.mode; import io.xpipe.app.core.*; +import io.xpipe.app.core.check.AppTempCheck; +import io.xpipe.app.core.check.AppUserDirectoryCheck; import io.xpipe.app.ext.DataStoreProviders; import io.xpipe.app.issue.*; import io.xpipe.app.launcher.LauncherCommand; @@ -95,8 +97,8 @@ public abstract class OperationMode { AppProperties.init(); AppState.init(); XPipeSession.init(AppProperties.get().getBuildUuid()); - AppChecks.checkDirectoryPermissions(); - AppChecks.checkTemp(); + AppUserDirectoryCheck.check(); + AppTempCheck.check(); AppLogs.init(); AppProperties.logArguments(args); AppProperties.logSystemProperties(); diff --git a/app/src/main/java/module-info.java b/app/src/main/java/module-info.java index 8c0d9e470..c44e94fb7 100644 --- a/app/src/main/java/module-info.java +++ b/app/src/main/java/module-info.java @@ -37,6 +37,7 @@ open module io.xpipe.app { exports io.xpipe.app.browser.action; exports io.xpipe.app.browser; exports io.xpipe.app.browser.icon; + exports io.xpipe.app.core.check; requires com.sun.jna; requires com.sun.jna.platform; diff --git a/app/src/main/resources/io/xpipe/app/resources/lang/translations_en.properties b/app/src/main/resources/io/xpipe/app/resources/lang/translations_en.properties index 69277b66f..f8f984cf1 100644 --- a/app/src/main/resources/io/xpipe/app/resources/lang/translations_en.properties +++ b/app/src/main/resources/io/xpipe/app/resources/lang/translations_en.properties @@ -233,6 +233,7 @@ confirm=Confirm print=Print whatsNew=What's new in version $VERSION$? antivirusNoticeTitle=A note on Antivirus programs +malwarebytesNoticeTitle=A note on Malwarebytes updateChangelogAlertTitle=Changelog greetingsAlertTitle=Welcome to XPipe gotIt=Got It diff --git a/app/src/main/resources/io/xpipe/app/resources/misc/malwarebytes.md b/app/src/main/resources/io/xpipe/app/resources/misc/malwarebytes.md new file mode 100644 index 000000000..d2911054f --- /dev/null +++ b/app/src/main/resources/io/xpipe/app/resources/misc/malwarebytes.md @@ -0,0 +1,12 @@ +### Information about Malwarebytes + +XPipe detected that you are running Malwarebytes. Certain protection settings in Malwarebytes Professional slow down XPipe massively to the point where it's basically unusable. +If you are running the paid Malwarebytes Professional version, you will have access to the `Exploit Protection` under the `Real-time Protection` mode. When this setting is active, any shell access is slowed down, resulting in XPipe becoming very slow. + +### What you can do + +In case you are facing performance problems with XPipe, it is recommended to try to disable the `Exploit Protection` setting for XPipe and see whether it makes a difference. + +### Security information + +You can find detailed information about the security model of XPipe at [https://docs.xpipe.io/security](https://docs.xpipe.io/security). From there you should be able to get a more accurate overview over the threat level of XPipe to you. \ No newline at end of file