-
Notifications
You must be signed in to change notification settings - Fork 179
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
[ANE-1659] update cargo metadata ID parser #1416
Conversation
…mes when there isn't a better option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
-- Prior to Cargo 1.77.0, package IDs looked like this: | ||
-- package version (source URL) | ||
-- adler 1.0.2 (registry+https://github.com/rust-lang/crates.io-index) | ||
-- | ||
-- For 1.77.0 and later, they look like this: | ||
-- registry source URL with a fragment of package@version | ||
-- registry+https://github.com/rust-lang/crates.io-index#adler@1.0.2 | ||
-- or | ||
-- path source URL with a fragment of package@version | ||
-- path+file:///Users/scott/projects/health-data/health_data#package_name@0.1.0 | ||
-- or | ||
-- path source URL with a fragment of version | ||
-- In this case we grab the last entry in the path to use for the package name | ||
-- path+file:///Users/scott/projects/health-data/health_data#0.1.0 | ||
-- | ||
-- Package Spec: https://doc.rust-lang.org/cargo/reference/pkgid-spec.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comments you added in this file are great!! It makes it really easy to follow and understand the implementation logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scott wrote the big one and made the testing setup, so thank you @spatten .
Co-authored-by: Jeffrey Huynh <jeffrey@fossa.com>
Overview
Cargo changed the format of project IDs in the output of
cargo metadata
.Prior to cargo 1.77.0 they looked like this:
For 1.77.0 and greater, they look like this, as defined in https://doc.rust-lang.org/nightly/cargo/reference/pkgid-spec.html
For path dependencies, I've seen them with and without the package name in the fragment:
or
Acceptance criteria
cargo metadata
for new versions of cargocargo metadata
with older versions of cargoTesting plan
Use rustup to install an old and a new version of cargo:
Now, analyze a cargo project with both the old version:
Clean up those output files (you sometimes get some cruft from
cabal run
at the beginning) and then run them through jq or otherwise prettify them.You should now see no difference when you diff the output.
Chris: I did this with foundation which has a mix of path deps and regular ones and got no differences:
Risks
Metrics
References
https://fossa.atlassian.net/browse/ANE-1659
https://teamfossa.slack.com/archives/C043EM3L96Z/p1713558253884749
Checklist
- [ ] If this PR introduced a user-visible change, I added documentation intodocs/
.- [ ] If this PR added docs, I added links as appropriate to the user manual's ToC indocs/README.ms
and gave consideration to how discoverable or not my documentation is.Changelog.md
. If this PR did not mark a release, I added my changes into an# Unreleased
section at the top.- [ ] If I made changes to.fossa.yml
orfossa-deps.{json.yml}
, I updateddocs/references/files/*.schema.json
AND I have updated example files used byfossa init
command. You may also need to update these if you have added/removed new dependency type (e.g.pip
) or analysis target type (e.g.poetry
).- [ ] If I made changes to a subcommand's options, I updateddocs/references/subcommands/<subcommand>.md
.