-
Notifications
You must be signed in to change notification settings - Fork 7
Mask passwords while error logging #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,7 +40,8 @@ public String version() { | |
| @Override | ||
| public void checkConnection() { | ||
| CommandLine gitCmd = Console.createCommand("ls-remote", gitConfig.getEffectiveUrl()); | ||
| runAndGetOutput(gitCmd); | ||
| CommandLine gitCmdMasked = Console.createCommand("ls-remote", gitConfig.getEffectiveMaskedUrl()); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you are replacing
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. gitCmdMasked here only for output in case of errors, to real execution we still pass gitCmd. Difference only in output while error |
||
| runAndGetOutput(gitCmd, workingDir, gitCmdMasked.toString()); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -49,10 +50,14 @@ public void cloneRepository() { | |
| if (gitConfig.isShallowClone()) { | ||
| args.add("--depth=1"); | ||
| } | ||
| List<String> maskedArgs = new ArrayList<String>(args); | ||
| args.add(gitConfig.getEffectiveUrl()); | ||
| maskedArgs.add(gitConfig.getEffectiveMaskedUrl()); | ||
| args.add(workingDir.getAbsolutePath()); | ||
| maskedArgs.add(workingDir.getAbsolutePath()); | ||
| CommandLine gitClone = Console.createCommand(ListUtil.toArray(args)); | ||
| runAndGetOutput(gitClone, null, stdOut, stdErr); | ||
| CommandLine gitCloneMasked = Console.createCommand(ListUtil.toArray(maskedArgs)); | ||
| runAndGetOutput(gitClone, null, stdOut, stdErr, gitCloneMasked.toString()); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -388,12 +393,20 @@ private ConsoleResult runOrBomb(CommandLine gitCmd) { | |
| private ConsoleResult runAndGetOutput(CommandLine gitCmd) { | ||
| return runAndGetOutput(gitCmd, workingDir); | ||
| } | ||
|
|
||
| private ConsoleResult runAndGetOutput(CommandLine gitCmd, File workingDir, String prettyMessage) { | ||
| return runAndGetOutput(gitCmd, workingDir, new ProcessOutputStreamConsumer(new InMemoryConsumer()), new ProcessOutputStreamConsumer(new InMemoryConsumer()), prettyMessage); | ||
| } | ||
|
|
||
| private ConsoleResult runAndGetOutput(CommandLine gitCmd, File workingDir) { | ||
| return runAndGetOutput(gitCmd, workingDir, new ProcessOutputStreamConsumer(new InMemoryConsumer()), new ProcessOutputStreamConsumer(new InMemoryConsumer())); | ||
| } | ||
|
|
||
| private ConsoleResult runAndGetOutput(CommandLine gitCmd, File workingDir, ProcessOutputStreamConsumer stdOut, ProcessOutputStreamConsumer stdErr) { | ||
| return Console.runOrBomb(gitCmd, workingDir, stdOut, stdErr); | ||
| return runAndGetOutput(gitCmd, workingDir, stdOut, stdErr, gitCmd.toString()); | ||
| } | ||
|
|
||
| private ConsoleResult runAndGetOutput(CommandLine gitCmd, File workingDir, ProcessOutputStreamConsumer stdOut, ProcessOutputStreamConsumer stdErr, String prettyMessage) { | ||
| return Console.runOrBomb(gitCmd, workingDir, stdOut, stdErr, prettyMessage); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if i understand this right, you are passing
commandLine.toString()asprettyMessageand using it ingetMessage(). But isn't that what's happening anyway?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saved previous behaviour in method with 4 params and added new one with 5 and pass different prettyMessage only where needed