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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 }} |
| 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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 0416abe: |
||
| 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 | ||
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 — npm audit results never reach code scanning, though the header comment and PR summary say they do
The header says "findings go to the job summary and code scanning", and the PR summary says main and daily runs send them to the Security tab. Only govulncheck and Trivy upload SARIF. The
yarn-auditjob only writes to$GITHUB_STEP_SUMMARY, so on push and schedule runs the npm advisories exist only in a summary that nobody is alerted to. Either convert the audit output (yarn npm audit --json) to SARIF and upload it with the samegithub.event_name != 'pull_request'gate, or change the comment and description to say that npm findings are summary-only.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