From d9b0a0dab646bc4a1a5b57cea74506c199a7b7b3 Mon Sep 17 00:00:00 2001 From: Fedele Mantuano Date: Thu, 26 Jul 2018 22:11:36 +0200 Subject: [PATCH] Bugfix --- requirements_optional.txt | 2 +- src/modules/attachments/post_processing.py | 23 +++++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/requirements_optional.txt b/requirements_optional.txt index 60f266c..45b1d5c 100644 --- a/requirements_optional.txt +++ b/requirements_optional.txt @@ -1,5 +1,5 @@ elasticsearch>=6.0.0, <7 redis>=2.10.5, <3 shodan -tika-app +tika-app>=1.4.0 virustotal-api diff --git a/src/modules/attachments/post_processing.py b/src/modules/attachments/post_processing.py index 5ce1716..b7fbdcd 100644 --- a/src/modules/attachments/post_processing.py +++ b/src/modules/attachments/post_processing.py @@ -84,13 +84,20 @@ def tika(conf, attachments): if conf["enabled"]: from tikapp import TikaApp - tika = TikaApp(file_jar=conf["path_jar"], - memory_allocation=conf["memory_allocation"]) + + tika = TikaApp( + file_jar=conf["path_jar"], + memory_allocation=conf["memory_allocation"]) + + wtlist = conf.get("whitelist_content_types", []) + if not wtlist: + log.warning( + "Apache Tika analysis setted, without whitelist content types") + return for a in attachments: if not a.get("is_filtered", False): - if a["Content-Type"] in \ - conf.get("whitelist_content_types", []): + if a["Content-Type"] in wtlist: payload = a["payload"] if a["content_transfer_encoding"] != "base64": @@ -132,7 +139,13 @@ def virustotal(conf, attachments): from .utils import reformat_virustotal vt = VirusTotalPublicApi(conf["api_key"]) - wtlist = conf["whitelist_content_types"] + wtlist = conf.get("whitelist_content_types", []) + + # I don't have content types to analyze + if not wtlist: + log.warning( + "Virustotal analysis setted, without whitelist content types") + return for a in attachments: if not a.get("is_filtered", False) and a["Content-Type"] in wtlist: