outfile is now mandatory

Having your passwords output in plaintext to stdout might be surprising
and potentially dangerous behaviour
This commit is contained in:
Rupus Reinefjord 2022-11-15 21:14:13 +01:00
parent 862f6dca4c
commit fd08fce575

View file

@ -89,7 +89,7 @@ def write(file, entries, get_fields, get_lines):
csvw.writerow(columns) csvw.writerow(columns)
def main(store_path, grouping_base, outfile, gpgbinary, use_agent, encodings, def main(store_path, outfile, grouping_base, gpgbinary, use_agent, encodings,
exclude, get_fields, get_lines): exclude, get_fields, get_lines):
entries = [] entries = []
failures = [] failures = []
@ -142,14 +142,22 @@ def main(store_path, grouping_base, outfile, gpgbinary, use_agent, encodings,
write(outfile, entries, get_fields, get_lines) write(outfile, entries, get_fields, get_lines)
def parse_args(args): def parse_args(args=None):
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument( parser.add_argument(
'store_path', 'store_path',
metavar='STOREPATH',
type=str, type=str,
help="path to the password-store to export", help="path to the password-store to export",
) )
parser.add_argument(
'outfile',
metavar='OUTFILE',
type=argparse.FileType('w'),
help="file to write exported data to, use - for stdout",
)
parser.add_argument( parser.add_argument(
'-b', '--base', '-b', '--base',
metavar='path', metavar='path',
@ -187,15 +195,6 @@ def parse_args(args):
dest='encodings' dest='encodings'
) )
parser.add_argument(
'-o', '--outfile',
metavar='file',
type=argparse.FileType('w'),
default="-",
help="file to write exported data to (default stdin)",
dest='outfile'
)
parser.add_argument( parser.add_argument(
'-e', '--exclude', '-e', '--exclude',
metavar='pattern', metavar='pattern',
@ -255,7 +254,7 @@ def compile_regexp(pattern):
if __name__ == '__main__': if __name__ == '__main__':
parsed = parse_args(sys.argv[1:]) parsed = parse_args()
failed = False failed = False
exclude_patterns = [] exclude_patterns = []
@ -296,11 +295,11 @@ if __name__ == '__main__':
kwargs = { kwargs = {
'store_path': parsed.store_path, 'store_path': parsed.store_path,
'outfile': parsed.outfile,
'grouping_base': grouping_base, 'grouping_base': grouping_base,
'gpgbinary': parsed.gpgbinary, 'gpgbinary': parsed.gpgbinary,
'use_agent': parsed.use_agent, 'use_agent': parsed.use_agent,
'encodings': encodings, 'encodings': encodings,
'outfile': parsed.outfile,
'exclude': exclude_patterns, 'exclude': exclude_patterns,
'get_fields': get_fields, 'get_fields': get_fields,
'get_lines': get_lines 'get_lines': get_lines