Skip to content

Commit

Permalink
Ref #431: Added summary
Browse files Browse the repository at this point in the history
  • Loading branch information
3c7 committed Feb 25, 2019
1 parent 1e40b0c commit abe29e4
Showing 1 changed file with 32 additions and 15 deletions.
47 changes: 32 additions & 15 deletions analyzers/URLhaus/URLhaus_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,41 @@ def run(self):

def summary(self, raw):
taxonomies = []
level = "info"
namespace = "URLhaus"
predicate = "Search"
value = "0 result"

results = raw["results"]
if len(results) >= 1:
level = "malicious"

if len(results) <= 1:
value = "{} result".format(len(results))
if raw['query_status'] == 'no_results':
taxonomies.append(self.build_taxonomy(
'info',
namespace,
'Search',
'No results'
))
else:
value = "{} results".format(len(results))

taxonomies.append(
self.build_taxonomy(level, namespace, predicate, value)
)

if self.data_type == 'url':
taxonomies.append(self.build_taxonomy(
'malicious',
namespace,
'Threat',
raw['threat']
))
elif self.data_type in ['domain', 'ip']:
threat_types = []
for url in raw['urls']:
if url['threat'] not in threat_types:
threat_types.append(url['threat'])
taxonomies.append(self.build_taxonomy(
'malicious',
namespace,
'Threat' if len(threat_types) == 1 else 'Threats',
','.join(threat_types)
))
elif self.data_type == 'hash':
taxonomies.append(self.build_taxonomy(
'malicious',
namespace,
'Signature',
raw['signature'] if raw['signature'] and raw['signature'] != 'null' else 'Unknown'
))
return {"taxonomies": taxonomies}


Expand Down

0 comments on commit abe29e4

Please sign in to comment.