Skip to content

Commit

Permalink
refactor: find SBOM product vendor (#1477)
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyharrison committed Dec 26, 2021
1 parent cd7b07a commit 40d32cc
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions cve_bin_tool/sbom_manager/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Copyright (C) 2021 Anthony Harrison
# SPDX-License-Identifier: GPL-3.0-or-later

import sqlite3
from collections import defaultdict
from logging import Logger
from typing import DefaultDict, Dict, List, Optional
Expand Down Expand Up @@ -83,21 +82,11 @@ def scan_file(self) -> Dict[ProductInfo, TriageData]:
return self.sbom_data

def get_vendor(self, product: str) -> Optional[str]:
self.cvedb.db_open()
if not self.cvedb.connection:
raise ConnectionError()
self.cursor = self.cvedb.connection.cursor()
get_vendor_request = "SELECT DISTINCT VENDOR FROM cve_range where PRODUCT=?"
self.cursor.execute(get_vendor_request, [product])
try:
# If multiple unique vendors then shouldn't proceed....
vendor = self.cursor.fetchone()[0]
# print(f"{product} is produced by {vendor}")
except (sqlite3.Error, TypeError) as e:
LOGGER.debug(e, exc_info=True)
vendor = None
self.cvedb.db_close()
return vendor
vendor_package_pair = self.cvedb.get_vendor_product_pairs(product)
if vendor_package_pair != []:
vendor = vendor_package_pair[0]["vendor"]
return vendor
return None


if __name__ == "__main__":
Expand Down

0 comments on commit 40d32cc

Please sign in to comment.