Skip to content

Commit

Permalink
Ref #284: PEP8, short report fix
Browse files Browse the repository at this point in the history
  • Loading branch information
3c7 committed Jul 10, 2018
1 parent 0cbfa74 commit addc8b6
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions analyzers/Hashdd/Hashdd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -19,26 +19,23 @@ 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()}
else:
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']
Expand All @@ -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()

Expand All @@ -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']))
Expand Down

0 comments on commit addc8b6

Please sign in to comment.