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 to CI #6963

Merged
merged 29 commits into from
Jul 11, 2023
Merged

Add govulncheck to CI #6963

merged 29 commits into from
Jul 11, 2023

Conversation

pgporada
Copy link
Member

@pgporada pgporada commented Jun 28, 2023

Fixes #6354

Installs govulncheck into a one-shot container so that at PR creation, updates to a PR, and merges to main can contact the govuln API and check for known vulnerabilities.

Lastly, upgrades the version of golangci-lint to the latest available (v1.53.3).

@pgporada pgporada requested a review from a team as a code owner June 28, 2023 15:28
@pgporada pgporada requested a review from aarongable June 28, 2023 15:28
@pgporada
Copy link
Member Author

pgporada commented Jun 28, 2023

I need to build new containers before govulncheck actually runs here, but I wanted to discuss the PR first before doing that work. Do we want to run it in offline mode? Should I have a sidecar container that comes online with network access?

$ govulncheck ./...
govulncheck is an experimental tool. Share feedback at https://go.dev/s/govulncheck-feedback.

Using go1.20.5 and govulncheck@v0.0.0 with
vulnerability data from https://vuln.go.dev (last modified 2023-06-26 16:56:57 +0000 UTC).

Scanning your code and 507 packages across 79 dependent modules for known vulnerabilities...
No vulnerabilities found.

Copy link
Contributor

@aarongable aarongable left a comment

Choose a reason for hiding this comment

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

On the whole, I think this approach is fine. It's unfortunate that it only updates the database when we re-run tag_and_upload, but that's still a step up from where we are today. I've left some comments assuming we continue down this path.

That said, there is another possible approach: add a whole new github workflow which just uses the official govulncheck action. It means we can't run it locally as part of t.sh -l, but it also means that we write approximately zero code and it runs against the live database.

test/boulder-tools/setup-govulncheck.sh Outdated Show resolved Hide resolved
test/boulder-tools/setup-govulncheck.sh Outdated Show resolved Hide resolved
test/boulder-tools/setup-govulncheck.sh Outdated Show resolved Hide resolved
@aarongable aarongable requested a review from a team June 29, 2023 01:22
@beautifulentropy beautifulentropy self-requested a review June 29, 2023 16:46
test/boulder-tools/setup-govulncheck.sh Outdated Show resolved Hide resolved
test/boulder-tools/setup-govulncheck.sh Outdated Show resolved Hide resolved
test/boulder-tools/setup-govulncheck.sh Outdated Show resolved Hide resolved
@pgporada
Copy link
Member Author

pgporada commented Jun 30, 2023

I decided to go the low code route and only run on Github CI. This has the benefit that govulncheck is run against the live vuln database at PR creation, each commit that run tests, and at merge time.

@pgporada pgporada dismissed beautifulentropy’s stale review June 30, 2023 18:36

I've changed the way this PR works.

@aarongable
Copy link
Contributor

It doesn't look like govulncheck is running on this PR yet. I thought you were moving the job from govulncheck.yml into boulder-ci.yml; is that commit just missing from the PR?

@pgporada
Copy link
Member Author

Pushed commits are out of sync with what is being displayed in this PR. I pushed this an hour ago, but it's still not showing up here. 6d76aef

@aarongable
Copy link
Contributor

Looks like that github outage left this PR permanently messed up. I'm trying to re-push your same commits to see if we can kick it into working.

.github/workflows/boulder-ci.yml Outdated Show resolved Hide resolved
.github/workflows/boulder-ci.yml Outdated Show resolved Hide resolved
.github/workflows/boulder-ci.yml Outdated Show resolved Hide resolved
.github/workflows/boulder-ci.yml Show resolved Hide resolved
.github/workflows/boulder-ci.yml Outdated Show resolved Hide resolved
Copy link
Contributor

@aarongable aarongable left a comment

Choose a reason for hiding this comment

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

Should the boulder_ci_test_matrix_status job be updated to check the status of the govulncheck jobs as well? Having one of these jobs fail isn't quite the same as having a test fail, but I don't think we want to accidentally submit code which failed these jobs either.

@pgporada
Copy link
Member Author

pgporada commented Jul 5, 2023

Yup, that's a good point and I completely failed to see the utility build job in the workflow.

aarongable
aarongable previously approved these changes Jul 6, 2023
Copy link
Contributor

@aarongable aarongable left a comment

Choose a reason for hiding this comment

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

LGTM, I'm glad we'll be running this now!

Now you have me curious whether its faster to pull the boulder/netaccess docker image (as this workflow does) or to install Go from scratch (as the govulncheck action does). It's a handful of seconds either way, so it doesn't matter compared to our integration tests.

@pgporada
Copy link
Member Author

pgporada commented Jul 6, 2023

The govulncheck action runs a setup-go action which cannot retrieve go1.21 release candidates. I wanted to be able to run vulnchecks against the exact versions of go we're using hence the container shenanigans.

@aarongable
Copy link
Contributor

Oh really? I thought it would work when specified like 1.21.0-rc.1, like in the example it gives. Weird that it doesn't. Alrighty then!

@pgporada
Copy link
Member Author

pgporada commented Jul 10, 2023

I was wrong, I figured out how to get it to retrieve release candidates. However, something I learned about the govulncheck action proper is that it runs setup-go which doesn't yet have the ability to use an already installed golang and will always install a fresh copy which is wasteful. The implementation in this PR avoids that.

.github/workflows/boulder-ci.yml Outdated Show resolved Hide resolved
RUN sed -i '/imklog/s/^/#/' /etc/rsyslog.conf
RUN sed -i '/$ActionFileDefaultTemplate/s/^/#/' /etc/rsyslog.conf
RUN sed -i '/$RepeatedMsgReduction on/s/^/#/' /etc/rsyslog.conf
RUN /tmp/install-go.sh && \
Copy link
Contributor

Choose a reason for hiding this comment

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

Why combine the rsyslog editing steps with the install-go step? Though I do like combining the different sed invocations into a single invocation.

Copy link
Member Author

Choose a reason for hiding this comment

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

RUN, COPY, and ADD create new layers which use some amount of disk space. Having less layers is more efficient disk space-wise. There's further optimizations that can be done with a multi-stage build, but that's outside the scope of this PR. Hell, even this change is now outside the scope of this PR because I changed strategies mid-way through.

Copy link
Member Author

Choose a reason for hiding this comment

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

Layers prior to this change
Screenshot from 2023-07-10 16-40-26

Layers after this change
Screenshot from 2023-07-10 16-49-52

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point, and that's why for instance we put a bunch of stuff inside build.sh rather than in RUN commands directly. Perhaps the sed commands should go inside build.sh? That makes more sense to me logically than clustering them with install-go.sh. It would probably be interesting to look at the git history and see if there's a specific reason they're in the Dockerfile rather than build.sh.

jsha
jsha previously approved these changes Jul 10, 2023
@pgporada pgporada requested a review from aarongable July 10, 2023 21:23
@pgporada pgporada merged commit 947e199 into main Jul 11, 2023
21 checks passed
@pgporada pgporada deleted the add-govulncheck-to-ci branch July 11, 2023 13:51
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.

Add govulncheck to CI
4 participants