File tree 1 file changed +15
-1
lines changed
1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -310,6 +310,14 @@ def refresh_cache_and_update_db(self) -> None:
310
310
self .create_exploit_db ()
311
311
self .update_exploits ()
312
312
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
+
313
321
def get_cvelist_if_stale (self ) -> None :
314
322
"""Update if the local db is more than one day old.
315
323
This avoids the full slow update with every execution.
@@ -370,7 +378,13 @@ def latest_schema(
370
378
if table_schema == current_schema :
371
379
schema_latest = True
372
380
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
374
388
375
389
return schema_latest
376
390
You can’t perform that action at this time.
0 commit comments