Commit 82503a9e71d2dafa664e1c484c87c9641584dfda
1 parent
749e9ebc
add errors in main to json_results
Showing
1 changed file
with
12 additions
and
0 deletions
oletools/olevba.py
| @@ -2956,6 +2956,10 @@ def main(): | @@ -2956,6 +2956,10 @@ def main(): | ||
| 2956 | % (filename, container, data)) | 2956 | % (filename, container, data)) |
| 2957 | return_code = RETURN_XGLOB_ERR if return_code == 0 \ | 2957 | return_code = RETURN_XGLOB_ERR if return_code == 0 \ |
| 2958 | else RETURN_SEVERAL_ERRS | 2958 | else RETURN_SEVERAL_ERRS |
| 2959 | + if options.output_mode == 'json': | ||
| 2960 | + json_results.append(dict(file=filename, type='error', | ||
| 2961 | + error=type(data).__name__, | ||
| 2962 | + message=str(data))) | ||
| 2959 | continue | 2963 | continue |
| 2960 | 2964 | ||
| 2961 | try: | 2965 | try: |
| @@ -2993,6 +2997,10 @@ def main(): | @@ -2993,6 +2997,10 @@ def main(): | ||
| 2993 | print '%-12s %s - File format not supported' % ('?', filename) | 2997 | print '%-12s %s - File format not supported' % ('?', filename) |
| 2994 | else: | 2998 | else: |
| 2995 | log.exception('Failed to open %s -- probably not supported!' % filename) | 2999 | log.exception('Failed to open %s -- probably not supported!' % filename) |
| 3000 | + if options.output_mode == 'json': | ||
| 3001 | + json_results.append(dict(file=filename, type='error', | ||
| 3002 | + error=type(exc).__name__, | ||
| 3003 | + message=str(exc))) | ||
| 2996 | return_code = RETURN_OPEN_ERROR if return_code == 0 \ | 3004 | return_code = RETURN_OPEN_ERROR if return_code == 0 \ |
| 2997 | else RETURN_SEVERAL_ERRS | 3005 | else RETURN_SEVERAL_ERRS |
| 2998 | except ProcessingError as exc: | 3006 | except ProcessingError as exc: |
| @@ -3001,6 +3009,10 @@ def main(): | @@ -3001,6 +3009,10 @@ def main(): | ||
| 3001 | else: | 3009 | else: |
| 3002 | log.exception('Error processing file %s (%s)!' | 3010 | log.exception('Error processing file %s (%s)!' |
| 3003 | % (filename, exc.orig_exception)) | 3011 | % (filename, exc.orig_exception)) |
| 3012 | + if options.output_mode == 'json': | ||
| 3013 | + json_results.append(dict(file=filename, type='error', | ||
| 3014 | + error=type(exc).__name__, | ||
| 3015 | + message=str(exc.orig_exception))) | ||
| 3004 | return_code = RETURN_PARSE_ERROR if return_code == 0 \ | 3016 | return_code = RETURN_PARSE_ERROR if return_code == 0 \ |
| 3005 | else RETURN_SEVERAL_ERRS | 3017 | else RETURN_SEVERAL_ERRS |
| 3006 | finally: | 3018 | finally: |