MCPcopy Create free account
hub / github.com/blacklanternsecurity/bbot / ScanIngress

Class ScanIngress

bbot/scanner/manager.py:8–168  ·  view source on GitHub ↗

This is always the first intercept module in the chain, responsible for basic scope checks It has its own incoming queue, but will also pull events from modules' outgoing queues

Source from the content-addressed store, hash-verified

6
7
8class ScanIngress(BaseInterceptModule):
9 """
10 This is always the first intercept module in the chain, responsible for basic scope checks
11
12 It has its own incoming queue, but will also pull events from modules' outgoing queues
13 """
14
15 watched_events = ["*"]
16 # accept all events regardless of scope distance
17 scope_distance_modifier = None
18 _name = "_scan_ingress"
19 _qsize = -1
20
21 @property
22 def priority(self):
23 # we are the highest priority
24 return -99
25
26 def __init__(self, *args, **kwargs):
27 super().__init__(*args, **kwargs)
28 self._module_priority_weights = None
29 self._non_intercept_modules = None
30 # track incoming duplicates module-by-module (for `suppress_dupes` attribute of modules)
31 self.incoming_dup_tracker = set()
32
33 async def init_events(self, event_seeds=None):
34 """
35 Initializes events by seeding the scanner with target events and distributing them for further processing.
36
37 Notes:
38 - This method populates the event queue with initial target events.
39 - It also marks the Scan object as finished with initialization by setting `_finished_init` to True.
40 """
41 async with (
42 self.scan._acatch(self.init_events, unhandled_is_critical=True),
43 self._task_counter.count(self.init_events),
44 ):
45 if event_seeds is None:
46 event_seeds = self.scan.target.seeds.event_seeds
47 root_event = self.scan.root_event
48 event_seeds = sorted(event_seeds, key=lambda e: (host_size_key(str(e.host)), e.data))
49 # queue root scan event
50 await self.queue_event(root_event, {})
51 target_module = self.scan._make_dummy_module(name="TARGET", _type="TARGET")
52 # queue each target in turn
53 for event_seed in event_seeds:
54 event = self.scan.make_event(
55 event_seed.data,
56 event_seed.type,
57 parent=root_event,
58 module=target_module,
59 context=f"Scan {self.scan.name} seeded with " + "{event.type}: {event.data}",
60 tags=["target"],
61 )
62 self.verbose(f"Target: {event}")
63 # don't fill up the queue with too many events
64 while self.incoming_event_queue.qsize() > 100:
65 await asyncio.sleep(0.2)

Callers 1

load_modulesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…