Skip to content

Commit

Permalink
Merge pull request #938 from blacklanternsecurity/tag-inheritance
Browse files Browse the repository at this point in the history
Inherit mutation tags
  • Loading branch information
TheTechromancer authored Dec 24, 2023
2 parents 270ca8f + fb18a69 commit 61dfc0b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
10 changes: 7 additions & 3 deletions bbot/core/event/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,13 @@ def source(self, source):
if not hosts_are_same:
new_scope_distance += 1
self.scope_distance = new_scope_distance
# inherit affiliate tag
if hosts_are_same and "affiliate" in source.tags:
self.add_tag("affiliate")
# inherit certain tags
if hosts_are_same:
for t in source.tags:
if t == "affiliate":
self.add_tag("affiliate")
elif t.startswith("mutation-"):
self.add_tag(t)
elif not self._dummy:
log.warning(f"Tried to set invalid source on {self}: (got: {source})")

Expand Down
9 changes: 9 additions & 0 deletions bbot/test/test_step_1/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ async def test_events(events, scan, helpers, bbot_config):
assert internal_event1._internal == True
assert "internal" in internal_event1.tags

# tag inheritance
for tag in ("affiliate", "mutation-1"):
affiliate_event = scan.make_event("1.2.3.4", source=root_event, tags=tag)
assert tag in affiliate_event.tags
affiliate_event2 = scan.make_event("1.2.3.4:88", source=affiliate_event)
affiliate_event3 = scan.make_event("4.3.2.1:88", source=affiliate_event)
assert tag in affiliate_event2.tags
assert tag not in affiliate_event3.tags

# event sorting
parent1 = scan.make_event("127.0.0.1", source=scan.root_event)
parent2 = scan.make_event("127.0.0.1", source=scan.root_event)
Expand Down

0 comments on commit 61dfc0b

Please sign in to comment.