This commit is contained in:
mtimvik 2026-07-09 17:10:55 +05:00 committed by GitHub
commit 8cd941c3e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5,6 +5,7 @@
# This project is not affiliated with or endorsed by SIA Mikrotīkls # This project is not affiliated with or endorsed by SIA Mikrotīkls
import json, re, os, requests, time import json, re, os, requests, time
from datetime import datetime
from packaging.version import Version, InvalidVersion from packaging.version import Version, InvalidVersion
from colorama import Fore, Style from colorama import Fore, Style
@ -13,6 +14,7 @@ NVD_URL = "https://services.nvd.nist.gov/rest/json/cves/2.0"
KEYWORD = "routeros" KEYWORD = "routeros"
RESULTS_PER_PAGE = 2000 RESULTS_PER_PAGE = 2000
OUTPUT_FILE = "routeros_cves.json" OUTPUT_FILE = "routeros_cves.json"
TIMEDRIFT = 900 # 900 seconds
GUTTER = 2 # spaces between columns GUTTER = 2 # spaces between columns
@ -261,8 +263,17 @@ def load_cve_data():
fetch_all_cves() fetch_all_cves()
else: else:
print(Fore.YELLOW + f"[?] {OUTPUT_FILE} already exists.") print(Fore.YELLOW + f"[?] {OUTPUT_FILE} already exists.")
answer = input(Fore.YELLOW + " Overwrite it with fresh CVE data? [yes/no]: ").strip().lower() # Get file last change date
if answer == "yes": file_mtime = os.path.getmtime(OUTPUT_FILE)
current_time = time.time()
time_diff = current_time - file_mtime
#answer = input(Fore.YELLOW + " Overwrite it with fresh CVE data? [yes/no]: ").strip().lower()
#if answer == "no":
if time_diff < TIMEDRIFT:
print(Fore.GREEN + f" File is recent (modified {time_diff:.0f}s ago). Skipping download.")
else:
#if answer == "yes":
print(Fore.YELLOW + f" File is old (modified {time_diff:.0f}s ago). Downloading fresh data...")
fetch_all_cves() fetch_all_cves()
try: try: