diff --git a/doc/rho.1 b/doc/rho.1 index 00e7c1b..883647c 100644 --- a/doc/rho.1 +++ b/doc/rho.1 @@ -337,10 +337,17 @@ and .B rho fact redact .B --reportfile= .I file +.B [--outputfile= +.I path +.B ] .PP .TP --reportfile=file -The path and filename of the comma-separated values (CSV) file to alter. +The path and filename of the comma-separated values (CSV) file to read from. +.PP +.TP +--outputfile=path +The path and filename of the comma-separated values (CSV) file to be written. .PP .B Encrypting Facts @@ -353,11 +360,18 @@ and .B rho fact encrypt .B --reportfile= .I file +.B [--outputfile= +.I path +.B ] .PP .TP --reportfile=file The path and filename of the comma-separated values (CSV) file to alter. .PP +.TP +--outputfile=path +The path and filename of the comma-separated values (CSV) file to be written. +.PP .B Decrypting Facts .PP @@ -369,11 +383,18 @@ and .B rho fact decrypt .B --reportfile= .I file +.B [--outputfile= +.I path +.B ] .PP .TP --reportfile=file The path and filename of the comma-separated values (CSV) file to alter. .PP +.TP +--outputfile=path +The path and filename of the comma-separated values (CSV) file to be written. +.PP .PP .SS SCANNING The 'scan' command is the one that actually runs discovery on the network. This command scans all of the servers within the range, and then writes the information to a CSV file. diff --git a/rho/factdecryptcommand.py b/rho/factdecryptcommand.py index 24a3bc6..b5940a2 100644 --- a/rho/factdecryptcommand.py +++ b/rho/factdecryptcommand.py @@ -42,6 +42,11 @@ def __init__(self): self.parser.add_option("--facts", dest="facts", metavar="FACTS", action="callback", callback=multi_arg, default=[], help=SUPPRESS_HELP) + + self.parser.add_option("--outputfile", dest="decrypted_path", + metavar="DECRYPTEDPATH", + help=_("Location for the decrypted file")) + self.facts_to_decrypt = None def _validate_options(self): @@ -111,5 +116,8 @@ def read_and_decrypt(self, path, vault): def _do_command(self): vault = get_vault(prompt=PROMPT) normalized_path = os.path.normpath(self.options.report_path) + decrypted_path = (self.options.decrypted_path or + normalized_path + '-decrypted') + keys, data = self.read_and_decrypt(normalized_path, vault) - write_csv_data(keys, data, normalized_path) + write_csv_data(keys, data, decrypted_path) diff --git a/rho/factencryptcommand.py b/rho/factencryptcommand.py index 77cfac0..7c740f6 100644 --- a/rho/factencryptcommand.py +++ b/rho/factencryptcommand.py @@ -42,6 +42,12 @@ def __init__(self): self.parser.add_option("--facts", dest="facts", metavar="FACTS", action="callback", callback=multi_arg, default=[], help=SUPPRESS_HELP) + + self.parser.add_option("--outputfile", dest="encrypted_path", + metavar="ENCRYPTEDPATH", + help=_("Location for the encrypted file"), + default=None) + self.facts_to_encrypt = None def _validate_options(self): @@ -111,5 +117,8 @@ def read_and_encrypt(self, path, vault): def _do_command(self): vault = get_vault(prompt=PROMPT) normalized_path = os.path.normpath(self.options.report_path) + encrypted_path = (self.options.encrypted_path or + normalized_path + '-encrypted') + keys, data = self.read_and_encrypt(normalized_path, vault) - write_csv_data(keys, data, normalized_path) + write_csv_data(keys, data, encrypted_path) diff --git a/rho/factredactcommand.py b/rho/factredactcommand.py index 15bbc36..e6b2280 100644 --- a/rho/factredactcommand.py +++ b/rho/factredactcommand.py @@ -41,6 +41,11 @@ def __init__(self): self.parser.add_option("--facts", dest="facts", metavar="FACTS", action="callback", callback=multi_arg, default=[], help=SUPPRESS_HELP) + + self.parser.add_option("--outputfile", dest="redacted_path", + metavar="REDACTEDPATH", + help=_("Location for the redacted file")) + self.facts_to_redact = None def _validate_options(self): @@ -81,6 +86,9 @@ def _do_command(self): data = [] keys = None normalized_path = os.path.normpath(self.options.report_path) + redacted_path = (self.options.redacted_path or + normalized_path + '-redacted') + with open(normalized_path, 'r') as read_file: reader = csv.DictReader(read_file, delimiter=',') for row in reader: @@ -112,4 +120,4 @@ def _do_command(self): for row in data: writer.writerow(row) data_temp.close() - move(data_temp.name, normalized_path) + move(data_temp.name, redacted_path)