Skip to content

Commit

Permalink
Merge pull request #55 from billdodd/fix/issue-54
Browse files Browse the repository at this point in the history
Mask password in README file
  • Loading branch information
mraineri authored Oct 30, 2020
2 parents 26f27c4 + 12955cd commit c213a2a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion redfishMockupCreate.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,17 @@ def main(argv):
rft.printErr("ERROR: cant create /redfish directory. aborting")
sys.exit(1)

# create copy of argv with password masked
mask_argv = list(argv)
if rft.password:
for i, arg in enumerate(mask_argv):
if i > 0:
if ((arg.startswith('-p') or arg.startswith('--p') or
mask_argv[i - 1].startswith('-p') or
mask_argv[i - 1].startswith('--p')) and
rft.password in arg):
mask_argv[i] = arg.replace(rft.password, '********')

# print out rhost and directory path
rft.printVerbose(1, "rhost: {}".format(rft.rhost))
rft.printVerbose(1, "full directory path: {}".format(mockDir))
Expand All @@ -332,7 +343,7 @@ def main(argv):
readf.write("Created: {}\n".format(rfdatetime))
readf.write("rhost: {}\n".format(rft.rhost))
readf.write("Description: {}\n".format(description))
readf.write("Commandline: {} {}\n".format('python3.4', ' '.join(argv)))
readf.write("Commandline: {} {}\n".format('python3.4', ' '.join(mask_argv)))
if os.path.isfile(readmeFile) is False:
rft.printErr("ERROR: cant create README file in directory. aborting")
sys.exit(1)
Expand Down

0 comments on commit c213a2a

Please sign in to comment.