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

Method __init__

bbot/scanner/scanner.py:99–269  ·  view source on GitHub ↗

Initializes the Scanner class. If a premade `preset` is specified, it will be used for the scan. Otherwise, `Scan` accepts the same arguments as `Preset`, which are passed through and used to create a new preset. Args: *targets (list[str], optional): Sc

(
        self,
        *targets,
        name=None,
        scan_id=None,
        dispatcher=None,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

97 }
98
99 def __init__(
100 self,
101 *targets,
102 name=None,
103 scan_id=None,
104 dispatcher=None,
105 **kwargs,
106 ):
107 """
108 Initializes the Scanner class.
109
110 If a premade `preset` is specified, it will be used for the scan.
111 Otherwise, `Scan` accepts the same arguments as `Preset`, which are passed through and used to create a new preset.
112
113 Args:
114 *targets (list[str], optional): Scan targets (passed through to `Preset`).
115 preset (Preset, optional): Preset to use for the scan.
116 scan_id (str, optional): Unique identifier for the scan. Auto-generates if None.
117 dispatcher (Dispatcher, optional): Dispatcher object to use. Defaults to new Dispatcher.
118 **kwargs (list[str], optional): Additional keyword arguments (passed through to `Preset`).
119 """
120 self._root_event = None
121 self._finish_event = None
122 self.start_time = None
123 self.end_time = None
124 self.duration = None
125 self.duration_human = None
126 self.duration_seconds = None
127
128 self._success = False
129 self._scan_finish_status_message = None
130
131 if scan_id is not None:
132 self.id = str(scan_id)
133 else:
134 self.id = f"SCAN:{sha1(rand_string(20)).hexdigest()}"
135
136 custom_preset = kwargs.pop("preset", None)
137 kwargs["_log"] = True
138
139 from .preset import Preset
140
141 if name is not None:
142 kwargs["scan_name"] = name
143
144 base_preset = Preset(*targets, **kwargs)
145
146 if custom_preset is not None:
147 if not isinstance(custom_preset, Preset):
148 raise ValidationError(f'Preset must be of type Preset, not "{type(custom_preset).__name__}"')
149 base_preset.merge(custom_preset)
150
151 self.preset = base_preset.bake(self)
152
153 # scan name
154 if self.preset.scan_name is None:
155 tries = 0
156 while 1:

Callers 1

__init__Method · 0.45

Calls 15

mergeMethod · 0.95
bakeMethod · 0.95
warningMethod · 0.95
sha1Function · 0.90
rand_stringFunction · 0.90
ValidationErrorClass · 0.90
random_nameFunction · 0.90
PresetClass · 0.85
DispatcherClass · 0.85
maxFunction · 0.85
ScanStatsClass · 0.85
popMethod · 0.80

Tested by

no test coverage detected