From 7c7cb7b7a8c53f14fa5d6cc436f3ec4f7f7cbcc4 Mon Sep 17 00:00:00 2001 From: Ben Selwyn-Smith Date: Mon, 18 Nov 2024 14:31:32 +1000 Subject: [PATCH] chore: fix after rebase Signed-off-by: Ben Selwyn-Smith --- src/macaron/repo_finder/repo_finder.py | 10 ++++------ src/macaron/repo_finder/repo_finder_java.py | 5 ----- src/macaron/repo_finder/repo_utils.py | 2 +- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/macaron/repo_finder/repo_finder.py b/src/macaron/repo_finder/repo_finder.py index e9f36bc2a..253c285ec 100644 --- a/src/macaron/repo_finder/repo_finder.py +++ b/src/macaron/repo_finder/repo_finder.py @@ -161,7 +161,7 @@ def find_source(purl_string: str, input_repo: str | None) -> bool: found_repo = input_repo if not input_repo: logger.debug("Searching for repo of PURL: %s", purl) - found_repo = find_repo(purl) + found_repo, _ = find_repo(purl) if not found_repo: logger.error("Could not find repo for PURL: %s", purl) @@ -174,7 +174,7 @@ def find_source(purl_string: str, input_repo: str | None) -> bool: logger.debug("Preparing repo: %s", found_repo) repo_dir = os.path.join(global_config.output_path, GIT_REPOS_DIR) logging.getLogger("macaron.slsa_analyzer.git_url").disabled = True - git_obj = prepare_repo( + git_obj, _, digest = prepare_repo( repo_dir, found_repo, purl=purl, @@ -185,9 +185,7 @@ def find_source(purl_string: str, input_repo: str | None) -> bool: logger.error("Could not resolve repository: %s", found_repo) return False - try: - digest = git_obj.get_head().hash - except ValueError: + if not digest: logger.debug("Could not retrieve commit hash from repository.") return False else: @@ -196,7 +194,7 @@ def find_source(purl_string: str, input_repo: str | None) -> bool: if not tags: return False - matches = match_tags(list(tags.keys()), purl.name, purl.version) + matches, _ = match_tags(list(tags.keys()), purl.name, purl.version) if not matches: return False diff --git a/src/macaron/repo_finder/repo_finder_java.py b/src/macaron/repo_finder/repo_finder_java.py index 0c94a5a98..d5588d1cc 100644 --- a/src/macaron/repo_finder/repo_finder_java.py +++ b/src/macaron/repo_finder/repo_finder_java.py @@ -66,11 +66,6 @@ def find_repo(self, purl: PackageURL) -> tuple[str, RepoFinderOutcome]: last_outcome = RepoFinderOutcome.FOUND check_parents = defaults.getboolean("repofinder.java", "find_parents") - if not version: - logger.info("Version missing for maven artifact: %s:%s", group, artifact) - # TODO add support for Java artifacts without a version - return "" - while group and artifact and version and limit > 0: # Create the URLs for retrieving the artifact's POM. group = group.replace(".", "/") diff --git a/src/macaron/repo_finder/repo_utils.py b/src/macaron/repo_finder/repo_utils.py index 3cba0fb6d..58470b194 100644 --- a/src/macaron/repo_finder/repo_utils.py +++ b/src/macaron/repo_finder/repo_utils.py @@ -209,7 +209,7 @@ def prepare_repo( # Find the digest and branch if a version has been specified if not digest and purl and purl.version: - found_digest = find_commit(git_obj, purl) + found_digest, commit_finder_outcome = find_commit(git_obj, purl) if not found_digest: logger.error("Could not map the input purl string to a specific commit in the corresponding repository.") return None, commit_finder_outcome, digest