Skip to content

Commit e36a627

Browse files
committed
Block non-interactive password input. Fixes #518
1 parent 0652cf9 commit e36a627

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

convex-cli/src/main/java/convex/cli/ACommand.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ public String prompt(String message) {
120120
}
121121

122122
public char[] readPassword(String prompt) {
123+
if (!isInteractive()) throw new CLIError("Can't prompt for password in non-interactive mode: "+prompt);
124+
123125
// For some reason using this stops CTRL-C from being subsequently handled :-(
124126
Console c = System.console();
125127
if (c == null) {

convex-cli/src/main/java/convex/cli/Constants.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ public class Constants {
1010

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

13-
public static final String HOSTNAME_PEER = "localhost";
1413

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

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

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

30+
public static final String DEFAULT_PEER_HOSTNAME = "localhost";
31+
32+
3133
public static final int DEFAULT_VERBOSE_LEVEL = 2;
3234

3335
}

convex-cli/src/main/java/convex/cli/mixins/RemotePeerMixin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class RemotePeerMixin extends AMixin {
1919
private Integer port;
2020

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

@@ -30,7 +30,7 @@ public class RemotePeerMixin extends AMixin {
3030
*/
3131
public Convex connect() {
3232
if (port==null) port=convex.core.Constants.DEFAULT_PEER_PORT;
33-
if (hostname==null) hostname=convex.cli.Constants.HOSTNAME_PEER;
33+
if (hostname==null) hostname=convex.cli.Constants.DEFAULT_PEER_HOSTNAME;
3434
InetSocketAddress sa=IPUtils.parseAddress(hostname,port);
3535
try {
3636
Convex c;

0 commit comments

Comments
 (0)