Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect invocation.configSource.uri value for inferred provenance value. #578

Open
tromai opened this issue Dec 21, 2023 · 1 comment
Open
Labels
bug Something isn't working

Comments

@tromai
Copy link
Member

tromai commented Dec 21, 2023

How to replicate

Run this command:

macaron analyze -rp https://github.com/ben-manes/caffeine.git --skip-deps

Because this repository doesn't have a provenance that Macaron can detect, Macaron put an inferred provenance in the final JSON report.
The content of the JSON report of this analysis is as follow:

...
                             "invocation": {
                                "configSource": {
                                    "uri": "https://github.com/ben-manes/caffeine@refs/heads/None",
...

Description

The logic for generating the content of invocation.configSource.uri for the inferred provenance is located here:

predicate["invocation"]["configSource"]["uri"] = (
    f"{ctx.component.repository.remote_path}"
    f"@refs/heads/{ctx.component.repository.branch_name}"
)

In scenarios where the branch name is not available, the content of this uri will be incorrect

Suggestion

If the branch name is not available for this software component, we can use f"{ctx.component.repository.remote_path}" only without f"@refs/heads/{ctx.component.repository.branch_name}"

@tromai tromai added the bug Something isn't working label Dec 21, 2023
@nathanwn
Copy link
Member

How about using the ctx.component.repository.commit_sha field, which is not nullable, to replace the nullable branch_name?

predicate["invocation"]["configSource"]["uri"] = (
    f"{ctx.component.repository.remote_path}"
-    f"@refs/heads/{ctx.component.repository.branch_name}"
+    f"@{ctx.component.repository.commit_sha}"
)

I think this should be better than not referencing any particular revision of the repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants