summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Bauer <felix.bauer@atos.net>2019-10-15 18:31:09 +0200
committerFelix Bauer <jack@ai4me.de>2019-10-29 12:37:07 +0100
commitc3987a2f029549208a7c146542989976f77afee2 (patch)
tree5ac5b428e3f024d5ccf7010f07d29dc35c42a7af
parent93e0b98a917b5c9e7405feeff045432b5a8ce170 (diff)
Removed overly specific exception handling
vbaparser.type was compared against a hard coded list. OleNotAnOfficeDocumentException has been removed. The additional test is unnecessary, olevba takes care of it.
-rw-r--r--peekaboo/ruleset/rules.py12
-rw-r--r--peekaboo/toolbox/ole.py14
2 files changed, 8 insertions, 18 deletions
diff --git a/peekaboo/ruleset/rules.py b/peekaboo/ruleset/rules.py
index 9bfae33..f88c7d9 100644
--- a/peekaboo/ruleset/rules.py
+++ b/peekaboo/ruleset/rules.py
@@ -33,8 +33,7 @@ from peekaboo.ruleset.expressions import ExpressionParser, \
IdentifierMissingException
from peekaboo.exceptions import PeekabooAnalysisDeferred, \
CuckooSubmitFailedException, PeekabooRulesetConfigError
-from peekaboo.toolbox.ole import Oletools, OletoolsReport, \
- OleNotAnOfficeDocumentException
+from peekaboo.toolbox.ole import Oletools, OletoolsReport
logger = logging.getLogger(__name__)
@@ -260,10 +259,11 @@ class OleRule(Rule):
ole = Oletools()
report = ole.get_report(sample)
sample.register_oletools_report(OletoolsReport(report))
- except OleNotAnOfficeDocumentException:
- return self.result(Result.unknown,
- _("File is not an office document"),
- True)
+
+ if not report:
+ return self.result(Result.unknown,
+ _("File is not an office document"),
+ True)
except Exception:
raise
diff --git a/peekaboo/toolbox/ole.py b/peekaboo/toolbox/ole.py
index fb907e9..d1fe4b4 100644
--- a/peekaboo/toolbox/ole.py
+++ b/peekaboo/toolbox/ole.py
@@ -26,14 +26,11 @@
import logging
import re
-from oletools.olevba import VBA_Parser
+from oletools.olevba import VBA_Parser, FileOpenError
logger = logging.getLogger(__name__)
-class OleNotAnOfficeDocumentException(Exception):
- pass
-
class Oletools(object):
""" Parent class, defines interface to Oletools. """
def get_report(self, sample):
@@ -46,13 +43,6 @@ class Oletools(object):
try:
vbaparser = VBA_Parser(sample.file_path)
- # List from oletools/olevba.py#L553
- oletype = ('OLE', 'OpenXML', 'FlatOPC_XML', 'Word2003_XML', 'MHTML', 'PPT')
-
- # check if ole detects it as an office file
- if vbaparser.type not in oletype:
- raise OleNotAnOfficeDocumentException(sample.file_extension)
-
# VBA_Parser reports macros for office documents
report['has_macros'] = vbaparser.detect_vba_macros() or vbaparser.detect_xlm_macros()
try:
@@ -63,7 +53,7 @@ class Oletools(object):
vbaparser.close()
except IOError:
raise
- except TypeError:
+ except (TypeError, FileOpenError):
# The given file is not an office document.
pass
except Exception as error: