From addc8b6ae3cc81a6ae9bdca116733c3776b6ad63 Mon Sep 17 00:00:00 2001 From: Nils Kuhnert Date: Tue, 10 Jul 2018 10:58:40 +0200 Subject: [PATCH] Ref #284: PEP8, short report fix --- analyzers/Hashdd/Hashdd.py | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/analyzers/Hashdd/Hashdd.py b/analyzers/Hashdd/Hashdd.py index d570919dd..ef5fed9c3 100755 --- a/analyzers/Hashdd/Hashdd.py +++ b/analyzers/Hashdd/Hashdd.py @@ -3,8 +3,8 @@ import requests from cortexutils.analyzer import Analyzer -class HashddAnalyzer(Analyzer): +class HashddAnalyzer(Analyzer): service = 'Status' url = 'https://api.hashdd.com/' hashdd_key = None @@ -19,7 +19,6 @@ def __init__(self): self.hashdd_key = self.get_param('config.api_key', None, 'Missing hashdd API key') self.url = 'https://api.hashdd.com/detail' - def hashdd_check(self, data): if self.hashdd_key is None: postdata = {'hash': self.get_data()} @@ -27,18 +26,16 @@ def hashdd_check(self, data): postdata = {'hash': self.get_data(), 'api_key': self.hashdd_key} r = requests.post(self.url, data=postdata) - r.raise_for_status() # Raise exception on HTTP errors + r.raise_for_status() # Raise exception on HTTP errors return r.json() - def summary(self, raw): - taxonomies = [] namespace = 'Hashdd' predicate = 'known_level' value = "\0\"" - level = 'info' # Default level: this assigned when known_level is unknown + level = 'info' # Default level: this assigned when known_level is unknown if 'known_level' in raw: known_level = raw['known_level'] @@ -49,15 +46,13 @@ def summary(self, raw): # else: # level = "suspicious" # this one is not used - value = "\"{}\"".format(known_level) # Value must be enclosed with double quotes + value = "{}".format(known_level) # Value must be enclosed with double quotes taxonomies.append(self.build_taxonomy(level, namespace, predicate, value)) return {"taxonomies": taxonomies} - def run(self): - if self.data_type != 'hash': self.notSupported() @@ -74,18 +69,18 @@ def run(self): }) elif self.service == "detail": self.report({ - 'known_level': response[hash]['summary']['hashdd_known_level'], - 'file_name': response[hash]['summary']['hashdd_file_name'], - 'file_absolute_path': response[hash]['summary']['hashdd_file_absolute_path'], - 'size': response[hash]['summary']['hashdd_size'], - 'product_manufacturer': response[hash]['summary']['hashdd_product_manufacturer'], - 'product_name': response[hash]['summary']['hashdd_product_name'], - 'product_version': response[hash]['summary']['hashdd_product_version'], - 'architecture': response[hash]['summary']['hashdd_architecture'], - 'md5': response[hash]['summary']['hashdd_md5'], - 'sha1': response[hash]['summary']['hashdd_sha1'], - 'sha256': response[hash]['summary']['hashdd_sha256'], - 'ssdeep': response[hash]['summary']['hashdd_ssdeep'] + 'known_level': response[hash]['summary']['hashdd_known_level'], + 'file_name': response[hash]['summary']['hashdd_file_name'], + 'file_absolute_path': response[hash]['summary']['hashdd_file_absolute_path'], + 'size': response[hash]['summary']['hashdd_size'], + 'product_manufacturer': response[hash]['summary']['hashdd_product_manufacturer'], + 'product_name': response[hash]['summary']['hashdd_product_name'], + 'product_version': response[hash]['summary']['hashdd_product_version'], + 'architecture': response[hash]['summary']['hashdd_architecture'], + 'md5': response[hash]['summary']['hashdd_md5'], + 'sha1': response[hash]['summary']['hashdd_sha1'], + 'sha256': response[hash]['summary']['hashdd_sha256'], + 'ssdeep': response[hash]['summary']['hashdd_ssdeep'] }) else: self.error('{}'.format(response['result']))