Conversation
Add CodeQL code scanning and Trivy filesystem/image scanning across CI and release workflows. Also gate publish-main on security scan jobs and enable GoReleaser image SBOM generation. --- _Generated with `mux` • Model: `openai:gpt-5.3-codex` • Thinking: `xhigh` • Cost: $0.34_ <!-- mux-attribution: model=openai:gpt-5.3-codex thinking=xhigh costs=0.34 -->
|
@codex review Please review this PR for the new CodeQL + Trivy scanning workflows and publish/release image scanning integration. |
|
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1064447553
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Pin Go setup in CodeQL workflow and compute release image tag without a leading `v` before Trivy scanning. --- _Generated with `mux` • Model: `openai:gpt-5.3-codex` • Thinking: `xhigh` • Cost: $0.34_ <!-- mux-attribution: model=openai:gpt-5.3-codex thinking=xhigh costs=0.34 -->
|
@codex review Addressed the two workflow comments:
Please take another look. |
|
Codex Review: Didn't find any major issues. Keep it up! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Add repository and container security scanning by integrating CodeQL and Trivy into CI/release workflows.
Background
The repository already ran linting and vulnerability checks (
gosec,govulncheck, Terraform Trivy config scan), but it did not yet provide first-class GitHub code scanning results or OCI image vulnerability scanning for publish/release paths.Implementation
main, and a weekly schedule.publish-maingating to include filesystem and image scanning jobs.ghcr.io/coder/coder-k8s:main.ghcr.io/coder/coder-k8s:${{ github.event.release.tag_name }}.Validation
go tool actionlintmake buildmake testmake lintmake verify-vendorRisks
📋 Implementation Plan
Plan: Add code scanning + OCI image scanning
Context / Why
You want to add (1) code scanning and (2) OCI container image scanning to the
coder-k8srepository, ideally as part of GitHub Actions CI/CD.This repo already has good baseline security checks (gosec via golangci-lint, govulncheck, Trivy config scan for Terraform, zizmor for Actions). The main missing pieces are:
ghcr.io/coder/coder-k8simages.Evidence (what we verified)
From repo inspection (Explore task):
.github/workflows/ci.yamlalready runs:golangci-lintwithgosecenabledgovulncheck ./...terraform/(usingaquasecurity/trivy-action@b6643a29...)zizmorfor workflow security.github/workflows/release.yamluses GoReleaser to publish artifacts/images..goreleaser.yamlbuilds and pushesghcr.io/coder/coder-k8sand hasdockers_v2.*.sbom: false.Dockerfile.goreleaserisdistroless/static:nonrootand copies in the built binary.These files are sufficient to plan concrete changes to CI/CD for code + image scanning.
Implementation details (proposed changes)
1) Add GitHub CodeQL workflow (Go code scanning)
Goal: Add “code scanning” in the GitHub-native sense (SAST + Security tab integration).
Create:
.github/workflows/codeql.yaml(new)pull_request(default branches)pushtomainscheduleweekly (optional but recommended)security-events: writecontents: readactions: readactions/checkout(SHA-pinned, match repo style)github/codeql-action/init(Go)github/codeql-action/autobuildor explicitgo build ./...withGOFLAGS=-mod=vendor)github/codeql-action/analyzeShape:
Notes:
2) Add Trivy filesystem scan (repo/code + secrets + config)
Goal: Complement CodeQL with quick repo scanning for known vulnerable dependencies, leaked secrets patterns, and misconfigurations.
Update:
.github/workflows/ci.yamllintjob) using the already-pinned Trivy action.scan-type: fsand scan the repo root.vendor/(since deps are scanned viagovulncheck, andvendor/can create noise/slowdowns).HIGH,CRITICALinitially.Shape:
Optional (recommended if you want results in the GitHub Security UI):
format: sarif,output: trivy-fs.sarifgithub/codeql-action/upload-sarif(SHA-pinned)3) Add Trivy OCI image vulnerability scanning
Goal: Scan the built container image for vulnerabilities as part of CI/CD.
There are two places to do this:
3a) CI (pre-merge) image scan job
Update:
.github/workflows/ci.yamlimage-scanjob gated on the existingchanges.outputs.publish == 'true'filter.Dockerfile.goreleaser.scan-type: imageagainst the local image tag.Shape:
Optional: SARIF output + upload-sarif (same as filesystem scan).
3b) Post-publish verification scan (main + releases)
Update:
.github/workflows/ci.yamlpublish-mainjob: add a Trivy image scan step forghcr.io/coder/coder-k8s:main..github/workflows/release.yaml: add a Trivy image scan step for the release tagghcr.io/coder/coder-k8s:${{ github.event.release.tag_name }}.This ensures the image that actually gets published is scanned even if a pre-merge job is skipped.
4) Enable SBOM generation for releases (optional but strongly recommended)
Goal: Improve supply-chain posture and make scanning/auditing easier.
Update:
.goreleaser.yamlProposed change:
dockers_v2entry, setsbom: true(instead offalse) if supported by your GoReleaser version.sboms:section to generate SBOMs for release artifacts.5) Add ignore/config files for managing findings
Goal: Keep signal-to-noise high as scans are introduced.
Add (as needed):
.trivyignorefor image/fs scans (keep Terraform-specific ignore interraform/.trivyignoreas-is)..trivy.yamlto centralize excludes and scanner settings.6) Validation plan (what to run before merging)
After implementing in Exec mode:
go tool actionlint(or your existing workflow job) to validate workflow YAML.make testmake buildmake lintRationale / trade-offs
fsscan is fast and broad (secrets/config/vuln), but can be noisy; excludingvendor/and using.trivyignorehelps.Generated with
mux• Model:openai:gpt-5.3-codex• Thinking:xhigh• Cost: $0.34