MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / __init__

Method __init__

advanced_vuln_scanner.py:436–502  ·  view source on GitHub ↗
(self, shared_data=None)

Source from the content-addressed store, hash-verified

434 ],
435 }
436
437 # Common test parameter names for synthetic fuzz targets
438 FUZZ_SYNTHETIC_PARAMS = [
439 'id', 'q', 'search', 'query', 'name', 'page', 'redirect',
440 'url', 'file', 'path', 'callback', 'next', 'return', 'ref',
441 ]
442
443 def __init__(self, shared_data=None):
444 self.shared_data = shared_data
445 self._lock = threading.Lock()
446
447 # Scan tracking
448 self.active_scans: Dict[str, ScanProgress] = {}
449 self.scan_results: Dict[str, List[VulnerabilityFinding]] = {}
450 self._scan_counter = 0
451
452 # Running subprocess handles, keyed by scan_id, so cancel_scan can
453 # actually terminate the external tool (nuclei/nikto/sqlmap/nmap/whatweb).
454 # A list per scan_id because a Full scan runs several tools concurrently.
455 self._scan_processes: Dict[str, List[subprocess.Popen]] = {}
456 self._scan_processes_lock = threading.Lock()
457 # PIDs launched in their own session (start_new_session=True) so we can
458 # kill the whole process group — e.g. nuclei under a systemd-run scope,
459 # or nuclei plus the helpers it spawns — instead of just the leader.
460 self._session_leader_pids: set = set()
461 # Delegated (mesh) scans: scan_id -> {'peer_io':..., 'remote_id':...}.
462 # These run on a capable peer but appear in active_scans/scan_results
463 # exactly like a local scan, so the whole UI treats them the same.
464 self._delegated_scans: Dict[str, Dict] = {}
465
466 # Cached result of the passwordless-sudo probe for nmap
467 self._nmap_sudo_ok: Optional[bool] = None
468
469 # Nuclei template tracking (cached; counting ~10k files is not free)
470 self._nuclei_template_cache: Optional[Dict[str, Any]] = None
471 self._nuclei_template_cache_ts: float = 0.0
472 self._nuclei_template_lock = threading.Lock()
473 self._nuclei_update_lock = threading.Lock()
474 self._nuclei_templates_stop = threading.Event()
475
476 # Scan history (deque for recent scans)
477 from collections import deque
478 self.scan_history: deque = deque(maxlen=100)
479
480 # Scan threading (direct threads instead of ThreadPoolExecutor
481 # to avoid "cannot schedule new futures after interpreter shutdown"
482 # on Python 3.12+/3.13 where atexit shuts down executors early)
483 self._max_workers = 4 # Configurable based on system
484
485 # Tool paths
486 self._tool_paths = {}
487 self._detect_tools()
488
489 # ZAP daemon management
490 self._zap_process: Optional[subprocess.Popen] = None
491 self._zap_port = self.ZAP_DEFAULT_PORT
492 self._zap_api_key = self._generate_api_key()
493 self._zap_base_url = f"http://127.0.0.1:{self._zap_port}"

Callers

nothing calls this directly

Calls 7

_detect_toolsMethod · 0.95
_generate_api_keyMethod · 0.95
_init_databaseMethod · 0.95
get_server_capabilitiesFunction · 0.90
getMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected