Skip to content

Commit

Permalink
Store to sqlite
Browse files Browse the repository at this point in the history
Signed-off-by: Prabhu Subramanian <[email protected]>
  • Loading branch information
prabhu committed Mar 16, 2024
1 parent 4337b97 commit cb10388
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions vdb/lib/cve.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,22 +353,25 @@ def store5(self, data: list[CVE]):
cve_id = d.cveMetadata.cveId
if d.containers.cna and d.containers.cna.affected:
for affected in d.containers.cna.affected.root:
cve_id = cve_id.model_dump(mode="python")
versions: list[Versions] = affected.versions
source_data = d.model_dump(mode="json",
exclude_defaults=True,
exclude_unset=True,
exclude_none=True)
self.db_conn.execute(
"INSERT INTO cve_data values(?, ?, ?, ?, ?, ?);", (
cve_id.model_dump(mode="python"), affected.vendor,
cve_id,
affected.vendor,
affected.product,
affected.packageName,
pickle.dumps(source_data),
None))
cleaned_versions = [v.model_dump(mode="json", exclude_none=True) for v in versions]
self.index_conn.execute(
"INSERT INTO cve_index values(?, ?, ?, ?, json(?));", (
cve_id.model_dump(mode="python"), affected.vendor,
cve_id,
affected.vendor,
affected.product,
affected.packageName,
orjson.dumps(cleaned_versions).decode("utf-8", "ignore")
Expand Down

0 comments on commit cb10388

Please sign in to comment.