first commit
This commit is contained in:
75
full_scan.py
Normal file
75
full_scan.py
Normal file
@@ -0,0 +1,75 @@
|
||||
#!/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())
|
||||
Reference in New Issue
Block a user