Skip to content

govulncheck to report known vulnerabilities#48311

Merged
thaJeztah merged 1 commit intomoby:masterfrom
crazy-max:govulncheck
Aug 9, 2024
Merged

govulncheck to report known vulnerabilities#48311
thaJeztah merged 1 commit intomoby:masterfrom
crazy-max:govulncheck

Conversation

@crazy-max
Copy link
Member

@crazy-max crazy-max commented Aug 8, 2024

similar to moby/buildkit#5199

Runs govulncheck tool in our workflow to report known vulnerabilities that affect Go code using the Go vulnerability database at https://vuln.go.dev/ and output a SARIF report that will be uploaded to GitHub Code scanning so we have these issues reported in the Security tab.

find ${{ env.DESTDIR }} -type f -exec file -e ascii -- {} +

govulncheck:
runs-on: ubuntu-24.04
Copy link
Member

Choose a reason for hiding this comment

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

Reminds me; I see the other ones are still on 20.04, and some on "ubuntu-latest".

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah right we should pin to ubuntu-24.04 where it's possible imo.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, It's fine to do that separately and have this one already on 24.04 I guess.

I thought I had a PR to do that, but maybe I never opened one 🙈

@thaJeztah
Copy link
Member

Hm...

Uploading results
  Processing sarif files: ["./build/govulncheck.out"]
  Validating ./build/govulncheck.out
  Combining SARIF files using the CodeQL CLI
  Adding fingerprints to SARIF file. See https://docs.github.com/en/enterprise-cloud@latest/code-security/code-scanning/integrating-with-code-scanning/sarif-support-for-code-scanning#providing-data-to-track-code-scanning-alerts-across-runs for more information.
  Error: Invalid SARIF. Missing 'results' array in run.

@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@crazy-max
Copy link
Member Author

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

Forgot to disable uploading scan result on PR, let me do that 😅

Comment on lines +23 to +28
if [ "${FORMAT}" = "sarif" ]; then
# Make sure "results" field is defined in SARIF output otherwise GitHub Code Scanning
# will fail when uploading report with "Invalid SARIF. Missing 'results' array in run."
# Relates to https://github.com/golang/vuln/blob/ffdef74cc44d7eb71931d8d414c478b966812488/internal/sarif/sarif.go#L69
jq '(.runs[] | select(.results == null) | .results) |= []' /out/govulncheck.out | tee >(sponge /out/govulncheck.out)
fi
Copy link
Member Author

Choose a reason for hiding this comment

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

Hm...

Uploading results
  Processing sarif files: ["./build/govulncheck.out"]
  Validating ./build/govulncheck.out
  Combining SARIF files using the CodeQL CLI
  Adding fingerprints to SARIF file. See https://docs.github.com/en/enterprise-cloud@latest/code-security/code-scanning/integrating-with-code-scanning/sarif-support-for-code-scanning#providing-data-to-track-code-scanning-alerts-across-runs for more information.
  Error: Invalid SARIF. Missing 'results' array in run.

Yes seems govulncheck omitempty for results: https://github.com/golang/vuln/blob/ffdef74cc44d7eb71931d8d414c478b966812488/internal/sarif/sarif.go#L69

So as a workaround set it if not defined to make GitHub happy. Not yet sure if this is something that needs to be fixed on GitHub or govulncheck side.

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants