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

feat: support parsing gradle/verification-metadata.xml #943

Merged
merged 3 commits into from May 23, 2024

Conversation

G-Rath
Copy link
Collaborator

@G-Rath G-Rath commented Apr 26, 2024

This adds support for parsing gradle/verification-metadata.xml files - since this seems to be like an actual lockfile it's very straightforward: we just parse the file as XML and extract out the name + version of "component".

The interesting part of this is that unlike other project-relative lockfiles this file currently must exist in the gradle directory which raises questions about how --recursive comes into play previously we'd not enabled APK and DPKG checking by default but I feel that was more because they were absolute paths and so didn't make sense to do when people were scanning in "project mode".

For now I've just taken the simple route of making the file gradle/verification-metadata.xml since that does just work (except for the "find parser" flow which checks against path.Base so that has the gradle omitted).

Resolves #915

@cuixq cuixq self-requested a review April 30, 2024 03:35
@G-Rath G-Rath force-pushed the support-gradle-dv branch 2 times, most recently from 5bc2c13 to 5109113 Compare May 1, 2024 00:05
@codecov-commenter
Copy link

codecov-commenter commented May 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.14%. Comparing base (1fa7d7a) to head (f89731a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #943      +/-   ##
==========================================
+ Coverage   64.07%   64.14%   +0.07%     
==========================================
  Files         146      147       +1     
  Lines       11983    12008      +25     
==========================================
+ Hits         7678     7703      +25     
  Misses       3853     3853              
  Partials      452      452              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

)

type GradleVerificationMetadataFile struct {
// XMLName xml.Name `xml:"project"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the reminder - I was meant to double check what this is actually doing and if we need it

| Dart | `pubspec.lock` |
| Elixir | `mix.lock` |
| Go | `go.mod` |
| Java | `buildscript-gradle.lockfile`<br>`gradle.lockfile`<br>`pom.xml`[\*](https://github.com/google/osv-scanner/issues/35),<br>`gradle/verification-metadata.xml` |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be alphabetical order?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah good point - I originally thought the * was applying to all of these but its actually just pom.xml so we could sort it alphabetically.

t.Parallel()

tests := []struct {
name string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete name if it is not used in t.Run

Copy link
Collaborator Author

@G-Rath G-Rath May 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is being used though? t.Run(tt.name, func(t *testing.T) {

I support not putting a name on this these tests as I think it's obvious what they do, but we've implicitly got the convention of always including the name field even if its blank for consistency and so that you can choose to name a new test in future.

@oliverchang oliverchang requested a review from cuixq May 23, 2024 04:19
@cuixq
Copy link
Contributor

cuixq commented May 23, 2024

I think I reviewed it and pending changes from @G-Rath

@G-Rath
Copy link
Collaborator Author

G-Rath commented May 23, 2024

@cuixq if you're requiring changes, could you submit a review requesting changes? The only outstanding change I know of that is needed is this one (which I'd completely forgotten about 😅), but that shouldn't hold up others reviewing it.

@G-Rath
Copy link
Collaborator Author

G-Rath commented May 23, 2024

Also when we last discussed this, I believe some research was going to be done into the Maven ecosystem to determine how appropriate supporting this file was, which was to be done by @cuixq

Copy link
Contributor

@cuixq cuixq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to comment last time with my findings: I think it makes sense to support vertification-metadata.xml. I can see this in open source projects - some of these projects may not have gradle.build so verification-metadata.xml definitely helps with understanding these projects.

@cuixq cuixq merged commit e6b3fd4 into google:main May 23, 2024
13 checks passed
@G-Rath G-Rath deleted the support-gradle-dv branch May 23, 2024 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support gradle's verification-metadata.xml?
3 participants