-
Couldn't load subscription status.
- Fork 471
feat(local): support resolving git packages that have a version specified #2209
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| { | ||
| "results": [ | ||
| { | ||
| "packages": [ | ||
| { | ||
| "//1": "version and commit are the same, so rust-openssl advisories should be reported", | ||
| "//2": "note online reports CVE-2023-6180 as well due to matching commits for an implicit fork", | ||
| "package": { | ||
| "name": "https://github.com/sfackler/rust-openssl", | ||
| "commit": "0f428d190410263e4daa65b917c0e84707a9c0ef", | ||
| "version": "openssl-v0.8.1" | ||
| } | ||
| }, | ||
| { | ||
| "//1": "repo is different to the advisory, so only online checking will report anything", | ||
| "package": { | ||
| "name": "https://github.com/sfackler-fork/rust-openssl", | ||
| "commit": "3b064fdb022912bbb98f5b8d9d111aeb6fec8f79", | ||
| "version": "openssl-v0.10.23" | ||
| } | ||
| }, | ||
| { | ||
| "//1": "no version, so only online checking will report anything", | ||
| "package": { | ||
| "name": "https://github.com/openssl/openssl", | ||
| "commit": "45fda76bc1b9fd74d10e85e0ce9b65a12dcc58b0" | ||
| } | ||
| }, | ||
| { | ||
| "//1": "version is for 3.5.0 which is vulnerable to CVE-2025-3416, but commit is for 3.5.1 which is not", | ||
| "package": { | ||
| "name": "https://github.com/openssl/openssl", | ||
| "commit": "aea7aaf2abb04789f5868cbabec406ea43aa84bf", | ||
| "version": "openssl-3.5.0" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -125,8 +125,26 @@ func AffectsEcosystem(v osvschema.Vulnerability, ecosystemAffected osvecosystem. | |
| return false | ||
| } | ||
|
|
||
| func hasGitRangeForRepo(affected osvschema.Affected, repo string) bool { | ||
| for _, r := range affected.Ranges { | ||
| if r.Type == "GIT" && r.Repo == repo { | ||
| return true | ||
| } | ||
| } | ||
|
|
||
| return false | ||
| } | ||
|
|
||
| func IsAffected(v osvschema.Vulnerability, pkg imodels.PackageInfo) bool { | ||
| for _, affected := range v.Affected { | ||
| // assume we're dealing with a git-source package whose name is the git repository, and that the version is the tag | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be clearer for this comment to be within the If statement? Right now it reads like the if statement is using the assumption, when I guess it's the other way around. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personally I tend to expect comments to be about the statement they precede, and that that tends to be the most common style - there's a number of small factors for that such as the comment is usually explaining the condition rather than the implementation, and editor folding of the content in the braces hides the comment which I find is typically counter to having the comment. In this case, most of the comment is describing the top |
||
| // the underlying commit has been resolved to (somehow), meaning we can check if it's in the versions listed by the advisory | ||
| if pkg.Ecosystem().IsEmpty() && pkg.Commit() != "" && pkg.Version() != "" { | ||
| if hasGitRangeForRepo(affected, pkg.Name()) && slices.Contains(affected.Versions, pkg.Version()) { | ||
| return true | ||
| } | ||
| } | ||
|
|
||
| // Assume vulnerability has already been validated | ||
| if osvecosystem.MustParse(affected.Package.Ecosystem).Equal(pkg.Ecosystem()) && | ||
| affected.Package.Name == pkg.Name() { | ||
|
|
||
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.
I'm surprised this just compiles without casting?
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.
ha yeah I was surprised too - technically it makes sense because the type is a
stringrather than a "enum" even though it gets used in that fashion, so I'm guessing this is triggering an implicit cast that succeeds because the right hand side is a string 🤷(in fact, if I add the cast it gets marked as redundant)