Skip to content

Commit 639fd49

Browse files
authored
fix: Add warning for slow schema updates, bump version to 3.2 (#2447)
* fix: Add warning for slow schema updates, bump version to 3.2 * fix: make latest_schema work if no arguments specified * fix: improve messages per Anthony's comments
1 parent fe126b1 commit 639fd49

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

cve_bin_tool/cvedb.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,17 @@ def get_cvelist_if_stale(self) -> None:
157157
self.time_of_last_update = datetime.datetime.today()
158158

159159
def latest_schema(
160-
self, table_name: str, table_schema: str, cursor: sqlite3.Cursor | None = None
160+
self,
161+
table_name: str = "",
162+
table_schema: str = "",
163+
cursor: sqlite3.Cursor | None = None,
161164
) -> bool:
162165
"""Check database is using latest schema"""
166+
if table_name == "":
167+
# If no table specified, check cve_range (the last one changed)
168+
_, range_schema = self.table_schemas()
169+
return self.latest_schema("cve_range", range_schema)
170+
163171
self.LOGGER.debug("Check database is using latest schema")
164172
cursor = self.db_open_and_get_cursor()
165173
schema_check = f"SELECT * FROM {table_name} WHERE 1=0"
@@ -265,13 +273,19 @@ def init_database(self) -> None:
265273
# Check schema on cve_severity
266274
if not self.latest_schema("cve_severity", severity_schema, cursor):
267275
# Recreate table using latest schema
268-
self.LOGGER.info("Upgrading database cve_severity to latest schema")
276+
self.LOGGER.info("Upgrading cve_severity data. This may take some time.")
277+
self.LOGGER.info(
278+
"If this step hangs, try using `-u now` to get a fresh db."
279+
)
269280
cursor.execute("DROP TABLE cve_severity")
270281
cursor.execute(cve_data_create)
271282

272283
# Check schema on cve_range
273284
if not self.latest_schema("cve_range", range_schema, cursor):
274-
self.LOGGER.info("Upgrading database cve_range to latest schema")
285+
self.LOGGER.info("Upgrading cve_range data. This may take some time.")
286+
self.LOGGER.info(
287+
"If this step hangs, try using `-u now` to get a fresh db."
288+
)
275289
cursor.execute("DROP TABLE cve_range")
276290
cursor.execute(version_range_create)
277291

cve_bin_tool/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from cve_bin_tool.log import LOGGER
1010

11-
VERSION: str = "3.2rc0"
11+
VERSION: str = "3.2"
1212

1313

1414
def check_latest_version():

0 commit comments

Comments
 (0)