Skip to content

Commit

Permalink
GG-20639 control.sh shows passwords in the output
Browse files Browse the repository at this point in the history
(cherry picked from commit 483d046)

(cherry picked from commit f3a762d)
(cherry picked from commit 4fddf21)

# Conflicts:
#	modules/core/src/main/java/org/apache/ignite/internal/commandline/CommandHandler.java
  • Loading branch information
ibelyakov committed Jul 25, 2019
1 parent 6864d2c commit 40c4bc3
Show file tree
Hide file tree
Showing 18 changed files with 122 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ public default void parseArguments(CommandArgIterator argIterator) {
*/
public void printUsage(Logger logger);

/**
* @return String which reflect of command-specific arguments in human-friendly format.
*/
public default String argumentString() {
return arg() == null? "" : arg().toString();
}

/**
* @return command name.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,11 @@ public int execute(List<String> rawArgs) {

try {
logger.info("Command [" + commandName + "] started");
logger.info("Arguments: " + String.join(" ", rawArgs));
logger.info("Common arguments: " + args.toString());

if (command.arg() != null)
logger.info("Command arguments: " + command.argumentString());

logger.info(DELIM);
lastOperationRes = command.execute(clientCfg, logger);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
package org.apache.ignite.internal.commandline;

import org.apache.ignite.internal.client.GridClientConfiguration;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.internal.S;

/**
* Container with common parsed and validated arguments.
Expand All @@ -33,6 +35,7 @@ public class ConnectionAndSslParameters {
private String user;

/** Password. */
@GridToStringExclude
private String pwd;

/** Force option is used for auto confirmation. */
Expand Down Expand Up @@ -60,6 +63,7 @@ public class ConnectionAndSslParameters {
private String sslKeyStoreType;

/** Keystore Password. */
@GridToStringExclude
private char[] sslKeyStorePassword;

/** Truststore. */
Expand All @@ -69,6 +73,7 @@ public class ConnectionAndSslParameters {
private String sslTrustStoreType;

/** Truststore Password. */
@GridToStringExclude
private char[] sslTrustStorePassword;

/** High-level command. */
Expand Down Expand Up @@ -259,4 +264,13 @@ public String sslTrustStoreType() {
public char[] sslTrustStorePassword() {
return sslTrustStorePassword;
}

/** {@inheritDoc} */
@Override public String toString() {
return S.toString(ConnectionAndSslParameters.class, this,
"password", pwd == null ? null : "*****",
"sslKeyStorePassword", sslKeyStorePassword == null ? null: "*****",
"sslTrustStorePassword", sslTrustStorePassword == null? null: "*****"
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ public class WalCommands implements Command<T2<String, String>> {
return new T2<>(walAct, walArgs);
}

/** {@inheritDoc} */
@Override public String argumentString() {
return "walAction=" + walAct + ", walArgs=" + walArgs;
}

/**
* Execute delete unused WAL segments task.
* @param client Client.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
package org.apache.ignite.internal.commandline.baseline;

import java.util.List;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;

/**
* This class contains all possible arguments after parsing baseline command input.
Expand All @@ -38,6 +40,7 @@ public class BaselineArguments {
/** Requested topology version. */
private long topVer = -1;
/** List of consistent ids for operation. */
@GridToStringInclude
List<String> consistentIds;

/**
Expand Down Expand Up @@ -92,6 +95,11 @@ public List<String> getConsistentIds() {
return consistentIds;
}

/** {@inheritDoc} */
@Override public String toString() {
return S.toString(BaselineArguments.class, this);
}

/**
* Builder of {@link BaselineArguments}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ private static String extendToLen(String s, int targetLen) {
return subcommand;
}

/** {@inheritDoc} */
@Override public String argumentString() {
return "cacheSubcommand=" + subcommand.name() +
(subcommand.subcommand() == null ? "" : ", " + subcommand.subcommand().argumentString());
}

/** {@inheritDoc} */
@Override public String name() {
return CACHE.toCommandName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.ignite.internal.commandline.CommandArgIterator;
import org.apache.ignite.internal.commandline.CommandLogger;
import org.apache.ignite.internal.processors.cache.verify.ContentionInfo;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.visor.verify.VisorContentionTask;
import org.apache.ignite.internal.visor.verify.VisorContentionTaskArg;
import org.apache.ignite.internal.visor.verify.VisorContentionTaskResult;
Expand Down Expand Up @@ -93,6 +94,11 @@ public int minQueueSize() {
public int maxPrint() {
return maxPrint;
}

/** {@inheritDoc} */
@Override public String toString() {
return S.toString(Arguments.class, this);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.ignite.internal.commandline.cache.distribution.CacheDistributionTask;
import org.apache.ignite.internal.commandline.cache.distribution.CacheDistributionTaskArg;
import org.apache.ignite.internal.commandline.cache.distribution.CacheDistributionTaskResult;
import org.apache.ignite.internal.util.typedef.internal.S;

import static org.apache.ignite.internal.commandline.CommandHandler.NULL;
import static org.apache.ignite.internal.commandline.CommandLogger.optional;
Expand Down Expand Up @@ -102,6 +103,11 @@ public UUID nodeId() {
public Set<String> getUserAttributes() {
return userAttributes;
}

/** {@inheritDoc} */
@Override public String toString() {
return S.toString(Arguments.class, this);
}
}

/** Command parsed arguments */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.ignite.internal.commandline.cache.argument.ValidateIndexesCommandArg;
import org.apache.ignite.internal.processors.cache.verify.PartitionKey;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.internal.visor.verify.IndexIntegrityCheckIssue;
import org.apache.ignite.internal.visor.verify.IndexValidationIssue;
Expand Down Expand Up @@ -137,6 +138,11 @@ public int checkThrough() {
public UUID nodeId() {
return nodeId;
}

/** {@inheritDoc} */
@Override public String toString() {
return S.toString(Arguments.class, this);
}
}

/** Command parsed arguments. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.ignite.internal.commandline.argument.CommandArgUtils;
import org.apache.ignite.internal.commandline.cache.argument.ListCommandArg;
import org.apache.ignite.internal.processors.cache.verify.CacheInfo;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.SB;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.internal.visor.cache.VisorCacheAffinityConfiguration;
Expand Down Expand Up @@ -149,6 +150,11 @@ public VisorViewCacheCmd cacheCommand() {
* @return Full config flag.
*/
public boolean fullConfig(){ return fullConfig; }

/** {@inheritDoc} */
@Override public String toString() {
return S.toString(Arguments.class, this);
}
}

/** Command parsed arguments */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.ignite.internal.commandline.CommandLogger;
import org.apache.ignite.internal.commandline.argument.CommandArgUtils;
import org.apache.ignite.internal.commandline.cache.argument.FindAndDeleteGarbageArg;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.visor.cache.VisorFindAndDeleteGarbageInPersistenceJobResult;
import org.apache.ignite.internal.visor.cache.VisorFindAndDeleteGarbageInPersistenceTask;
import org.apache.ignite.internal.visor.cache.VisorFindAndDeleteGarbageInPersistenceTaskArg;
Expand Down Expand Up @@ -100,6 +101,11 @@ public Set<String> groups() {
public boolean delete() {
return delete;
}

/** {@inheritDoc} */
@Override public String toString() {
return S.toString(Arguments.class, this);
}
}

/** Command parsed arguments. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Logger;
import java.util.function.Consumer;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import org.apache.ignite.IgniteException;
Expand All @@ -46,6 +46,7 @@
import org.apache.ignite.internal.processors.cache.verify.PartitionKey;
import org.apache.ignite.internal.processors.cache.verify.VerifyBackupPartitionsTaskV2;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.SB;
import org.apache.ignite.internal.visor.verify.CacheFilterEnum;
import org.apache.ignite.internal.visor.verify.VisorIdleVerifyDumpTask;
Expand Down Expand Up @@ -179,6 +180,11 @@ public boolean idleCheckCrc() {
public boolean isSkipZeros() {
return skipZeros;
}

/** {@inheritDoc} */
@Override public String toString() {
return S.toString(Arguments.class, this);
}
}

/** Command parsed arguments. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public class ResetLostPartitions implements Command<Set<String>> {
return caches;
}

/** {@inheritDoc} */
@Override public String argumentString() {
return "caches=" + caches;
}

/** {@inheritDoc} */
@Override public Object execute(GridClientConfiguration clientCfg, Logger logger) throws Exception {
CacheResetLostPartitionsTaskArg taskArg = new CacheResetLostPartitionsTaskArg(caches);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ public class DiagnosticCommand implements Command<DiagnosticSubCommand> {
return subcommand;
}

/** {@inheritDoc} */
@Override public String argumentString() {
return "diagnosticSubcommand=" + subcommand.name() +
(subcommand.subcommand() == null ? "" : ", " + subcommand.subcommand().argumentString());
}

/** {@inheritDoc} */
@Override public void parseArguments(CommandArgIterator argIter) {
if (!argIter.hasNextSubArg()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.ignite.internal.commandline.TaskExecutor;
import org.apache.ignite.internal.commandline.argument.CommandArg;
import org.apache.ignite.internal.commandline.argument.CommandArgUtils;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.visor.diagnostic.Operation;
import org.apache.ignite.internal.visor.diagnostic.VisorPageLocksResult;
import org.apache.ignite.internal.visor.diagnostic.VisorPageLocksTask;
Expand All @@ -43,10 +44,10 @@
import static org.apache.ignite.internal.commandline.CommandLogger.optional;
import static org.apache.ignite.internal.commandline.diagnostic.DiagnosticSubCommand.PAGE_LOCKS;
import static org.apache.ignite.internal.commandline.diagnostic.PageLocksCommand.PageLocksCommandArg.ALL;
import static org.apache.ignite.internal.commandline.diagnostic.PageLocksCommand.PageLocksCommandArg.NODES;
import static org.apache.ignite.internal.commandline.diagnostic.PageLocksCommand.PageLocksCommandArg.PATH;
import static org.apache.ignite.internal.commandline.diagnostic.PageLocksCommand.PageLocksCommandArg.DUMP;
import static org.apache.ignite.internal.commandline.diagnostic.PageLocksCommand.PageLocksCommandArg.DUMP_LOG;
import static org.apache.ignite.internal.commandline.diagnostic.PageLocksCommand.PageLocksCommandArg.NODES;
import static org.apache.ignite.internal.commandline.diagnostic.PageLocksCommand.PageLocksCommandArg.PATH;
import static org.apache.ignite.internal.processors.diagnostic.DiagnosticProcessor.DEFAULT_TARGET_FOLDER;

/**
Expand Down Expand Up @@ -76,7 +77,7 @@ public class PageLocksCommand implements Command<PageLocksCommand.Arguments> {
});
}

VisorPageLocksTrackerArgs taskArg = new VisorPageLocksTrackerArgs(arguments.op, arguments.filePath, nodeIds);
VisorPageLocksTrackerArgs taskArg = new VisorPageLocksTrackerArgs(arguments.operation, arguments.filePath, nodeIds);

res = TaskExecutor.executeTask(
client,
Expand Down Expand Up @@ -180,7 +181,7 @@ private void printResult(Map<ClusterNode, VisorPageLocksResult> res) {
/** */
public static class Arguments {
/** */
private final Operation op;
private final Operation operation;
/** */
private final String filePath;
/** */
Expand All @@ -189,22 +190,27 @@ public static class Arguments {
private final Set<String> nodeIds;

/**
* @param op Operation.
* @param operation Operation.
* @param filePath File path.
* @param allNodes If {@code True} include all available nodes for command. If {@code False} include only subset.
* @param nodeIds Node ids.
*/
public Arguments(
Operation op,
Operation operation,
String filePath,
boolean allNodes,
Set<String> nodeIds
) {
this.op = op;
this.operation = operation;
this.filePath = filePath;
this.allNodes = allNodes;
this.nodeIds = nodeIds;
}

/** {@inheritDoc} */
@Override public String toString() {
return S.toString(Arguments.class, this);
}
}

enum PageLocksCommandArg implements CommandArg {
Expand Down
Loading

0 comments on commit 40c4bc3

Please sign in to comment.