Skip to content

Commit

Permalink
Fixed bug with adding duplicating tags or tags without colon
Browse files Browse the repository at this point in the history
  • Loading branch information
siniysv committed Apr 3, 2018
1 parent f55c946 commit 1cc78f8
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions rc-cts-misp/rc_cts_misp/components/searcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,21 @@ def matches(an_attribute):
UriProp(name="MISP Link", value=link),
)
# Add all the tags as separate properties
tags = {}
for tag in event.get("Tag"):
tag_name, tag_value = tag["name"].split(":", 1)
hit.append(StringProp(name="{}:".format(tag_name), value=tag_value))
try:
tag_name, tag_value = tag["name"].split(":", 1)
except:
tag_value = tag["name"]
tag_name = 'tag'
if tag_name not in tags:
tags[tag_name] = 0
tag_name_modified = "{}_{}".format(tag_name, tags[tag_name])
else:
tags[tag_name] += 1
tag_name_modified = "{}_{}".format(tag_name, tags[tag_name])
hit.append(StringProp(name="{}:".format(tag_name_modified),
value=tag_value))
hits.append(hit)

return hits
Expand Down

0 comments on commit 1cc78f8

Please sign in to comment.