From d97e5779f23d5f62f3cb3cbfaccc3369983018c3 Mon Sep 17 00:00:00 2001 From: Michael Weiser Date: Tue, 12 Feb 2019 13:47:03 +0000 Subject: Allow multiple files to be scanned at once To simulate typical usage by e.g. AMaViS, allow scan_file.py to submit more than one file at once for analysis. --- bin/scan_file.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bin/scan_file.py b/bin/scan_file.py index c11fa23..b8434c1 100755 --- a/bin/scan_file.py +++ b/bin/scan_file.py @@ -49,18 +49,24 @@ def main(): help='Output additional diagnostics') parser.add_argument('-s', '--socket_file', action='store', required=True, help='Path to Peekaboo\'s socket file') - parser.add_argument('-f', '--filename', action='store', required=True, - help='Path to the file to scan') + parser.add_argument('-f', '--filename', action='append', required=True, + help='Path to the file to scan. Can be given more ' + 'than once to scan multiple files.') args = parser.parse_args() result_regex = re.compile(r'.*wurde als', re.MULTILINE + re.DOTALL + re.UNICODE) - file_abspath = path.abspath(args.filename) peekaboo = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) peekaboo.connect(args.socket_file) - request = '[ { "full_name": "%s" } ]' % file_abspath + + file_snippets = [] + for filename in args.filename: + file_snippets.append('{ "full_name": "%s" }' % path.abspath(filename)) + request = '[ %s ]' % ', '.join(file_snippets) + if args.debug: print ('Sending request: %s' % request) + peekaboo.send(request) print ('Waiting for response...') -- cgit v1.2.3