Repository navigation
ci: add report-only Trivy, govulncheck and yarn npm audit scans #3735
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
Open
jordan-simonovski
wants to merge
2
commits into
main
Choose a base branch
from
jordansimonovski/vuln-scanning
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| name: Trivy image scan | ||
| description: | ||
| Report fixable HIGH and CRITICAL CVEs in a locally loaded image to the job | ||
| summary and GitHub code scanning. Report-only; never fails on findings. | ||
| inputs: | ||
| image: | ||
| description: Image reference already loaded into the local Docker daemon | ||
| required: true | ||
| category: | ||
| description: Code scanning category, unique per image | ||
| required: true | ||
| runs: | ||
| using: composite | ||
| steps: | ||
| # Pinned by SHA: trivy-action's tags were rewritten by an attacker in 2026. | ||
| - name: Scan image | ||
| uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0 | ||
| with: | ||
| image-ref: ${{ inputs.image }} | ||
| scanners: vuln | ||
| severity: HIGH,CRITICAL | ||
| ignore-unfixed: true | ||
| format: json | ||
| output: trivy.json | ||
| exit-code: '0' | ||
| version: v0.76.2 | ||
| - name: Write summary and SARIF | ||
| shell: bash | ||
| env: | ||
| CATEGORY: ${{ inputs.category }} | ||
| run: | | ||
| { | ||
| echo "### Trivy: ${CATEGORY} (fixable high and critical)" | ||
| echo '```' | ||
| trivy convert --format table trivy.json | ||
| echo '```' | ||
| } >> "$GITHUB_STEP_SUMMARY" | ||
| trivy convert --format sarif --output trivy.sarif trivy.json | ||
| # PR uploads would add a code scanning check that fails on new alerts. | ||
| - name: Upload to code scanning | ||
| if: github.event_name != 'pull_request' | ||
| uses: github/codeql-action/upload-sarif@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3 | ||
| with: | ||
| sarif_file: trivy.sarif | ||
| category: trivy-${{ inputs.category }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| name: Dependency Scan | ||
| # Report-only: findings go to the job summary and code scanning and never fail | ||
| # the run. The daily schedule catches advisories published against unchanged | ||
| # dependencies. Image scanning lives in docker-build.yml. | ||
| on: | ||
| pull_request: | ||
| branches: [main] | ||
| paths: | ||
| - '**/package.json' | ||
| - yarn.lock | ||
| - .yarnrc.yml | ||
| - packages/otel-collector/go.mod | ||
| - packages/otel-collector/go.sum | ||
| - packages/otel-collector/cmd/** | ||
| - docker/otel-collector/Dockerfile | ||
| - .github/workflows/dependency-scan.yml | ||
| push: | ||
| branches: [main] | ||
| schedule: | ||
| - cron: '0 9 * * *' | ||
| workflow_dispatch: | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
| permissions: | ||
| contents: read | ||
| jobs: | ||
| yarn-audit: | ||
| name: yarn npm audit | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 5 | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
| - name: Setup node | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| # Reads yarn.lock directly, so no install is needed. Dev tooling is skipped, | ||
| # except in the CLI, which bundles its devDependencies into the release. | ||
| - name: Audit dependencies | ||
| run: | | ||
| status=0 | ||
| { | ||
| echo '### yarn npm audit (high and critical)' | ||
| echo '#### Production dependencies, all workspaces' | ||
| echo '```' | ||
| yarn npm audit --all --recursive --environment production \ | ||
| --severity high 2>&1 || status=$? | ||
| echo '```' | ||
| echo '#### @hyperdx/cli, including bundled devDependencies' | ||
| echo '```' | ||
| yarn workspace @hyperdx/cli npm audit --recursive \ | ||
| --severity high 2>&1 || status=$? | ||
| echo '```' | ||
| } >> "$GITHUB_STEP_SUMMARY" | ||
| if [ "$status" -ne 0 ]; then | ||
| echo "::warning title=yarn npm audit::Advisories found or audit failed, see the job summary" | ||
| fi | ||
|
|
||
| govulncheck: | ||
| name: govulncheck | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 10 | ||
| permissions: | ||
| contents: read | ||
| security-events: write | ||
| defaults: | ||
| run: | ||
| working-directory: packages/otel-collector | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
| # govulncheck reports stdlib advisories for the Go on PATH, so match the | ||
| # release the shipped binary is built with rather than go.mod's minimum. | ||
| - name: Read Go version from the Dockerfile | ||
| id: go-version | ||
| working-directory: . | ||
| run: | | ||
| version=$(sed -nE 's/^FROM golang:([0-9.]+)-.* AS migrate-builder$/\1/p' \ | ||
| docker/otel-collector/Dockerfile) | ||
| if [ -z "$version" ]; then | ||
| echo "::error::No golang version found on the migrate-builder FROM line in docker/otel-collector/Dockerfile" | ||
| exit 1 | ||
| fi | ||
| echo "version=$version" >> "$GITHUB_OUTPUT" | ||
| - name: Setup Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: ${{ steps.go-version.outputs.version }} | ||
| cache-dependency-path: packages/otel-collector/go.sum | ||
| - name: Install govulncheck | ||
| run: go install golang.org/x/vuln/cmd/govulncheck@v1.10.0 | ||
| # Text mode exits 3 on findings; SARIF mode always exits 0. The SARIF | ||
| # paths are relative to the module, so prefix them for code scanning. | ||
| - name: Scan the migrate tool | ||
| continue-on-error: true | ||
| run: | | ||
| status=0 | ||
| govulncheck ./... > report.txt 2>&1 || status=$? | ||
| { | ||
| echo '### govulncheck (packages/otel-collector)' | ||
| echo '```' | ||
| cat report.txt | ||
| echo '```' | ||
| } >> "$GITHUB_STEP_SUMMARY" | ||
| if [ "$status" -ne 0 ]; then | ||
| echo "::warning title=govulncheck::Vulnerabilities found or scan failed, see the job summary" | ||
| fi | ||
| govulncheck -format sarif ./... > raw.sarif | ||
| jq '(.. | objects | select(.uriBaseId? == "%SRCROOT%") | .uri) |= "packages/otel-collector/" + .' \ | ||
| raw.sarif > govulncheck.sarif | ||
| # PR uploads would add a code scanning check that fails on new alerts. | ||
| - name: Upload to code scanning | ||
| if: github.event_name != 'pull_request' | ||
| continue-on-error: true | ||
| uses: github/codeql-action/upload-sarif@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3 | ||
| with: | ||
| sarif_file: packages/otel-collector/govulncheck.sarif | ||
| category: govulncheck | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 P2 — Bumping Go in the Dockerfile doesn't trigger govulncheck on the PR
govulncheck takes its Go version from
docker/otel-collector/Dockerfile, but that file isn't in thepull_requestpath filter. A PR that changes only the golang base image (a toolchain bump that changes stdlib advisories) gets no Dependency Scan run. The change only shows up after merge or on the daily schedule. Adddocker/otel-collector/Dockerfiletopaths.Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 0416abe:
docker/otel-collector/Dockerfileis now in the path filter, and the version step fails with an error if it can't parse the Go version.