From 82503a9e71d2dafa664e1c484c87c9641584dfda Mon Sep 17 00:00:00 2001 From: Christian Herdtweck Date: Thu, 28 Apr 2016 16:44:24 +0200 Subject: [PATCH] add errors in main to json_results --- oletools/olevba.py | 12 ++++++++++++ 1 file changed, 12 insertions(+), 0 deletions(-) diff --git a/oletools/olevba.py b/oletools/olevba.py index 518f759..d97827e 100755 --- a/oletools/olevba.py +++ b/oletools/olevba.py @@ -2956,6 +2956,10 @@ def main(): % (filename, container, data)) return_code = RETURN_XGLOB_ERR if return_code == 0 \ else RETURN_SEVERAL_ERRS + if options.output_mode == 'json': + json_results.append(dict(file=filename, type='error', + error=type(data).__name__, + message=str(data))) continue try: @@ -2993,6 +2997,10 @@ def main(): print '%-12s %s - File format not supported' % ('?', filename) else: log.exception('Failed to open %s -- probably not supported!' % filename) + if options.output_mode == 'json': + json_results.append(dict(file=filename, type='error', + error=type(exc).__name__, + message=str(exc))) return_code = RETURN_OPEN_ERROR if return_code == 0 \ else RETURN_SEVERAL_ERRS except ProcessingError as exc: @@ -3001,6 +3009,10 @@ def main(): else: log.exception('Error processing file %s (%s)!' % (filename, exc.orig_exception)) + if options.output_mode == 'json': + json_results.append(dict(file=filename, type='error', + error=type(exc).__name__, + message=str(exc.orig_exception))) return_code = RETURN_PARSE_ERROR if return_code == 0 \ else RETURN_SEVERAL_ERRS finally: -- libgit2 0.21.4