Commit 52dc2d70f987d10064553b5ecad52eca5330e51c
1 parent
c39b462d
move handling of FileOpenError from VBA_Parser_CLI.__init__ to main
Showing
1 changed file
with
8 additions
and
8 deletions
oletools/olevba.py
| @@ -2516,8 +2516,7 @@ class VBA_Parser_CLI(VBA_Parser): | @@ -2516,8 +2516,7 @@ class VBA_Parser_CLI(VBA_Parser): | ||
| 2516 | def __init__(self, filename, data=None, container=None): | 2516 | def __init__(self, filename, data=None, container=None): |
| 2517 | """ | 2517 | """ |
| 2518 | Constructor for VBA_Parser_CLI. | 2518 | Constructor for VBA_Parser_CLI. |
| 2519 | - Calls __init__ from VBA_Parser, but handles the TypeError exception | ||
| 2520 | - when the file type is not supported. | 2519 | + Calls __init__ from VBA_Parser |
| 2521 | 2520 | ||
| 2522 | :param filename: filename or path of file to parse, or file-like object | 2521 | :param filename: filename or path of file to parse, or file-like object |
| 2523 | 2522 | ||
| @@ -2528,11 +2527,7 @@ class VBA_Parser_CLI(VBA_Parser): | @@ -2528,11 +2527,7 @@ class VBA_Parser_CLI(VBA_Parser): | ||
| 2528 | :param container: str, path and filename of container if the file is within | 2527 | :param container: str, path and filename of container if the file is within |
| 2529 | a zip archive, None otherwise. | 2528 | a zip archive, None otherwise. |
| 2530 | """ | 2529 | """ |
| 2531 | - try: | ||
| 2532 | - VBA_Parser.__init__(self, filename, data=data, container=container) | ||
| 2533 | - except TypeError: | ||
| 2534 | - # in that case, self.type=None | ||
| 2535 | - pass | 2530 | + super(VBA_Parser_CLI, self).__init__(filename, data=data, container=container) |
| 2536 | 2531 | ||
| 2537 | 2532 | ||
| 2538 | def print_analysis(self, show_decoded_strings=False, deobfuscate=False): | 2533 | def print_analysis(self, show_decoded_strings=False, deobfuscate=False): |
| @@ -2897,7 +2892,12 @@ def main(): | @@ -2897,7 +2892,12 @@ def main(): | ||
| 2897 | if container and filename.endswith('/'): | 2892 | if container and filename.endswith('/'): |
| 2898 | continue | 2893 | continue |
| 2899 | # Open the file | 2894 | # Open the file |
| 2900 | - vba_parser = VBA_Parser_CLI(filename, data=data, container=container) | 2895 | + try: |
| 2896 | + vba_parser = VBA_Parser_CLI(filename, data=data, container=container) | ||
| 2897 | + except FileOpenError as exc: | ||
| 2898 | + log.exception('Failed to open %s (%s)!' % (filename, exc)) | ||
| 2899 | + continue | ||
| 2900 | + | ||
| 2901 | if options.output_mode == 'detailed': | 2901 | if options.output_mode == 'detailed': |
| 2902 | # fully detailed output | 2902 | # fully detailed output |
| 2903 | vba_parser.process_file(show_decoded_strings=options.show_decoded_strings, | 2903 | vba_parser.process_file(show_decoded_strings=options.show_decoded_strings, |