Commit 6463d8b8c05620593c763ff5bfdd46398bab972b

Authored by Christian Herdtweck
1 parent 730f64f5

handle new exceptions in main

Showing 1 changed file with 14 additions and 0 deletions
oletools/olevba.py
... ... @@ -2959,6 +2959,8 @@ class VBA_Parser_CLI(VBA_Parser):
2959 2959 print self.reveal()
2960 2960 else:
2961 2961 print 'No VBA macros found.'
  2962 + except OlevbaBaseException:
  2963 + raise
2962 2964 except Exception as exc:
2963 2965 # display the exception with full stack trace for debugging
2964 2966 log.info('Error processing file %s (%s)' % (self.filename, exc))
... ... @@ -3261,6 +3263,18 @@ def main():
3261 3263 raise ValueError('unexpected output mode: "{0}"!'.format(options.output_mode))
3262 3264 count += 1
3263 3265  
  3266 + except (SubstreamOpenError, UnexpectedDataError) as exc:
  3267 + if options.output_mode in ('triage', 'unspecified'):
  3268 + print '%-12s %s - Error opening substream or uenxpected ' \
  3269 + 'content' % ('?', filename)
  3270 + elif options.output_mode == 'json':
  3271 + print_json(file=filename, type='error',
  3272 + error=type(exc).__name__, message=str(exc))
  3273 + else:
  3274 + log.exception('Error opening substream or unexpected '
  3275 + 'content in %s' % filename)
  3276 + return_code = RETURN_OPEN_ERROR if return_code == 0 \
  3277 + else RETURN_SEVERAL_ERRS
3264 3278 except FileOpenError as exc:
3265 3279 if options.output_mode in ('triage', 'unspecified'):
3266 3280 print '%-12s %s - File format not supported' % ('?', filename)
... ...