Skip to content

Commit

Permalink
Block non-interactive password input. Fixes #518
Browse files Browse the repository at this point in the history
  • Loading branch information
mikera committed Dec 12, 2024
1 parent 0652cf9 commit e36a627
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions convex-cli/src/main/java/convex/cli/ACommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ public String prompt(String message) {
}

public char[] readPassword(String prompt) {
if (!isInteractive()) throw new CLIError("Can't prompt for password in non-interactive mode: "+prompt);

// For some reason using this stops CTRL-C from being subsequently handled :-(
Console c = System.console();
if (c == null) {
Expand Down
4 changes: 3 additions & 1 deletion convex-cli/src/main/java/convex/cli/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public class Constants {

public static final String HOSTNAME_REMOTE = "convex.world";

public static final String HOSTNAME_PEER = "localhost";

public static final String KEYSTORE_FILENAME = convex.core.Constants.DEFAULT_KEYSTORE_FILENAME;

Expand All @@ -28,6 +27,9 @@ public class Constants {

public static final int DEFAULT_PEER_PORT = convex.core.Constants.DEFAULT_PEER_PORT;

public static final String DEFAULT_PEER_HOSTNAME = "localhost";


public static final int DEFAULT_VERBOSE_LEVEL = 2;

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class RemotePeerMixin extends AMixin {
private Integer port;

@Option(names={"--host"},
defaultValue="${env:CONVEX_HOST:-"+Constants.HOSTNAME_PEER+"}",
defaultValue="${env:CONVEX_HOST:-"+Constants.DEFAULT_PEER_HOSTNAME+"}",
description="Hostname for remote peer connection. Can specify with CONVEX_HOST. Defaulting to: ${DEFAULT-VALUE}")
private String hostname;

Expand All @@ -30,7 +30,7 @@ public class RemotePeerMixin extends AMixin {
*/
public Convex connect() {
if (port==null) port=convex.core.Constants.DEFAULT_PEER_PORT;
if (hostname==null) hostname=convex.cli.Constants.HOSTNAME_PEER;
if (hostname==null) hostname=convex.cli.Constants.DEFAULT_PEER_HOSTNAME;
InetSocketAddress sa=IPUtils.parseAddress(hostname,port);
try {
Convex c;
Expand Down

0 comments on commit e36a627

Please sign in to comment.