Commit ee8dce2
feat(ci): govulncheck - add PR checks, SARIF Code Scanning, and automated remediation (#4595)
### What does this PR do?
Migrates vulnerability scanning from Dependabot Security Alerts to \`govulncheck\`-based scanning. Three changes:
1. **\`govulncheck.yml\`** (updated): adds a \`pull_request\` trigger so govulncheck now gates PRs; adds a SARIF upload job that feeds into GitHub Code Scanning (replaces Dependabot alerts in the Security tab); always installs \`govulncheck@latest\`; adds a concurrency group to cancel stale runs; pins all actions to latest SHA.
2. **\`govulncheck-fix.yml\`** (new): weekly remediation workflow (Mondays 6 AM UTC, also \`workflow_dispatch\`) that scans all modules, identifies reachable vulnerabilities with available fixes, updates the affected \`go.mod\` files, and opens a PR automatically.
3. **\`govulncheck-fix.sh\`** (new): remediation script that parses \`govulncheck -json\` streaming output, extracts \`(module, fixedVersion)\` pairs from \`finding.trace[-1]\`, runs \`go get module@version\` across all affected \`go.mod\` files (core + all 65+ contrib modules), and runs \`go mod tidy\`.
### Motivation
Dependabot Security Alerts flag every CVE in transitive dependencies regardless of whether the vulnerable code is actually reachable — the push that triggered this PR showed 32 alerts. \`govulncheck\` uses Go call graph analysis to only report vulnerabilities in code paths that are **actually called**, eliminating false positives.
After this merges, Dependabot Security Alerts for Go can be disabled in repo settings (Settings → Code security → Dependabot alerts). The \`dependabot.yml\` config is kept as-is since it only manages GitHub Actions version updates, which is still useful.
### How SARIF + GitHub Code Scanning works
The \`govulncheck-analysis\` job runs \`govulncheck -format sarif\` and uploads the result via \`github/codeql-action/upload-sarif\`. Here is what happens end-to-end:
1. **SARIF file generated**: \`govulncheck -format sarif\` emits a structured JSON file (Static Analysis Results Interchange Format) describing each reachable vulnerability — including file path, line number, severity, CVE reference, and the full call chain that reaches the vulnerable symbol. Critically, \`-format sarif\` exits 0 even when vulnerabilities are found, so the upload step always runs regardless of findings.
2. **Uploaded to GitHub Code Scanning**: The SARIF is posted to the GitHub Code Scanning API under the \`govulncheck\` category. GitHub parses it and creates persistent alerts in **Security → Code scanning alerts**. Each alert includes the call stack showing exactly how the vulnerable code is reached from this module.
3. **De-duplication across runs**: If the same vulnerability appears in multiple scans, GitHub tracks it as a single alert (not a new one each time). When a dependency is updated and the vulnerability disappears from the SARIF, GitHub automatically closes the alert.
4. **PR annotations**: When a PR introduces a new reachable vulnerability, GitHub adds an inline annotation on the diff pointing to the call site.
5. **Two-job design — soft gate + hard gate**:
- \`govulncheck-analysis\`: non-blocking, uploads SARIF for Code Scanning visibility. Always succeeds so the upload always runs.
- \`govulncheck-tests\`: blocking PR check, runs \`govulncheck\` in text mode (exits non-zero on any reachable finding). This is the gate that fails the PR.
> **Why not use \`golang/govulncheck-action\`?** The official action is blocked by the DataDog enterprise action allowlist (it internally uses \`actions/checkout@v4\` and \`actions/setup-go@v5\` which are not in the allowlist pattern). The \`govulncheck -format sarif\` flag is available natively in \`govulncheck@latest\`, so we install it directly via \`go install\` instead.
### Reviewer's Checklist
- [ ] Changed code has unit tests for its functionality at or near 100% coverage.
- [ ] [System-Tests](https://github.com/DataDog/system-tests/) covering this feature have been added and enabled with the va.b.c-dev version tag.
- [ ] There is a benchmark for any new code, or changes to existing code.
- [ ] If this interacts with the agent in a new way, a system test has been added.
- [ ] New code is free of linting errors. You can check this by running \`make lint\` locally.
- [ ] New code doesn't break existing tests. You can check this by running \`make test\` locally.
- [ ] Add an appropriate team label so this PR gets put in the right place for the release notes.
- [ ] All generated files are up to date. You can check this by running \`make generate\` locally.
- [ ] Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild. Make sure all nested modules are up to date by running \`make fix-modules\` locally.
### References
- [Filippo Valsorda: Turn Dependabot Off](https://words.filippo.io/dependabot/) — rationale for replacing Dependabot with govulncheck
- [golang/govulncheck-action](https://github.com/golang/govulncheck-action) — official Go team action with SARIF support
- [Setting up govulncheck with GitHub Code Scanning](https://www.jvt.me/posts/2025/09/11/govulncheck-github-actions/) — detailed integration walkthrough
- [govulncheck JSON output format](https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck) — streaming JSON format used by the remediation script
- [CodeQL Action v4](https://github.com/github/codeql-action) — SARIF upload action (v3 deprecated Dec 2026)
Co-authored-by: dario.castane <[email protected]>1 parent 41183c0 commit ee8dce2
3 files changed
Lines changed: 275 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
3 | 12 | | |
4 | 13 | | |
5 | 14 | | |
| |||
20 | 29 | | |
21 | 30 | | |
22 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
23 | 36 | | |
24 | 37 | | |
| 38 | + | |
25 | 39 | | |
26 | 40 | | |
27 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
28 | 49 | | |
29 | 50 | | |
30 | 51 | | |
31 | 52 | | |
| 53 | + | |
32 | 54 | | |
33 | | - | |
34 | | - | |
35 | | - | |
| 55 | + | |
| 56 | + | |
36 | 57 | | |
37 | 58 | | |
38 | | - | |
39 | | - | |
40 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
41 | 65 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
0 commit comments