Skip to content

Commit 5aa1321

Browse files
authored
chore: add config option to disable latest PURL retrieval (#1011)
Signed-off-by: Ben Selwyn-Smith <benselwynsmith@googlemail.com>
1 parent 4d1d8ee commit 5aa1321

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

src/macaron/config/defaults.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ use_open_source_insights = True
5959
redirect_urls =
6060
gitbox.apache.org
6161
git-wip-us.apache.org
62+
# If False, the find-source operation will use git ls-remote to find tags, instead of cloning repositories.
6263
find_source_should_clone = False
64+
# If True, the Repo Finder will try to find and use the latest version of a PURL when the provided version fails
65+
# to return a valid repository.
66+
try_latest_purl = True
6367

6468
[repofinder.java]
6569
# The list of maven-like repositories to attempt to retrieve artifact POMs from.

src/macaron/repo_finder/repo_finder.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ def find_repo(purl: PackageURL, check_latest_version: bool = True) -> tuple[str,
103103
logger.debug("Analyzing %s with Repo Finder: %s", purl, type(repo_finder))
104104
found_repo, outcome = repo_finder.find_repo(purl)
105105

106+
if check_latest_version and not defaults.getboolean("repofinder", "try_latest_purl", fallback=True):
107+
check_latest_version = False
108+
106109
if found_repo or not check_latest_version:
107110
return found_repo, outcome
108111

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2025 - 2025, Oracle and/or its affiliates. All rights reserved.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
3+
4+
[repofinder]
5+
try_latest_purl = False

tests/integration/cases/apache_maven_sbom/test.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2024 - 2024, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2024 - 2025, Oracle and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
33

44
description: |
@@ -12,6 +12,7 @@ steps:
1212
- name: Run macaron analyze
1313
kind: analyze
1414
options:
15+
ini: config.ini
1516
command_args:
1617
- -purl
1718
- pkg:maven/org.apache.maven/maven@4.0.0-alpha-1-SNAPSHOT?type=pom

0 commit comments

Comments
 (0)