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

Function download_vulnerability_report

webapp_modern.py:6528–6555  ·  view source on GitHub ↗

Stream a vulnerability report file while preventing directory traversal. Supports per-network directories via ?network= query param so that download URLs returned by /api/vulnerability-intel can be followed directly when a network context is active. Falls back to the global vulnerabilit

(filename)

Source from the content-addressed store, hash-verified

6526 try:
6527 os.makedirs(cred_results_dir, exist_ok=True)
6528 logger.debug(f"Ensured directory exists: {cred_results_dir}")
6529 except Exception as e:
6530 logger.warning(f"Could not create crackedpwd directory: {e}")
6531
6532 if os.path.exists(cred_results_dir):
6533 cred_count = 0
6534 try:
6535 # Get stable file list (excludes temporary/hidden files) - only CSV files for network storage
6536 cred_files_found = []
6537 for filename in sorted(os.listdir(cred_results_dir)):
6538 if filename.endswith('.csv') and not filename.startswith('.') and not filename.endswith('.tmp'):
6539 filepath = os.path.join(cred_results_dir, filename)
6540 # Only count files that exist and aren't being written to
6541 try:
6542 stat_info = os.stat(filepath)
6543 if stat_info.st_size > 0: # Skip empty files
6544 cred_files_found.append(filename)
6545 except (OSError, IOError):
6546 continue # Skip files that can't be accessed
6547
6548 # Count credentials from stable file list
6549 for filename in cred_files_found:
6550 filepath = os.path.join(cred_results_dir, filename)
6551 try:
6552 # Use more robust file reading with retry for locked files
6553 max_retries = 2
6554 for attempt in range(max_retries):
6555 try:
6556 with open(filepath, 'r', encoding='utf-8', errors='ignore') as f:
6557 lines = f.readlines()
6558 # Skip header row and count data rows only

Callers

nothing calls this directly

Calls 3

warningMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected