generated from oracle/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: find repo from latest artifact when provided artifact has none (#…
…931) This PR adds new functionality to the Repo Finder: If the repository of the provided artifact cannot be found for the specified version, the latest version will be checked instead. The latest version will also be checked in cases where the repository was found, but the sought version (tag) did not exist within it. Signed-off-by: Ben Selwyn-Smith <[email protected]>
- Loading branch information
Showing
8 changed files
with
414 additions
and
196 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
tests/integration/cases/latest_repo_comparison/check_output.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
# Copyright (c) 2024 - 2024, Oracle and/or its affiliates. All rights reserved. | ||
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/. | ||
|
||
[[ "$(jq -r '.commit' output/reports/maven/io_avaje/avaje-prisms/avaje-prisms.source.json)" = "1f6f953df0b58f0c35b5e136f62f63ba7a22bc03" ]] && | ||
[[ "$(jq -r '.repo' output/reports/maven/io_avaje/avaje-prisms/avaje-prisms.source.json)" = "https://github.com/avaje/avaje-prisms" ]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright (c) 2024 - 2024, Oracle and/or its affiliates. All rights reserved. | ||
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/. | ||
|
||
description: | | ||
Check that the find-source and analyze commands behave the same for a given artifact. | ||
tags: | ||
- macaron-python-package | ||
- macaron-docker-image | ||
|
||
steps: | ||
- name: Run macaron find source | ||
kind: find-source | ||
options: | ||
command_args: | ||
- -purl | ||
- pkg:maven/io.avaje/[email protected] | ||
- name: Check that the repository was not cloned | ||
kind: shell | ||
options: | ||
cmd: ls output/git_repos/github.com/avaje/avaje-prisms/ | ||
expect_fail: true | ||
- name: Check the report contents | ||
kind: shell | ||
options: | ||
cmd: ./check_output.sh | ||
- name: Run macaron analyze | ||
kind: analyze | ||
options: | ||
command_args: | ||
- -purl | ||
- pkg:maven/io.avaje/[email protected] | ||
- name: Check that correct repository was cloned | ||
kind: shell | ||
options: | ||
cmd: ls output/git_repos/github.com/avaje/avaje-prisms/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
from macaron.config.defaults import defaults | ||
from macaron.repo_finder import repo_validator | ||
from macaron.repo_finder.repo_finder import find_repo | ||
from macaron.repo_finder.repo_finder_deps_dev import DepsDevRepoFinder | ||
from macaron.slsa_analyzer.git_url import clean_url | ||
|
||
logger: logging.Logger = logging.getLogger(__name__) | ||
|
@@ -70,6 +71,21 @@ def test_repo_finder() -> int: | |
if not parsed_url or not repo_validator.resolve_redirects(parsed_url): | ||
return os.EX_UNAVAILABLE | ||
|
||
# Test Java package whose SCM metadata only points to the repo in later versions than is provided here. | ||
purl = PackageURL.from_string("pkg:maven/io.vertx/[email protected]") | ||
repo = find_repo(purl) | ||
if repo == "https://github.com/eclipse-vertx/vertx-auth": | ||
return os.EX_UNAVAILABLE | ||
latest_purl = DepsDevRepoFinder().get_latest_version(purl) | ||
assert latest_purl | ||
repo = find_repo(latest_purl) | ||
if repo != "https://github.com/eclipse-vertx/vertx-auth": | ||
return os.EX_UNAVAILABLE | ||
|
||
# Test Java package that has no version. | ||
if not find_repo(PackageURL.from_string("pkg:maven/io.vertx/vertx-auth-common")): | ||
return os.EX_UNAVAILABLE | ||
|
||
return os.EX_OK | ||
|
||
|
||
|