Skip to content

Commit

Permalink
fix: [tags] tags as notes for events - see issue #4
Browse files Browse the repository at this point in the history
  • Loading branch information
cvandeplas committed Feb 7, 2019
1 parent 0015cbb commit d9ddb08
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/MISP_maltego/transforms/common/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ def attribute_to_entity(a, link_label=None, event_tags=None):
# ignore all misp-galaxies
if t['name'].startswith('misp-galaxy'):
continue
# ignore all those we add as notes
if tag_matches_note_prefix(t['name']):
continue
yield Hashtag(t['name'])

notes = convert_tags_to_note(combined_tags)
Expand Down Expand Up @@ -309,6 +312,13 @@ def convert_tags_to_note(tags):
return '\n'.join(notes)


def tag_matches_note_prefix(tag):
for tag_note_prefix in tag_note_prefixes:
if tag.startswith(tag_note_prefix):
return True
return False


def event_to_entity(e, link_style=LinkStyle.Normal):
tags = []
if 'Tag' in e['Event']:
Expand Down
6 changes: 5 additions & 1 deletion src/MISP_maltego/transforms/eventtoattributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from canari.maltego.transform import Transform
# from canari.framework import EnableDebugWindow
from MISP_maltego.transforms.common.entities import MISPEvent, MISPObject
from MISP_maltego.transforms.common.util import get_misp_connection, attribute_to_entity, event_to_entity, galaxycluster_to_entity, object_to_entity, object_to_attributes
from MISP_maltego.transforms.common.util import get_misp_connection, attribute_to_entity, event_to_entity, galaxycluster_to_entity, object_to_entity, object_to_attributes, tag_matches_note_prefix
from canari.maltego.message import LinkStyle

import json
Expand Down Expand Up @@ -33,13 +33,17 @@ def do_transform(self, request, response, config):
if not event_json.get('Event'):
return response

response += event_to_entity(event_json)
event_tags = []
if 'Tag' in event_json['Event']:
for t in event_json['Event']['Tag']:
event_tags.append(t['name'])
# ignore all misp-galaxies
if t['name'].startswith('misp-galaxy'):
continue
# ignore all those we add as notes
if tag_matches_note_prefix(t['name']):
continue
response += Hashtag(t['name'])
for g in event_json['Event']['Galaxy']:
for c in g['GalaxyCluster']:
Expand Down

0 comments on commit d9ddb08

Please sign in to comment.