Extract VCS URL from package.id (pkgid spec) instead of package.source#861
Open
beer4code wants to merge 3 commits intoCycloneDX:mainfrom
Open
Extract VCS URL from package.id (pkgid spec) instead of package.source#861beer4code wants to merge 3 commits intoCycloneDX:mainfrom
beer4code wants to merge 3 commits intoCycloneDX:mainfrom
Conversation
Replace the use of package.source (opaque/unstable) with package.id (stable pkgid spec) for extracting VCS URLs from git dependencies. - Add extract_git_url_from_id helper in purl.rs that strips the #name@version fragment and ?branch=/?tag=/?rev= query params from the pkgid, returning a clean git+proto://host/path URL - Use the helper in get_purl for the PURL vcs_url qualifier, replacing the previous source_to_vcs_url function - Use the helper in get_external_references as a fallback when package.repository is absent on git dependencies - Update git_package.json fixture to use the new pkgid format package.source is explicitly documented as opaque and unstable by the cargo_metadata crate. package.id (the pkgid spec) is the stable alternative. On Rust 1.77+ the pkgid format for git deps is: git+proto://host/path[?query]#name@version. The fragment contains name@version (not a commit hash like package.source does), so the output no longer includes commit hashes. This was recommended by the maintainer in PR CycloneDX#777. Signed-off-by: beer4code <102912454+beer4code@users.noreply.github.com>
Contributor
|
Thanks for the PR!
I'd rather have tests and fixtures for both formats. The old for fallback to source on older versions as described in #854 and the new to extract it from pkgid. |
Signed-off-by: beer4code <102912454+beer4code@users.noreply.github.com>
Signed-off-by: beer4code <102912454+beer4code@users.noreply.github.com>
Author
|
Would you mind having another look please? |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the use of
package.source(opaque/unstable) withpackage.id(stable) for extracting VCS URLs from git dependencies.package.sourceis explicitly documented as opaque and unstable by the cargo_metadata crate.package.id(the pkgid spec) is the stable alternative. On Rust 1.77+ the pkgid format for git deps is:The fragment contains
name@version(not a commit hash likepackage.sourcedoes), so the output no longer includes commit hashes.This PR is supposed to replace #777.
Changes
extract_git_url_from_idhelper inpurl.rsthat strips the#name@versionfragment and?branch=/?tag=/?rev=query params from the pkgid, returning a cleangit+proto://host/pathURLget_purlfor the PURLvcs_urlqualifier, replacing the previoussource_to_vcs_urlfunctionget_external_referencesas a fallback whenpackage.repositoryis absent on git dependenciesgit_package.jsonfixture to use the new pkgid format