Skip to content

Conversation

lentzi90
Copy link
Contributor

@lentzi90 lentzi90 commented May 6, 2025

What this PR does / why we need it:

This adds a github workflow that runs the govulncheck and trivy.
It is all copied and adapted from CAPI (hence the existing licenses at the top).
We may want to think about how to notify maintainers of this.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer:

  1. Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

TODOs:

  • squashed commits
  • if necessary:
    • includes documentation
    • adds unit tests

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 6, 2025
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 6, 2025
@k8s-ci-robot k8s-ci-robot requested review from EmilienM and mdbooth May 6, 2025 16:23
Copy link

netlify bot commented May 6, 2025

👷 Deploy Preview for kubernetes-sigs-cluster-api-openstack processing.

Name Link
🔨 Latest commit 7cfdcfc
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-openstack/deploys/681cd490a65e930007181e12

@mnaser
Copy link
Contributor

mnaser commented May 6, 2025

We can simplify this a lot by just using the official action:

https://google.github.io/osv-scanner/github-action/

It takes care of everything for us and maintained by the team behind it, thoughts?

@lentzi90
Copy link
Contributor Author

lentzi90 commented May 7, 2025

Oh I wasn't aware of that one actually! I asked around a bit and it turns out we did use it before in CAPM3. Unfortunately we had issues with it around the go version and dependabot updates. I'm open to try it though, perhaps the issues are solved.

Another thing I was thinking about is if we should rather copy what CAPI does. They run govulncheck directly through a workflow and some make targets.
What do you think?

@mnaser
Copy link
Contributor

mnaser commented May 7, 2025

So, I did a bit of research on how the different projects are doing this, the common thing that I found across all of them is that they use and run Trivy & some have govulncheck in addition. CAPI approach seems to be the most commonly shared across most components.

cluster-api-provider-azure

cluster-api-provider-aws

cluster-api-provider-vsphere

cluster-api-provider-gcp

  • Didn't find any scanning

cluster-api-provider-ibmcloud

@lentzi90
Copy link
Contributor Author

lentzi90 commented May 8, 2025

Thanks! Then I will rework this to follow CAPI 🙂

@lentzi90 lentzi90 force-pushed the lentzi90/osv-scanner branch from b2494fc to 6ae4671 Compare May 8, 2025 08:00
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 8, 2025
@lentzi90 lentzi90 changed the title 🌱 Add OSV scanner github workflow 🌱 Add weekly security scan using govulncheck and trivy May 8, 2025
@lentzi90 lentzi90 force-pushed the lentzi90/osv-scanner branch 3 times, most recently from 9bacb86 to 042b352 Compare May 8, 2025 10:00
@lentzi90
Copy link
Contributor Author

lentzi90 commented May 8, 2025

 hack/tools/bin/govulncheck-v1.1.4 ./... && R1=$? || R1=$?; \
hack/tools/bin/govulncheck-v1.1.4 -C "hack/tools" ./... && R2=$? || R2=$?; \
if [ "$R1" -ne "0" ] || [ "$R2" -ne "0" ]; then \
	exit 1; \
fi
No vulnerabilities found.
No vulnerabilities found. 

The normal test will run govulncheck also but not trivy to scan images.

@lentzi90
Copy link
Contributor Author

lentzi90 commented May 8, 2025

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 8, 2025
This is all based on how CAPI does the same.

Signed-off-by: Lennart Jern <[email protected]>
@lentzi90 lentzi90 force-pushed the lentzi90/osv-scanner branch from 042b352 to 7cfdcfc Compare May 8, 2025 15:58
@mdbooth
Copy link
Contributor

mdbooth commented May 9, 2025

Nice! Running this locally seems to be recommending a bump to Go 1.23.8.

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 9, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mdbooth, mnaser

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 9, 2025
@lentzi90
Copy link
Contributor Author

lentzi90 commented May 9, 2025

Nice! Running this locally seems to be recommending a bump to Go 1.23.8.

Thanks! Yes, this is also why I pushed #2539 yesterday 🙂

@lentzi90
Copy link
Contributor Author

lentzi90 commented May 9, 2025

Hmm netlify checks seems stuck
/retest

@lentzi90 lentzi90 changed the title 🌱 Add weekly security scan using govulncheck and trivy 🌱 Add weekly security scan using govulncheck and Trivy May 9, 2025
@lentzi90
Copy link
Contributor Author

Ok I'm just going to merge this now. The netlify check has been stuck for 4 days

@lentzi90 lentzi90 merged commit e09e4c0 into kubernetes-sigs:main May 12, 2025
6 of 9 checks passed
@github-project-automation github-project-automation bot moved this from Inbox to Done in CAPO Roadmap May 12, 2025
@lentzi90 lentzi90 deleted the lentzi90/osv-scanner branch May 12, 2025 05:45
@lentzi90
Copy link
Contributor Author

/cherry-pick release-0.12 release-0.11 release-0.10

@k8s-infra-cherrypick-robot

@lentzi90: new pull request created: #2543

In response to this:

/cherry-pick release-0.12 release-0.11 release-0.10

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants