json_output updates
@@ -850,20 +850,23 @@ def create_r2_script(sample_file_path, r2_script_file, decoded_strings, stack_st
# TODO return, catch exception in main()
-def create_json_output(json_file_path, sample_file_path, decoded_strings, stack_strings):
+def create_json_output(options, sample_file_path, decoded_strings, stack_strings):
"""
Create a report of the analysis performed by FLOSS
- :param json_file_path: path to write the report
+ :param options: parsed options
:param sample_file_path: path of the sample analyzed
:param decoded_strings: list of decoded strings ([DecodedString])
:param stack_strings: list of stack strings ([StackString])
"""
- results = {'stack_strings': [sanitize_string_for_printing(ss.s) for ss in stack_strings],
+ strings = {'stack_strings': [sanitize_string_for_printing(ss.s) for ss in stack_strings],
'decoded_strings': [sanitize_string_for_printing(ds.s) for ds in decoded_strings]}
- report = {'file_path': sample_file_path, 'results': results}
+ metadata = {'file_path': sample_file_path,
+ 'stack_strings': not options.no_stack_strings,
+ 'decoded_strings': not options.no_decoded_strings,
+ 'static_strings': not options.no_static_strings}
try:
- with open(json_file_path, 'w') as f:
- json.dump(report, f)
+ with open(options.json_file_path, 'w') as f:
+ json.dump({'metadata': metadata, 'strings': strings}, f)
except Exception:
raise
@@ -1114,7 +1117,7 @@ def main(argv=None):
print("\nFinished execution after %f seconds" % (time1 - time0))
if options.json_output_file:
- create_json_output(options.json_output_file, sample_file_path, decoded_strings, stack_strings)
+ create_json_output(options, sample_file_path, decoded_strings, stack_strings)
floss_logger.info("Wrote JSON file to %s\n" % options.json_output_file)
return 0
