From 6d02dcee0d294cb6b3d08bf6b70c025cf14934ed Mon Sep 17 00:00:00 2001 From: decalage2 Date: Fri, 19 May 2017 22:37:54 +0200 Subject: [PATCH] olevba: added enable_logging to fix issue #154 --- oletools/olevba.py | 18 +++++++++++++++--- setup.py | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/oletools/olevba.py b/oletools/olevba.py index a82ed99..cea374b 100644 --- a/oletools/olevba.py +++ b/oletools/olevba.py @@ -192,8 +192,9 @@ from __future__ import print_function # - added keywords for Mac-specific macros (issue #130) # 2017-03-08 PL: - fixed absolute imports # 2017-03-16 PL: - fixed issues #148 and #149 for option --reveal +# 2017-05-19 PL: - added enable_logging to fix issue #154 -__version__ = '0.51dev3' +__version__ = '0.51dev8' #------------------------------------------------------------------------------ # TODO: @@ -347,6 +348,18 @@ def get_logger(name, level=logging.CRITICAL+1): log = get_logger('olevba') +def enable_logging(): + """ + Enable logging for this module (disabled by default). + This will set the module-specific logger level to NOTSET, which + means the main application controls the actual logging level. + """ + log.setLevel(logging.NOTSET) + # Also enable logging in the ppt_parser module: + ppt_parser.enable_logging() + + + #=== EXCEPTIONS ============================================================== class OlevbaBaseException(Exception): @@ -2522,7 +2535,6 @@ class VBA_Parser(object): """ log.info('Check whether OLE file is PPT') - ppt_parser.enable_logging() try: ppt = ppt_parser.PptParser(self.ole_file, fast_fail=True) for vba_data in ppt.iter_vba_data(): @@ -3317,7 +3329,7 @@ def main(): logging.basicConfig(level=LOG_LEVELS[options.loglevel], format='%(levelname)-8s %(message)s') # enable logging in the modules: - log.setLevel(logging.NOTSET) + enable_logging() # Old display with number of items detected: # print '%-8s %-7s %-7s %-7s %-7s %-7s' % ('Type', 'Macros', 'AutoEx', 'Susp.', 'IOCs', 'HexStr') diff --git a/setup.py b/setup.py index 9268d6a..f8c6369 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,7 @@ import os, fnmatch #--- METADATA ----------------------------------------------------------------- name = "oletools" -version = '0.51dev7' +version = '0.51dev8' desc = "Python tools to analyze security characteristics of MS Office and OLE files (also called Structured Storage, Compound File Binary Format or Compound Document File Format), for Malware Analysis and Incident Response #DFIR" long_desc = open('oletools/README.rst').read() author = "Philippe Lagadec" -- libgit2 0.21.4