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

First attempt using aquasecurity/trivy-action to scan for CVEs during build. #3461

Merged
merged 5 commits into from
Aug 28, 2024

Conversation

mitchell-as
Copy link
Contributor

@mitchell-as mitchell-as commented Aug 26, 2024

TaskDX-2978 We have a test that verifies we aren't shipping with CVEs

Remediate go-retryablehttp and gqlparser CVEs.

@mitchell-as mitchell-as requested a review from MDrakos August 26, 2024 21:24
@mitchell-as mitchell-as marked this pull request as ready for review August 26, 2024 21:24
@@ -214,6 +214,17 @@ jobs:
shell: bash
run: parallelize results Build-Executor

- # === Scan for CVEs (Linux only) ===
name: Scan for CVEs
if: runner.os == 'Linux'
Copy link
Member

Choose a reason for hiding this comment

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

We will need to scan for all platforms. It's ok if this runs ON linux, so long as we verify all binaries for all platforms.

Additionally, we should only run this on release branches and the nightly I think, no point slowing down regular PRs.

We could add a new job that runs in between build.yml and release.yml. Because we are already transferring all platform bits from build to release.yml, so we could inject something in the middle there for CVE validation.

Copy link
Member

Choose a reason for hiding this comment

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

Well, that's what I was going to say...

For additional information you can run go version -m <executable> on a Go binary to see that there are differences in the modules used. It doesn't appear that versions are different but the Windows build may include modules that Linux does not and vice versa.

It also appears that Trivy has releases for MacOS and Windows, if that helps: https://github.com/aquasecurity/trivy/releases

Copy link
Contributor Author

@mitchell-as mitchell-as Aug 27, 2024

Choose a reason for hiding this comment

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

Very well, I've added a new Scan action inbetween build and deploy that scans all platform-specific binaries in one go. I disagree that it should only run on release branches and nightlies. PRs should not introduce CVEs only for them to be caught later. We should be proactive. It took a whopping 5s to scan all generated binaries.

Copy link
Member

Choose a reason for hiding this comment

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

@MDrakos did I hijack your review? 😅 Not my intention. When I reviewed this I was under the impression I was flagged, maybe I got my wires crossed.

@@ -424,7 +435,7 @@ jobs:
name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
go-version: 1.22.x
Copy link
Member

Choose a reason for hiding this comment

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

Should update the matrix version instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The matrix does not exist for this job. Our action linter caught this.

@mitchell-as mitchell-as requested a review from Naatan August 27, 2024 18:38
with:
scan-type: rootfs
scan-ref: build
ignore-unfixed: true
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ignore-unfixed: true
ignore-unfixed: false

If I understand this correctly true would only report it the first time.

Copy link
Contributor Author

@mitchell-as mitchell-as Aug 28, 2024

Choose a reason for hiding this comment

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

No, this will ignore any CVEs that do not have fixes. We currently have an unfixed CVE (archiver/v3 does not have a fix, so there's no safe version we can update to). Without this option, the check will fail and we will have to force PRs to merge.

Copy link
Member

Choose a reason for hiding this comment

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

Ahh I see.. ok yeah that makes sense 👍

- name: Scan for CVEs
if: runner.os == 'Linux'
uses: aquasecurity/[email protected]
with:
Copy link
Member

Choose a reason for hiding this comment

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

Could you try adding list-all-pkgs? I'd like to see a report of the files that were scanned so we can assert that it did in fact scan the things we want it to.

@@ -397,11 +397,32 @@ jobs:
name: session-build-${{ matrix.sys.os }}
path: build/

scan:
Copy link
Member

Choose a reason for hiding this comment

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

Please add the same if conditional as deploy. Which has it only run on nightly and release branches.

eg.

if: contains(fromJSON('["refs/heads/master", "refs/heads/beta", "refs/heads/release", "refs/heads/LTS"]'), github.ref) || startsWith(github.event.pull_request.head.ref, 'version/')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You missed my comment about this:

I disagree that it should only run on release branches and nightlies. PRs should not introduce CVEs only for them to be caught later. We should be proactive. It took a whopping 5s to scan all generated binaries.

Until that is addressed, I am not okay with doing what you requested.

@mitchell-as mitchell-as merged commit 5123958 into version/0-46-0-RC1 Aug 28, 2024
8 checks passed
@mitchell-as mitchell-as deleted the mitchell/dx-2978-2 branch August 28, 2024 22:09
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.

3 participants