MCPcopy
hub / github.com/smicallef/spiderfoot / __startScan

Method __startScan

sfscan.py:259–427  ·  view source on GitHub ↗

Start running a scan. Raises: AssertionError: Never actually raised.

(self)

Source from the content-addressed store, hash-verified

257 self.__dbh.scanInstanceSet(self.__scanId, started, ended, status)
258
259 def __startScan(self):
260 """Start running a scan.
261
262 Raises:
263 AssertionError: Never actually raised.
264 """
265 failed = True
266
267 try:
268 self.__setStatus("STARTING", time.time() * 1000, None)
269 self.__sf.status(f"Scan [{self.__scanId}] for '{self.__target.targetValue}' initiated.")
270
271 self.eventQueue = queue.Queue()
272
273 self.__sharedThreadPool.start()
274
275 # moduleList = list of modules the user wants to run
276 self.__sf.debug(f"Loading {len(self.__moduleList)} modules ...")
277 for modName in self.__moduleList:
278 if not modName:
279 continue
280
281 # Module may have been renamed or removed
282 if modName not in self.__config['__modules__']:
283 self.__sf.error(f"Failed to load module: {modName}")
284 continue
285
286 try:
287 module = __import__('modules.' + modName, globals(), locals(), [modName])
288 except ImportError:
289 self.__sf.error(f"Failed to load module: {modName}")
290 continue
291
292 try:
293 mod = getattr(module, modName)()
294 mod.__name__ = modName
295 except Exception:
296 self.__sf.error(f"Module {modName} initialization failed: {traceback.format_exc()}")
297 continue
298
299 # Set up the module options, scan ID, database handle and listeners
300 try:
301 # Configuration is a combined global config with module-specific options
302 self.__modconfig[modName] = deepcopy(self.__config['__modules__'][modName]['opts'])
303 for opt in list(self.__config.keys()):
304 self.__modconfig[modName][opt] = deepcopy(self.__config[opt])
305
306 # clear any listener relationships from the past
307 mod.clearListeners()
308 mod.setScanId(self.__scanId)
309 mod.setSharedThreadPool(self.__sharedThreadPool)
310 mod.setDbh(self.__dbh)
311 mod.setup(self.__sf, self.__modconfig[modName])
312 except Exception:
313 self.__sf.error(f"Module {modName} initialization failed: {traceback.format_exc()}")
314 mod.errorState = True
315 continue
316

Callers 1

__init__Method · 0.95

Calls 15

__setStatusMethod · 0.95
clearListenersMethod · 0.95
setDbhMethod · 0.95
setTargetMethod · 0.95
notifyListenersMethod · 0.95
waitForThreadsMethod · 0.95
runCorrelationsMethod · 0.95
SpiderFootPluginClass · 0.90
SpiderFootEventClass · 0.90
setScanIdMethod · 0.80
setSharedThreadPoolMethod · 0.80
_updateSocketMethod · 0.80

Tested by

no test coverage detected