From 8da34c670a5670fb4fd9785a8c1733b7c272b403 Mon Sep 17 00:00:00 2001 From: crschnick Date: Thu, 20 Apr 2023 14:17:39 +0000 Subject: [PATCH] Add support for message formatting in process control --- SECURITY.md | 4 ++++ .../main/java/io/xpipe/app/util/LockChangeAlert.java | 11 ++++++++++- .../java/io/xpipe/core/process/CommandControl.java | 3 +++ .../main/java/io/xpipe/core/process/ShellControl.java | 2 ++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/SECURITY.md b/SECURITY.md index 0ebfbbd1..a12d8896 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1,5 +1,9 @@ # Security +Due to its nature, X-Pipe has to handle a lot of sensitive information. +This can range from passwords for all kinds of servers, to SSH keys, and more. +Therefore, you should definitely be interested in the security model of X-Pipe. + This document summarizes the approach of X-Pipe when it comes to the security of your sensitive information. If any of your questions are left unanswered by this document, feel free to file an issue report so your question can be answered individually and can also potentially be included in this document. diff --git a/app/src/main/java/io/xpipe/app/util/LockChangeAlert.java b/app/src/main/java/io/xpipe/app/util/LockChangeAlert.java index 29bba45b..1c83613e 100644 --- a/app/src/main/java/io/xpipe/app/util/LockChangeAlert.java +++ b/app/src/main/java/io/xpipe/app/util/LockChangeAlert.java @@ -7,10 +7,14 @@ import io.xpipe.app.fxcomps.impl.LabelComp; import io.xpipe.app.fxcomps.impl.SecretFieldComp; import io.xpipe.app.prefs.AppPrefs; import io.xpipe.core.util.SecretValue; +import javafx.beans.binding.Bindings; import javafx.beans.property.SimpleObjectProperty; import javafx.scene.control.Alert; +import javafx.scene.control.ButtonType; import javafx.scene.layout.VBox; +import java.util.Objects; + public class LockChangeAlert { public static void show() { @@ -42,8 +46,13 @@ public class LockChangeAlert { var content = new VBox(label1, p1, new Spacer(15), label2, p2); content.setSpacing(5); alert.getDialogPane().setContent(content); + + var button = alert.getDialogPane().lookupButton(ButtonType.OK); + button.disableProperty().bind(Bindings.createBooleanBinding(() -> { + return !Objects.equals(prop1.getValue(), prop2.getValue()); + }, prop1, prop2)); }) - .filter(b -> b.getButtonData().isDefaultButton() && ((prop1.getValue() != null && prop2.getValue() != null && prop1.getValue().equals(prop2.getValue())) || (prop1.getValue() == null && prop2.getValue() == null))) + .filter(b -> b.getButtonData().isDefaultButton()) .ifPresent(t -> { AppPrefs.get().changeLock(prop1.getValue()); }); diff --git a/core/src/main/java/io/xpipe/core/process/CommandControl.java b/core/src/main/java/io/xpipe/core/process/CommandControl.java index de84debc..51df8207 100644 --- a/core/src/main/java/io/xpipe/core/process/CommandControl.java +++ b/core/src/main/java/io/xpipe/core/process/CommandControl.java @@ -8,6 +8,7 @@ import java.io.InputStreamReader; import java.io.OutputStream; import java.nio.charset.Charset; import java.util.function.Consumer; +import java.util.function.Function; public interface CommandControl extends ProcessControl { @@ -20,6 +21,8 @@ public interface CommandControl extends ProcessControl { CLOSE } + CommandControl withMessageFormatter(Function formatter); + CommandControl terminalExitMode(TerminalExitMode mode); public CommandControl doesNotObeyReturnValueConvention(); diff --git a/core/src/main/java/io/xpipe/core/process/ShellControl.java b/core/src/main/java/io/xpipe/core/process/ShellControl.java index e5a72c28..caf278d3 100644 --- a/core/src/main/java/io/xpipe/core/process/ShellControl.java +++ b/core/src/main/java/io/xpipe/core/process/ShellControl.java @@ -19,6 +19,8 @@ public interface ShellControl extends ProcessControl { ShellControl onExit(Consumer pc); + ShellControl withMessageFormatter(Function formatter); + String prepareTerminalOpen() throws Exception; String prepareIntermediateTerminalOpen(String content) throws Exception;