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

Support Go dependency scanning for pull requests #1012

Merged
merged 4 commits into from
Sep 26, 2023

Conversation

teodor-yanev
Copy link
Member

@teodor-yanev teodor-yanev commented Sep 25, 2023

#912

Add Go PR vulnerabilities check

The vulnerability checks were tested against the following PR: #725

Proof of functional testing:
Screenshot 2023-09-25 at 15 44 31

Closes #1012

@teodor-yanev teodor-yanev self-assigned this Sep 25, 2023
@teodor-yanev teodor-yanev added the dependencies Pull requests that update a dependency file label Sep 25, 2023
jhrozek
jhrozek previously approved these changes Sep 25, 2023
Copy link
Contributor

@jhrozek jhrozek left a comment

Choose a reason for hiding this comment

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

I think that this patch is fine, some suggestions inline.

@@ -15,8 +15,8 @@ pull_request:
vulnerability_database_endpoint: https://api.osv.dev/v1/query
package_repository:
url: https://registry.npmjs.org
- name: go
- name: Go
Copy link
Contributor

Choose a reason for hiding this comment

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

why did you change the name to start with an uppercase letter? btw I wonder if we should just compare the names in a case-insensitive manner so that we'd match all of go, Go, gO and GO.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh I understand now, OSV's databases are case-sensitive..I would honestly make the mediator ecosystems case-insensitive.. (but if you disagree, just tell me that it's a bad idea..).

tested with:

curl -X POST -d \
  '{"version": "0.0.1",
    "package": {"name": "golang.org/x/net", "ecosystem": "Go"}}' \
  "https://api.osv.dev/v1/query" | jq

versus:

curl -X POST -d \
  '{"version": "0.0.1",
    "package": {"name": "golang.org/x/net", "ecosystem": "go"}}' \
  "https://api.osv.dev/v1/query" | jq

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, the names are case-sensitive and can be found here: https://ossf.github.io/osv-schema/#affectedpackage-field

I've changed it to lower-case mediator-wise, thanks.

Copy link
Member Author

Choose a reason for hiding this comment

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

Re-tested:
Screenshot 2023-09-26 at 13 39 16

vulnerability_database_type: osv
vulnerability_database_endpoint: https://vuln.go.dev
vulnerability_database_endpoint: https://api.osv.dev/v1/query
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see, while vuln.dev.go does export their data in the OSV format, they don't provide the same API. We might want to even serve our own and fetch their database periodically, but..not now.

@@ -29,13 +30,44 @@ func newEcosystemParser(eco DependencyEcosystem) ecosystemParser {
switch eco {
Copy link
Contributor

Choose a reason for hiding this comment

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

if you agree about the case-insensitive comparison, maybe we should change this to strings.ToLower and lowercase all the dependencies..

@jhrozek
Copy link
Contributor

jhrozek commented Sep 25, 2023

oh and it looks like a rebase is in order..too many patches are touching the protobuf structs lately..

@jhrozek
Copy link
Contributor

jhrozek commented Sep 25, 2023

(you'll want to rebase, then just call make gen, git add the conflicting file pkg/generated/protobuf/go/mediator/v1/mediator.pb.go and git rebase --continue)

@jhrozek jhrozek merged commit acdf4ea into main Sep 26, 2023
13 checks passed
@jhrozek jhrozek deleted the 912-support-go-dependency-scanning-for-pr branch September 26, 2023 11:44
@jhrozek
Copy link
Contributor

jhrozek commented Sep 26, 2023

merged so I can send the next PR atop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants