Skip to content

Commit 8f9043a

Browse files
fix: unknown values in metrics cvedb
1 parent e8a0f7f commit 8f9043a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

cve_bin_tool/cvedb.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,14 @@ def refresh_cache_and_update_db(self) -> None:
310310
self.create_exploit_db()
311311
self.update_exploits()
312312

313+
# Check if metrics need to be updated
314+
cursor = self.db_open_and_get_cursor()
315+
if not self.latest_schema("metrics", self.TABLE_SCHEMAS["metrics"], cursor):
316+
self.LOGGER.info("Updating metrics data.")
317+
self.populate_metrics()
318+
self.connection.commit()
319+
self.db_close()
320+
313321
def get_cvelist_if_stale(self) -> None:
314322
"""Update if the local db is more than one day old.
315323
This avoids the full slow update with every execution.
@@ -370,7 +378,13 @@ def latest_schema(
370378
if table_schema == current_schema:
371379
schema_latest = True
372380

373-
# check for cve_
381+
# Check for metrics table schema
382+
if table_name == "metrics":
383+
result = cursor.execute(
384+
"SELECT * FROM metrics WHERE metrics_id=?", (UNKNOWN_METRIC_ID,)
385+
)
386+
if not result.fetchone():
387+
schema_latest = False
374388

375389
return schema_latest
376390

0 commit comments

Comments
 (0)