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

Add govulncheck script to expose go vulnerabilities #120562

Merged
merged 3 commits into from
Oct 12, 2023

Conversation

ArkaSaha30
Copy link
Member

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR will add a govulncheck script to check for go vulnerabilities when a PR is raised. It will be triggered as a presubmit from test-infra/config/jobs/kubernetes/sig-security/govulncheck-presubmit.yaml for every PR opened for go module changes.

Which issue(s) this PR fixes:

Fixes: kubernetes/sig-security#99
Parent Issue: kubernetes/sig-security#95

Special notes for your reviewer:

Discussion threads:

Does this PR introduce a user-facing change?


Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

NONE

Signed-off-by: ArkaSaha30 <arkasaha30@gmail.com>
@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Sep 11, 2023
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Sep 11, 2023
@dims
Copy link
Member

dims commented Sep 11, 2023

/assign @liggitt @PushkarJ

hack/verify-govulncheck.sh Outdated Show resolved Hide resolved
hack/verify-govulncheck.sh Outdated Show resolved Hide resolved
Co-authored-by: LX <hwdefcom@outlook.com>
Signed-off-by: ArkaSaha30 <arkasaha30@gmail.com>
@rjsadow
Copy link
Contributor

rjsadow commented Sep 13, 2023

/lgtm
/release-note-none

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Sep 13, 2023
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 13, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 85c2ef617e0473cda69f2b6f9e56339502cdc9a9

@rjsadow
Copy link
Contributor

rjsadow commented Sep 13, 2023

/sig security

@k8s-ci-robot k8s-ci-robot added sig/security Categorizes an issue or PR as relevant to SIG Security. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Sep 13, 2023
Copy link
Member

@PushkarJ PushkarJ left a comment

Choose a reason for hiding this comment

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

@ArkaSaha30 make sure to make changes to test infra PR to pull this file from right repository

/lgtm

@ArkaSaha30
Copy link
Member Author

@ArkaSaha30 make sure to make changes to test infra PR to pull this file from right repository

Sure, I have already made the necessary changes - kubernetes/test-infra#30591 (comment)

hack/verify-govulncheck.sh Outdated Show resolved Hide resolved
hack/verify-govulncheck.sh Outdated Show resolved Hide resolved
hack/verify-govulncheck.sh Show resolved Hide resolved
export PATH=$PATH:$GOPATH/bin
mkdir -p "${WORKDIR}"
go install golang.org/x/vuln/cmd/govulncheck@v1.0.1

Copy link
Member

Choose a reason for hiding this comment

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

use KUBE_VERIFY_GIT_BRANCH which is already populated in the verify CI job (other scripts in this repo already use it)

# KUBE_VERIFY_GIT_BRANCH is populated in verify CI jobs
BRANCH="${KUBE_VERIFY_GIT_BRANCH:-master}"

Copy link
Member

@pacoxu pacoxu Nov 23, 2023

Choose a reason for hiding this comment

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

master verify all failed for this verify script.

KUBE_VERIFY_GIT_BRANCH is overridden by Makefile.

verify:
KUBE_VERIFY_GIT_BRANCH=$(BRANCH) hack/make-rules/verify.sh
endif

We got fatal: invalid reference: master in

https://prow.k8s.io/view/gs/kubernetes-jenkins/logs/ci-kubernetes-verify-1-29/1727556821872283648

https://github.com/kubernetes/test-infra/blob/36a7c91fffc75a3bc9dd8d18a6a6471e7b3a9527/config/jobs/kubernetes/sig-release/release-branch-jobs/1.29.yaml#L433-L436

Should we skip this in release 1.29 verify-all? Or should we set BRANCH for this ci?

mkdir -p "${WORKDIR}"
go install golang.org/x/vuln/cmd/govulncheck@v1.0.1

govulncheck -scan module ./... > "${WORKDIR}/head.txt"
Copy link
Member

Choose a reason for hiding this comment

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

use the helper to make a temp dir that will get cleaned up

kube::util::ensure-temp-dir
WORKTREE="${KUBE_TEMP}/worktree"

# Create a copy of the repo with $BRANCH checked out
git worktree add -f "${WORKTREE}" "${BRANCH}"
# Clean up the copy on exit
kube::util::trap_add "git worktree remove -f ${WORKTREE}" EXIT

Copy link
Member Author

@ArkaSaha30 ArkaSaha30 Sep 27, 2023

Choose a reason for hiding this comment

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

Thank you for the suggestions @liggitt , I have updated the script with changes. My only concern is that ${KUBE_TEMP} tends to get removed and we do not get the artifacts. Do you suggest to copy them to /artifacts directory and add

export WORKDIR=${ARTIFACTS:-$TMPDIR}
export PATH=$PATH:$GOPATH/bin
mkdir -p "${WORKDIR}"

as it was?

hack/verify-govulncheck.sh Outdated Show resolved Hide resolved
hack/verify-govulncheck.sh Outdated Show resolved Hide resolved
@liggitt
Copy link
Member

liggitt commented Sep 16, 2023

FYI, new verify-*.sh scripts run by default in the verify presubmit... this script is already running in this PR's presubmits, without any test-infra changes:

image

@PushkarJ
Copy link
Member

@liggitt that's amazing. I learnt something new today. Also makes me happy we need one less job to run in test-infra because less code is more secure code 😎

On related note, Who needs to /approve to merge this ?

@PushkarJ
Copy link
Member

Oops looks like I missed the fact that there are some suggested edits before we can merge. @ArkaSaha30 Please feel free to ask for help from me on addressing these suggestions if needed.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Sep 27, 2023
@ArkaSaha30 ArkaSaha30 force-pushed the govulncheck-script branch 3 times, most recently from a4e9117 to f6c151c Compare September 27, 2023 10:11
Signed-off-by: ArkaSaha30 <arkasaha30@gmail.com>
@dims
Copy link
Member

dims commented Oct 12, 2023

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ArkaSaha30, dims, PushkarJ

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 Oct 12, 2023
@dims
Copy link
Member

dims commented Oct 12, 2023

/lgtm

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

LGTM label has been added.

Git tree hash: a083f586ff5ea4b03fde385f17358ca7ff09be40

@k8s-ci-robot
Copy link
Contributor

@ArkaSaha30: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubernetes-e2e-gce 7437ad2 link unknown /test pull-kubernetes-e2e-gce

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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/test-infra repository. I understand the commands that are listed here.

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. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. sig/security Categorizes an issue or PR as relevant to SIG Security. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[govulncheck] Pre-submit Prow Job for govulncheck
8 participants