Files
cve_monitor/full_scan.py
Mateusz Gruszczyński bc1b4279de first commit
2026-02-13 12:42:53 +01:00

76 lines
2.2 KiB
Python

#!/usr/bin/env python3
import logging
import sys
from datetime import datetime
from cve_handler import update_all_vendors, CVEHandler
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.FileHandler(f'logs/full_scan_{datetime.now().strftime("%Y%m%d_%H%M%S")}.log'),
logging.StreamHandler(sys.stdout)
]
)
logger = logging.getLogger(__name__)
def main():
print("=" * 70)
print("CVE MONITOR - FULL SCAN")
print("=" * 70)
print(f"Started at: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
print()
try:
updated, failed = update_all_vendors(force=True)
print()
print("=" * 70)
print("SCAN COMPLETED")
print("=" * 70)
print(f"✓ Successfully updated: {updated} vendors")
print(f"✗ Failed: {failed} vendors")
print(f"Finished at: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
print()
print("=" * 70)
print("DATABASE STATISTICS")
print("=" * 70)
handler = CVEHandler()
summary = handler.get_all_vendors_summary()
total_cves = sum(v['total'] for v in summary)
total_critical = sum(v['critical'] for v in summary)
total_high = sum(v['high'] for v in summary)
print(f"Total CVEs in database: {total_cves}")
print(f" Critical: {total_critical}")
print(f" High: {total_high}")
print()
print("Per vendor breakdown:")
print("-" * 70)
print(f"{'Vendor':<25} {'Total':>8} {'Critical':>10} {'High':>10} {'Recent':>10}")
print("-" * 70)
for v in sorted(summary, key=lambda x: x['total'], reverse=True):
print(f"{v['name']:<25} {v['total']:>8} {v['critical']:>10} {v['high']:>10} {v['recent']:>10}")
print("=" * 70)
return 0 if failed == 0 else 1
except KeyboardInterrupt:
print("\n\n Scan interrupted by user")
return 2
except Exception as e:
logger.error(f"Fatal error during scan: {e}", exc_info=True)
return 3
if __name__ == '__main__':
sys.exit(main())