Skip to content

Commit

Permalink
#56 fixed format of summary() output and short reports
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromeleonard committed Jun 15, 2017
1 parent ee2bf0c commit ee94e1e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions analyzers/GoogleSafebrowsing/safebrowsing_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,23 @@ def __init__(self):

def summary(self, raw):

result = {"level":"info", "taxonomy":{"namespace": "Google", "predicate": "Safebrowsing", "value":0}}
taxonomy = {"level":"info", "namespace": "Google", "predicate": "Safebrowsing", "value":0}
taxonomies = []

if ("results" in raw):
r = len(raw['results'])

if r == 0 or r == 1:
result["taxonomy"]["value"] = "\"{} match\"".format(r)
taxonomy["value"] = "\"{} match\"".format(r)
else:
result["taxonomy"]["value"] = "\"{} matches\"".format(r)
taxonomy["value"] = "\"{} matches\"".format(r)

if r > 0:
result["level"] = "malicious"
taxonomy["level"] = "malicious"
# level : info, safe, suspicious, malicious

taxonomies.append(taxonomy)
result = {"taxonomies": taxonomies}
return result

def run(self):
Expand Down
4 changes: 2 additions & 2 deletions thehive-templates/GoogleSafebrowsing_1_0/short.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<span class="label" ng-init="t = content.taxonomy" ng-class="{'info': 'label-info', 'safe': 'label-success', 'suspicious': 'label-warning', 'malicious':'label-danger'}[content.level]">
<span class="label" ng-repeat="t in content.taxonomies" ng-class="{'info': 'label-info', 'safe': 'label-success', 'suspicious': 'label-warning', 'malicious':'label-danger'}[t.level]">
{{t.namespace}}:{{t.predicate}}={{t.value}}
</span>
</span>&nbsp;

0 comments on commit ee94e1e

Please sign in to comment.