Skip to content

Commit

Permalink
fix stats tests
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Oct 15, 2024
1 parent c59ab92 commit 5ab09d1
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions bbot/test/test_step_1/test_modules_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,21 +380,22 @@ async def handle_event(self, event):
scan.modules["dummy"] = dummy(scan)
events = [e async for e in scan.async_start()]

assert len(events) == 9
assert len(events) == 10
for e in events:
log.critical(e)
assert 2 == len([e for e in events if e.type == "SCAN"])
assert 3 == len([e for e in events if e.type == "DNS_NAME"])
assert 4 == len([e for e in events if e.type == "DNS_NAME"])
# one from target and one from speculate
assert 2 == len([e for e in events if e.type == "DNS_NAME" and e.data == "evilcorp.com"])
# the reason we don't have a DNS_NAME for www.evilcorp.com is because FINDING.quick_emit = True
assert 0 == len([e for e in events if e.type == "DNS_NAME" and e.data == "www.evilcorp.com"])
assert 1 == len([e for e in events if e.type == "DNS_NAME" and e.data == "www.evilcorp.com"])
assert 1 == len([e for e in events if e.type == "DNS_NAME" and e.data == "asdf.evilcorp.com"])
assert 1 == len([e for e in events if e.type == "ORG_STUB" and e.data == "evilcorp"])
assert 1 == len([e for e in events if e.type == "FINDING"])
assert 1 == len([e for e in events if e.type == "URL_UNVERIFIED"])

assert scan.stats.events_emitted_by_type == {
"SCAN": 1,
"DNS_NAME": 3,
"DNS_NAME": 4,
"URL": 1,
"ORG_STUB": 1,
"URL_UNVERIFIED": 1,
Expand All @@ -414,34 +415,34 @@ async def handle_event(self, event):
assert dummy_stats.produced == {"FINDING": 1, "URL": 1}
assert dummy_stats.produced_total == 2
assert dummy_stats.consumed == {
"DNS_NAME": 2,
"DNS_NAME": 3,
"FINDING": 1,
"OPEN_TCP_PORT": 1,
"ORG_STUB": 1,
"SCAN": 1,
"URL": 1,
"URL_UNVERIFIED": 1,
}
assert dummy_stats.consumed_total == 8
assert dummy_stats.consumed_total == 9

python_stats = scan.stats.module_stats["python"]
assert python_stats.produced == {}
assert python_stats.produced_total == 0
assert python_stats.consumed == {
"DNS_NAME": 3,
"DNS_NAME": 4,
"FINDING": 1,
"ORG_STUB": 1,
"SCAN": 1,
"URL": 1,
"URL_UNVERIFIED": 1,
}
assert python_stats.consumed_total == 8
assert python_stats.consumed_total == 9

speculate_stats = scan.stats.module_stats["speculate"]
assert speculate_stats.produced == {"DNS_NAME": 1, "URL_UNVERIFIED": 1, "ORG_STUB": 1}
assert speculate_stats.produced_total == 3
assert speculate_stats.consumed == {"URL": 1, "DNS_NAME": 2, "URL_UNVERIFIED": 1, "IP_ADDRESS": 2}
assert speculate_stats.consumed_total == 6
assert speculate_stats.consumed == {"URL": 1, "DNS_NAME": 3, "URL_UNVERIFIED": 1, "IP_ADDRESS": 3}
assert speculate_stats.consumed_total == 8


@pytest.mark.asyncio
Expand Down

0 comments on commit 5ab09d1

Please sign in to comment.