Skip to content

Commit

Permalink
revised test
Browse files Browse the repository at this point in the history
  • Loading branch information
liquidsec committed Jul 13, 2023
1 parent 16839f5 commit 904dc3b
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions bbot/test/test_step_1/test_modules_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,43 +114,47 @@ async def test_modules_basic(scan, helpers, events, bbot_config, bbot_scanner, h
# ensure that multiple events to the same "host" (schema + host) are blocked and check the per host tracker
for module_name, module in sorted(per_host_scan.modules.items()):
if "URL" in module.watched_events:
url_1 = per_host_scan.make_event("http://evilcorp.com/1", source=scan2.root_event)
url_2 = per_host_scan.make_event("http://evilcorp.com/2", source=scan2.root_event)
valid_1, reason_1 = await base_module._event_postcheck(url_1)
valid_2, reason_2 = await base_module._event_postcheck(url_2)
url_1 = per_host_scan.make_event(
"URL", "http://evilcorp.com/1", source=per_host_scan.root_event, tags=["status-200"]
)
url_2 = per_host_scan.make_event(
"URL", "http://evilcorp.com/2", source=per_host_scan.root_event, tags=["status-200"]
)
valid_1, reason_1 = await module._event_postcheck(url_1)
valid_2, reason_2 = await module._event_postcheck(url_2)

if module.per_host_only == True:
assert valid_1 == True
assert valid_2 == False
assert "http://evilcorp.com/" in module._per_host_tracker
assert hash("http://evilcorp.com/") in module._per_host_tracker

else:
assert valid_1 == True
assert valid_2 == False
assert valid_2 == True

elif "DNS_NAME" in module.watched_events:
# no dns-based modules currently use per_host_only, so we have to simulate it
module.per_host_only = False

dns_1 = per_host_scan.make_event("evilcorp.com", source=scan2.root_event)
dns_2 = per_host_scan.make_event("evilcorp.com", source=scan2.root_event)
dns_valid_1, dns_reason_1 = await base_module._event_postcheck(dns_1)
dns_valid_2, dns_reason_2 = await base_module._event_postcheck(dns_2)
dns_1 = per_host_scan.make_event("evilcorp.com", source=per_host_scan.root_event)
dns_2 = per_host_scan.make_event("evilcorp.com", source=per_host_scan.root_event)
dns_valid_1, dns_reason_1 = await module._event_postcheck(dns_1)
dns_valid_2, dns_reason_2 = await module._event_postcheck(dns_2)

assert dns_valid_1 == True
assert dns_valid_2 == True

module.per_host_only = True

dns_1 = per_host_scan.make_event("evilcorp.com", source=scan2.root_event)
dns_2 = per_host_scan.make_event("evilcorp.com", source=scan2.root_event)
dns_valid_1, dns_reason_1 = await base_module._event_postcheck(dns_1)
dns_valid_2, dns_reason_2 = await base_module._event_postcheck(dns_2)
dns_1 = per_host_scan.make_event("evilcorp.com", source=per_host_scan.root_event)
dns_2 = per_host_scan.make_event("evilcorp.com", source=per_host_scan.root_event)
dns_valid_1, dns_reason_1 = await module._event_postcheck(dns_1)
dns_valid_2, dns_reason_2 = await module._event_postcheck(dns_2)

assert dns_valid_1 == True
assert dns_valid_2 == False

assert "evilcorp.com" in module._per_host_tracker
assert hash("evilcorp.com") in module._per_host_tracker

# module preloading
all_preloaded = module_loader.preloaded()
Expand Down

0 comments on commit 904dc3b

Please sign in to comment.