diff --git a/manager/src/grype_db_manager/grypedb.py b/manager/src/grype_db_manager/grypedb.py index c0acbe28..bfe18383 100644 --- a/manager/src/grype_db_manager/grypedb.py +++ b/manager/src/grype_db_manager/grypedb.py @@ -363,7 +363,12 @@ def list_dbs(self) -> list[DBInfo]: class GrypeDB: def __init__(self, bin_path: str, config_path: str = ""): - self.version = os.path.basename(bin_path).removeprefix("grype-db-") + if bin_path: + self.version = os.path.basename(bin_path).removeprefix("grype-db-") + else: + logging.info("using existing grype-db that is on path") + self.version = "" + self.bin_path = bin_path self.config_path = config_path @@ -383,11 +388,14 @@ def list_installed(cls, root_dir: str) -> list[GrypeDB]: @classmethod def install(cls, version: str, config_path: str, root_dir: str) -> GrypeDB: - bin_path = _install_grype_db( - input_version=version, - bin_dir=os.path.join(root_dir, BIN_DIR), - clone_dir=os.path.join(root_dir, CLONE_DIR), - ) + bin_path = None + if version != "disabled": + bin_path = _install_grype_db( + input_version=version, + bin_dir=os.path.join(root_dir, BIN_DIR), + clone_dir=os.path.join(root_dir, CLONE_DIR), + ) + return cls(bin_path=bin_path, config_path=config_path) def build_and_package(self, schema_version: int, provider_root_dir: str, root_dir: str) -> str: @@ -443,7 +451,7 @@ def package_db(self, build_dir: str, provider_root_dir: str) -> None: ) def run(self, *args, provider_root_dir: str, config: str) -> int: - cmd = " ".join([self.bin_path, *args]) + cmd = " ".join([self.bin_path, *args]) if self.bin_path else " ".join(["grype-db", *args]) level = logging.getLevelName(logging.getLogger().getEffectiveLevel()) if level == "TRACE": # trace is not supported in grype-db yet