Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/actions/trivy-scan/action.yml
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 }}
120 changes: 120 additions & 0 deletions .github/workflows/dependency-scan.yml
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

Copy link
Copy Markdown
Contributor

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 the pull_request path 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. Add docker/otel-collector/Dockerfile to paths.

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

Copy link
Copy Markdown
Contributor Author

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/Dockerfile is now in the path filter, and the version step fails with an error if it can't parse the Go version.

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
50 changes: 47 additions & 3 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,21 @@ jobs:
name: Build OTel Collector Image
runs-on: ubuntu-24.04
timeout-minutes: 25
permissions:
contents: read
security-events: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Get changed files
id: changed-files
if: github.event_name == 'pull_request'
uses: tj-actions/changed-files@v47.0.6
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files: |
docker/otel-collector/**
packages/otel-collector/**
.github/actions/trivy-scan/**
- name: Setup Docker Buildx
if:
github.event_name != 'pull_request' ||
Expand All @@ -75,10 +79,22 @@ jobs:
target: prod
platforms: linux/amd64
push: false
load: true
tags: clickstack-otel-collector:ci
cache-from: |
type=gha,scope=otel-collector-nightly-amd64
type=gha,scope=docker-build-pr-otel-collector
cache-to: type=gha,mode=max,scope=docker-build-pr-otel-collector
- name: Scan image
if:
github.event_name != 'pull_request' ||
steps.changed-files.outputs.any_changed == 'true'
continue-on-error: true
timeout-minutes: 10
uses: ./.github/actions/trivy-scan
with:
image: clickstack-otel-collector:ci
category: otel-collector

# App/prod image (API + App + common-utils Node build) — docker/hyperdx target prod.
# This is the image the nightly css.d.ts failure surfaced in; the same builder
Expand All @@ -87,13 +103,16 @@ jobs:
name: Build App Image
runs-on: ubuntu-24.04
timeout-minutes: 25
permissions:
contents: read
security-events: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Get changed files
id: changed-files
if: github.event_name == 'pull_request'
uses: tj-actions/changed-files@v47.0.6
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files: |
packages/api/**
Expand Down Expand Up @@ -124,6 +143,8 @@ jobs:
target: prod
platforms: linux/amd64
push: false
load: true
tags: clickstack:ci
build-contexts: |
hyperdx=./docker/hyperdx
api=./packages/api
Expand All @@ -134,6 +155,16 @@ jobs:
type=gha,scope=app-nightly-amd64
type=gha,scope=docker-build-pr-app
cache-to: type=gha,mode=max,scope=docker-build-pr-app
- name: Scan image
if:
github.event_name != 'pull_request' ||
steps.changed-files.outputs.any_changed == 'true'
continue-on-error: true
timeout-minutes: 10
uses: ./.github/actions/trivy-scan
with:
image: clickstack:ci
category: app

# All-in-one image (adds ClickHouse, MongoDB, OTel Collector to the app build)
# — docker/hyperdx targets all-in-one-auth AND all-in-one-noauth (the Local
Expand All @@ -155,13 +186,16 @@ jobs:
name: Build All-in-One Image
runs-on: ubuntu-24.04
timeout-minutes: 40
permissions:
contents: read
security-events: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Get changed files
id: changed-files
if: github.event_name == 'pull_request'
uses: tj-actions/changed-files@v47.0.6
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files: |
packages/otel-collector/**
Expand Down Expand Up @@ -232,3 +266,13 @@ jobs:
steps.changed-files.outputs.any_changed == 'true'
timeout-minutes: 10
run: scripts/ci/smoke-all-in-one.sh hyperdx-aio-smoke:pr
- name: Scan image
if:
github.event_name != 'pull_request' ||
steps.changed-files.outputs.any_changed == 'true'
continue-on-error: true
timeout-minutes: 10
uses: ./.github/actions/trivy-scan
with:
image: hyperdx-aio-smoke:pr
category: all-in-one
Loading