Skip to content

Commit

Permalink
fix event tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechromancer committed Oct 13, 2023
1 parent 5d896b5 commit 14f38dc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 22 deletions.
2 changes: 1 addition & 1 deletion bbot/modules/internal/speculate.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async def setup(self):
port_string = self.config.get("ports", "80,443")

try:
self.ports = self.helpers.parse_port_string(port_string)
self.ports = self.helpers.parse_port_string(str(port_string))
except ValueError as e:
self.warning(f"Error parsing ports: {e}")
return False
Expand Down
17 changes: 9 additions & 8 deletions bbot/scanner/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,15 @@ async def _emit_event(self, event, **kwargs):

# Scope shepherding
# here is where we make sure in-scope events are set to their proper scope distance
if event.host and event_whitelisted:
log.debug(f"Making {event} in-scope")
event.scope_distance = 0
elif (not event.always_emit) and event.scope_distance > self.scan.scope_report_distance:
log.debug(
f"Making {event} internal because its scope_distance ({event.scope_distance}) > scope_report_distance ({self.scan.scope_report_distance})"
)
event.make_internal()
if event.host:
if event_whitelisted:
log.debug(f"Making {event} in-scope")
event.scope_distance = 0
elif (not event.always_emit) and event.scope_distance > self.scan.scope_report_distance:
log.debug(
f"Making {event} internal because its scope_distance ({event.scope_distance}) > scope_report_distance ({self.scan.scope_report_distance})"
)
event.make_internal()

# check for wildcards
if event.scope_distance <= self.scan.scope_search_distance:
Expand Down
13 changes: 0 additions & 13 deletions bbot/test/test_step_1/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,6 @@ async def test_events(events, scan, helpers, bbot_config):
internal_event1 = scan.make_event("1.2.3.4", source=root_event, internal=True)
assert internal_event1._internal == True
assert "internal" in internal_event1.tags
internal_event1.scope_distance = 0
assert internal_event1._internal == False
assert "internal" not in internal_event1.tags
internal_event2 = scan.make_event("2.3.4.5", source=internal_event1, internal=True)
internal_event3 = scan.make_event("3.4.5.6", source=internal_event2, internal=True)
internal_event4 = scan.make_event("4.5.6.7", source=internal_event3)
source_trail = internal_event4.scope_distance = 0
assert internal_event4._internal == False
assert internal_event3._internal == False
assert internal_event2._internal == False
assert len(source_trail) == 2
assert internal_event2 in source_trail
assert internal_event3 in source_trail

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

0 comments on commit 14f38dc

Please sign in to comment.