Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inherit mutation tags #938

Merged
merged 1 commit into from
Dec 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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