Skip to content

Commit 30045dc

Browse files
committed
Merge branch 'master' of github.com:gchq/stroom
2 parents a6d42d6 + 06c56e6 commit 30045dc

3 files changed

Lines changed: 87 additions & 9 deletions

File tree

stroom-app/src/main/java/stroom/app/commands/AbstractStroomBaseCommand.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ protected void run(final Bootstrap<Config> bootstrap,
9191
runCommand(bootstrap, namespace, config, childInjector);
9292
} catch (final Exception e) {
9393
final String msg = "Error running command "
94-
+ commandName
95-
+ ": " + e.getMessage()
96-
+ ". Check logs for more detail.";
94+
+ commandName
95+
+ ": " + e.getMessage()
96+
+ ". Check logs for more detail.";
9797
error(LOGGER, msg, e);
9898
System.exit(1);
9999
}
@@ -243,19 +243,29 @@ protected String argsToString(final Namespace namespace) {
243243
})
244244
.sorted(Entry.comparingByKey())
245245
.map(entry ->
246-
"--" + entry.getKey() + " " + argValueToString(entry.getValue()))
246+
"--" + entry.getKey() + " " + argValueToString(entry.getKey(), entry.getValue()))
247247
.collect(Collectors.joining(" "));
248248
}
249249
}
250250

251-
final String argValueToString(final Object value) {
251+
protected String obfuscateArgValue(final String argName, final String value) {
252+
if ("password".equals(argName)) {
253+
return "*****";
254+
} else {
255+
return value;
256+
}
257+
}
258+
259+
final String argValueToString(final String argName, final Object value) {
260+
final String str;
252261
if (value instanceof final List<?> listVal) {
253-
return listVal.stream()
262+
str = listVal.stream()
254263
.map(item -> "'" + item.toString() + "'")
255264
.collect(Collectors.joining(" "));
256265
} else {
257-
return value.toString();
266+
str = value.toString();
258267
}
268+
return obfuscateArgValue(argName, str);
259269
}
260270

261271
/**

stroom-app/src/main/java/stroom/app/commands/ResetPasswordCommand.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import stroom.security.api.SecurityContext;
2222
import stroom.security.identity.account.AccountDao;
2323
import stroom.util.logging.LogUtil;
24+
import stroom.util.shared.NullSafe;
2425

2526
import com.google.inject.Injector;
2627
import event.logging.AuthenticateAction;
@@ -47,7 +48,7 @@ public class ResetPasswordCommand extends AbstractStroomAppCommand {
4748

4849
private static final String COMMAND_NAME = "reset_password";
4950
private static final String COMMAND_DESCRIPTION = "Reset the password of the user account " +
50-
"in the internal identity provider";
51+
"in the internal identity provider";
5152

5253
private static final String USERNAME_ARG_NAME = "user";
5354
private static final String PASSWORD_ARG_NAME = "password";
@@ -97,9 +98,15 @@ protected void runSecuredCommand(final Bootstrap<Config> bootstrap,
9798
final Namespace namespace,
9899
final Config config,
99100
final Injector injector) {
100-
101101
final String username = namespace.getString(USERNAME_ARG_NAME);
102+
if (NullSafe.isEmptyString(username)) {
103+
throw new RuntimeException("Username must be provided");
104+
}
105+
102106
final String newPassword = namespace.getString(PASSWORD_ARG_NAME);
107+
if (NullSafe.isEmptyString(newPassword)) {
108+
throw new RuntimeException("Password must be provided");
109+
}
103110

104111
LOGGER.debug("Resetting password for account {}", username);
105112

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
* Bug : Fix missing arg validation on reset_password CLI command. Obfuscate password in logging.
2+
3+
4+
```sh
5+
# ONLY the top line will be included as a change entry in the CHANGELOG.
6+
# The entry should be in GitHub flavour markdown and should be written on a SINGLE
7+
# line with no hard breaks. You can have multiple change files for a single GitHub issue.
8+
# The entry should be written in the imperative mood, i.e. 'Fix nasty bug' rather than
9+
# 'Fixed nasty bug'.
10+
#
11+
# Examples of acceptable entries are:
12+
#
13+
#
14+
# * Bug **#123** : Fix bug with an associated GitHub issue in this repository.
15+
#
16+
# * Bug **namespace/other-repo#456** : Fix bug with an associated GitHub issue in another repository.
17+
#
18+
# * Feature **#789** : Add new feature X.
19+
#
20+
# * Bug : Fix bug with no associated GitHub issue.
21+
#
22+
#
23+
# Note: The line must start '* XXX ', where 'XXX' is a valid category,
24+
# one of [Bug Feature Refactor Dependency Build].
25+
26+
27+
# --------------------------------------------------------------------------------
28+
# The following is random text to make this file unique for git's change detection
29+
# Mgi76uWLK90Kf5W9qyaYs3OPTPKuI3f08Gscby9bmOGVxDUauvo9SxoXwIJkOwoTXCTZZos1wEfPZUdD
30+
# e3rCfe9XqSdcB4h2iDXcnm7R9Sdj3aWbebZM5D6nUbVAGMCMjGdMznVIjcBMJHl0ebD5ViJzqt3vueHP
31+
# s0xSRUVl5edfRioK23FDDh9iYTmCUQ7tslBq7fbyrUsGuzYNQysXO8lssQf3M4ajNXK4mnSDc9XLaa6i
32+
# ZgVNsxRo8NStOgsXOGtlsxO3lQPiKLogaUYSukgHBq9OJjnKq0mzEUyN8CjIVko4cQwflYYqzYqRpfGR
33+
# vayc7lixUaMDcMvMbGcHmsnEzekQ3TD7IjllORLn87txXzSSE4ROPpRvRdUWA6g2WpsCFVcXUTyjgEqr
34+
# t2Kd8yrhnIZmKFZqyvJliGKqyPm7zETmA8ZEepz39mZm2RQo0RvPUBCLLQNSFe2OKznI2s2SxSd9WA7A
35+
# bLyPzZXurKmIr98cSLxS5oMdP8NkFCax9GF6WiTBzz87qg3K0aaS832NrX7iNfY3slJzv12DBJzS6uIA
36+
# nGbNXIYpooPKlHunMsgFQPLdOWKD5G5EwhaBS1JgUJsdpgZ6GgpFSmTxqpqcivKAOGkf0p2kBYLZHO40
37+
# Wd6Pk19D74LDJZVyFOUxUuFMxZ6C39vawBWxcOUbThVnlQOXaABNXBGq7KQiDyZcOK1kBbRs16PdveNX
38+
# 9l9XsAaW84mBUax4FfPI1GLNzXdSvBrzehvOJUiDtlTSxq8AOKLaaT1Lv6SbAtfPwZODQiKfrFpqYHRB
39+
# g37oKTXyOtWKLOFUN3Zh9EaXmlslRuUDQOnlvP0Q3pWZV5WQ5dcoiik2OAPVIrogE5POj4CKgkpkPKFv
40+
# JhfrVtiqFRTiKsR2mhl5uT3y3h1uRQ9IHWgob5ThCndiUUzimkkhBxXos63CkljGOVqo0f72SJSfjApu
41+
# 4S0BzqdyWK7kojtfyfHoTHRVwL2YnelAqTia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fp4Nnrrl9ROL5ZM5dTOCA1ryW4iNNnnx9otVS9tB8XQdtQg9cxmI8mArXjvRC7MvDsikHw1KSG9
55+
# aFf0CCoLtpow71IUyaBg6XDxfKDYAXWsuky0nVtbwXEGSAXJBmXaKEqAihv0WAvlDjxzRuA7FUJPbnFT
56+
# fkjqzdEKjvwrBx55UlDCCZdfPn5rkCxf12sN2e2m0WiWlMyzmhJVQjKExItjSSNt0ugeAXxvZjbUb38S
57+
# Pj5KQ46VuaRHftBGYKgIbG0dyznPLS2RmgnhcUxiZfhgylGEDUXHkIKATWAQgnYebfzK6tmXZFBJHGUN
58+
# bxZkqvfRu1l6h95VxgjBKwJryNHwwMWl6uNC0vsXnTFUq5EYGGPy0jq32Hvl4ZjLfQYLchHw3qEk3YY7
59+
# --------------------------------------------------------------------------------
60+
61+
```

0 commit comments

Comments
 (0)