Skip to content

Commit

Permalink
go back to blob
Browse files Browse the repository at this point in the history
Signed-off-by: Prabhu Subramanian <[email protected]>
  • Loading branch information
prabhu committed Mar 19, 2024
1 parent 6dc099c commit ef3f49a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion vdb/lib/cve.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def store5(self, data: list[CVE]):
# Filter obvious duplicates
if not source_completed_keys.get(pkg_key):
dbc.execute(
"INSERT INTO cve_data values(?, ?, ?, ?, json(?), ?, ?);", (
"INSERT INTO cve_data values(?, ?, ?, ?, jsonb(?), ?, ?);", (
cve_id,
affected.vendor,
affected.product,
Expand Down
2 changes: 1 addition & 1 deletion vdb/lib/db6.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
def ensure_schemas(db_conn_obj: apsw.Connection, index_conn_obj: apsw.Connection):
"""Create the sqlite tables and indexes in case they don't exist"""
db_conn_obj.execute(
"CREATE TABLE if not exists cve_data(cve_id TEXT NOT NULL, type TEXT NOT NULL, namespace TEXT, name TEXT NOT NULL, source_data JSON NOT NULL, override_data JSON, source_data_hash TEXT NOT NULL);")
"CREATE TABLE if not exists cve_data(cve_id TEXT NOT NULL, type TEXT NOT NULL, namespace TEXT, name TEXT NOT NULL, source_data BLOB NOT NULL, override_data BLOB, source_data_hash TEXT NOT NULL);")
db_conn_obj.pragma("synchronous", "OFF")
db_conn_obj.pragma("journal_mode", "MEMORY")
index_conn_obj.execute(
Expand Down
6 changes: 3 additions & 3 deletions vdb/lib/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def get_cve_data(db_conn, index_hits: list[dict, Any], search_str: str) -> list[
data_list = []
for ahit in index_hits:
results = exec_query(db_conn,
"SELECT cve_id, type, namespace, name, source_data, override_data FROM cve_data WHERE cve_id = ? AND type = ? ORDER BY cve_id DESC;",
"SELECT cve_id, type, namespace, name, json_object('source', source_data), json_object('override', override_data) FROM cve_data WHERE cve_id = ? AND type = ? ORDER BY cve_id DESC;",
(ahit["cve_id"], ahit["type"]))
for res in results:
data_list.append({
Expand All @@ -48,8 +48,8 @@ def get_cve_data(db_conn, index_hits: list[dict, Any], search_str: str) -> list[
"name": res[3],
"matching_vers": ahit["vers"],
"matched_by": search_str,
"source_data": CVE.model_validate(orjson.loads(res[4]), strict=False) if res[4] else None,
"override_data": orjson.loads(res[5]) if res[5] else None
"source_data": CVE.model_validate(orjson.loads(res[4])["source"], strict=False) if res[4] else None,
"override_data": orjson.loads(res[5])["override"] if res[5] else None
})
return data_list

Expand Down

0 comments on commit ef3f49a

Please sign in to comment.