Skip to content

Commit 2ebd41e

Browse files
authored
sync(workflows): migrate security scans to OSV-Scanner (#189)
1 parent dde4e19 commit 2ebd41e

12 files changed

Lines changed: 494 additions & 96 deletions

.github/docs/repository-features.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ A comprehensive list of built-in features that ship with this repository.
1515
* **Uniform Code Style** via [gofumpt](https://github.com/mvdan/gofumpt) plus zero‑noise linting with [golangci‑lint](https://github.com/golangci/golangci-lint).
1616
* **Confidence‑Boosting Tests** with [testify](https://github.com/stretchr/testify), the Go [race detector](https://blog.golang.org/race-detector), crystal‑clear [HTML coverage](https://blog.golang.org/cover) snapshots, and automatic reporting via internal coverage system.
1717
* **Hands‑Free Releases** delivered by [GoReleaser](https://github.com/goreleaser/goreleaser) whenever you create a [new Tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging).
18-
* **Relentless Dependency & Vulnerability Scans** via [Dependabot](https://dependabot.com) (runs daily at 8am to ensure broadcast dependencies are always current), [Nancy](https://github.com/sonatype-nexus-community/nancy), and [govulncheck](https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck).
18+
* **Relentless Dependency & Vulnerability Scans** via [Dependabot](https://dependabot.com) (runs daily at 8am to ensure broadcast dependencies are always current), [Nancy](https://github.com/sonatype-nexus-community/nancy), [OSV-Scanner](https://github.com/google/osv-scanner), and [govulncheck](https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck).
1919
* **Security Posture by Default** with [CodeQL](https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/about-code-scanning), [OpenSSF Scorecard](https://openssf.org), and secret‑leak detection via [gitleaks](https://github.com/gitleaks/gitleaks).
2020
* **Automatic Syndication** to [pkg.go.dev](https://pkg.go.dev/) on every release for instant godoc visibility.
21-
* **Polished Community Experience** using rich templates for [Issues & PRs](https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-go-broadcastsitory).
21+
* **Polished Community Experience** using rich templates for Issues & PRs.
2222
* **All the Right Meta Files** (`LICENSE`, `CONTRIBUTING.md`, `CODE_OF_CONDUCT.md`, `SUPPORT.md`, `SECURITY.md`) pre‑filled and ready.
2323
* **Code Ownership** clarified through a [CODEOWNERS](../CODEOWNERS) file, keeping reviews fast and focused.
2424
* **Zero‑Noise Dev Environments** with tuned editor settings ([`.editorconfig`](../../.editorconfig)) plus curated *ignore* files for [VS Code](../../.editorconfig), [Docker](../../.dockerignore), and [Git](../../.gitignore).

.github/env/00-core.env

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ ENABLE_YAML_LINT=true
8787
# Security Scanning
8888
ENABLE_SECURITY_SCAN_GITLEAKS=true
8989
ENABLE_SECURITY_SCAN_GOVULNCHECK=true
90-
ENABLE_SECURITY_SCAN_NANCY=true
90+
# Nancy is disabled: Sonatype retired the free OSS Index tier in favor of the
91+
# credit-metered Sonatype Guide backend (Nancy v2). OSV-Scanner replaces it below.
92+
ENABLE_SECURITY_SCAN_NANCY=false
93+
# OSV-Scanner (google/osv-scanner) — multi-source dependency vulnerability scanning
94+
# backed by the OSV.dev database (GHSA, Go vuln DB, and 30+ other sources). Free,
95+
# no account or API key required. Complements govulncheck's reachability analysis.
96+
ENABLE_SECURITY_SCAN_OSV=true
9197

9298
# Documentation & Publishing
9399
ENABLE_GODOCS_PUBLISHING=true

.github/env/10-mage-x.env

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
# ================================================================================================
3737

3838
# MAGE-X version
39-
MAGE_X_VERSION=v1.25.1
39+
MAGE_X_VERSION=v1.26.0
4040

4141
# For mage-x development, set to 'true' to use local version instead of downloading from releases
4242
MAGE_X_USE_LOCAL=false
@@ -77,7 +77,10 @@ MAGE_X_GOVULNCHECK_VERSION=v1.1.4
7777
MAGE_X_GO_SECONDARY_VERSION=1.24.x
7878
MAGE_X_GO_VERSION=1.24.x
7979
MAGE_X_MOCKGEN_VERSION=v0.6.0
80-
MAGE_X_NANCY_VERSION=v1.2.0
80+
MAGE_X_NANCY_VERSION=v2.1.0
81+
# OSV-Scanner version for MAGE-X parity (authoritative pin is OSV_SCANNER_VERSION in
82+
# 10-security.env, which the CI workflow uses to `go install` the scanner).
83+
MAGE_X_OSV_SCANNER_VERSION=v2.5.0
8184
MAGE_X_STATICCHECK_VERSION=2026.1
8285
MAGE_X_SWAG_VERSION=v1.16.6
8386
MAGE_X_YAMLFMT_VERSION=v0.21.0

.github/env/10-pre-commit.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# 🪝 PRE-COMMIT TOOL VERSION
2727
# ================================================================================================
2828

29-
GO_PRE_COMMIT_VERSION=v1.9.1
29+
GO_PRE_COMMIT_VERSION=v1.10.0
3030
GO_PRE_COMMIT_USE_LOCAL=false
3131

3232
# ================================================================================================

.github/env/10-security.env

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
#
88
# This file defines configuration for security scanning tools used by go-fortress:
99
# - Gitleaks: Secret and credential scanning
10-
# - Nancy: Dependency vulnerability scanning via OSS Index
10+
# - Nancy: Dependency vulnerability scanning via OSS Index (DEPRECATED — disabled)
1111
# - Govulncheck: Go-specific vulnerability detection
12-
# - CVE exclusion lists for known acceptable vulnerabilities
12+
# - OSV-Scanner: Multi-source dependency scanning via the OSV.dev database
13+
# - Shared vulnerability exclusion list (GO-*, GHSA-*, and CVE-* advisory IDs) for known acceptable vulnerabilities
1314
#
1415
# Override in: 90-project.env for project-specific security settings
1516
#
@@ -32,34 +33,55 @@ GITLEAKS_NOTIFY_USER_LIST=@mrz1836
3233
GITLEAKS_CONFIG_FILE=
3334

3435
# ================================================================================================
35-
# 🛡️ NANCY CONFIGURATION
36+
# 🚫 SHARED VULNERABILITY EXCLUSIONS (single source of truth)
3637
# ================================================================================================
37-
38-
# Nancy CVE Exclusions (known acceptable vulnerabilities)
39-
# Format: comma-separated CVE IDs (e.g., CVE-9999-12345,CVE-9999-43210)
40-
# These are example/fake CVEs - replace with real ones as needed
41-
NANCY_EXCLUDES=CVE-9999-12345,CVE-9999-43210
42-
43-
# OSS Index Authentication for Nancy (optional, reduces rate limits)
44-
# Set OSSI_USERNAME and OSSI_TOKEN in GitHub Secrets
45-
# Get your API token from: https://ossindex.sonatype.org/user-token
46-
# OSSI_USERNAME should be your email address
38+
#
39+
# ONE list of advisory IDs to exclude across ALL dependency scanners. Maintain it here (or
40+
# override in 90-project.env); the CI workflow adapts it to each tool's native mechanism:
41+
# - govulncheck : exported as MAGE_X_CVE_EXCLUDES for `magex deps:audit`
42+
# - OSV-Scanner : rendered into an osv-scanner.toml `[[IgnoredVulns]]` config (--config)
43+
# - Nancy : passed to `nancy sleuth --exclude-vulnerability`
44+
#
45+
# Format: comma-separated advisory IDs. Use each tool's native namespace as appropriate —
46+
# each scanner silently ignores IDs outside its own namespace:
47+
# - Go vuln DB / OSV IDs -> GO-YYYY-NNNN (govulncheck, OSV-Scanner)
48+
# - GitHub advisories -> GHSA-xxxx-... (OSV-Scanner)
49+
# - CVE IDs -> CVE-YYYY-NNNN (OSV-Scanner, Nancy)
50+
#
51+
# Keep this DEFAULT EMPTY. Add real, justified exclusions in 90-project.env with a comment
52+
# explaining why each is acceptable (unreachable, unmaintained-but-unused, already patched…).
53+
SECURITY_VULN_EXCLUDES=
54+
#
55+
# Backwards compatibility: the legacy per-tool variables MAGE_X_CVE_EXCLUDES (govulncheck)
56+
# and NANCY_EXCLUDES (Nancy) are still honored — the workflow merges them into the effective
57+
# exclusion list. Projects that already set them keep working; new projects should prefer the
58+
# single SECURITY_VULN_EXCLUDES above. Define the legacy vars only if you need them.
4759

4860
# ================================================================================================
49-
# 🔐 GOVULNCHECK CONFIGURATION
61+
# 🛰️ OSV-SCANNER CONFIGURATION
5062
# ================================================================================================
51-
52-
# Govulncheck/Magex CVE Exclusions (known acceptable vulnerabilities)
53-
# Format: comma-separated CVE IDs (e.g., CVE-9999-12345,CVE-9999-43210)
54-
# Used by: magex deps:audit (govulncheck)
55-
# Can also be passed via: magex deps:audit exclude=CVE-9999-12345
56-
# These are example/fake CVEs - replace with real ones as needed
57-
MAGE_X_CVE_EXCLUDES=CVE-9999-12345,CVE-9999-43210
63+
#
64+
# OSV-Scanner (https://github.com/google/osv-scanner) scans Go dependencies against the
65+
# OSV.dev database (aggregates GHSA, the Go vuln DB, and 30+ other advisory sources).
66+
# Free, no account/API key required. Results are uploaded to GitHub Code Scanning as SARIF.
67+
#
68+
# Enforcement mode (default: enforcing):
69+
# true = fail the security job when affecting vulnerabilities are found (enforcing gate).
70+
# false = report only (findings still appear in Code Scanning + job summary, CI passes).
71+
# Only an *affecting* finding (OSV exit 1) can fail CI; infrastructure errors
72+
# (network / OSV.dev / DB) are ALWAYS inconclusive and never fail CI.
73+
#
74+
# This is ON by default for all projects. To make OSV report-only for a specific repo,
75+
# override in that repo's 90-project.env: OSV_SCANNER_FAIL_ON_VULNERABILITY=false
76+
OSV_SCANNER_FAIL_ON_VULNERABILITY=true
5877

5978
# ================================================================================================
6079
# 🛠️ SECURITY TOOL VERSIONS
6180
# ================================================================================================
6281

6382
GITLEAKS_VERSION=8.30.1
6483
GOVULNCHECK_VERSION=v1.1.4
65-
NANCY_VERSION=v1.2.0
84+
NANCY_VERSION=v2.1.0
85+
# OSV-Scanner: pin to a validated release (v2.5.0 released 2026-08-07; v2.4.0 is the
86+
# prior stable). Installed via `go install github.com/google/osv-scanner/v2/...`.
87+
OSV_SCANNER_VERSION=v2.5.0

.github/tech-conventions/commit-branch-conventions.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,15 @@ docs(README): improve installation instructions
3434
To ensure consistent commit messages and code quality, we use the external **go-pre-commit** tool that checks formatting, linting, and other standards before allowing a commit. The system is configured via `.github/env/` and can be installed with:
3535

3636
```bash
37-
# Install the external tool
38-
go install github.com/mrz1836/go-pre-commit/cmd/go-pre-commit@latest
37+
# Install the latest release binary into ~/.local/bin, verified against checksums.txt
38+
VER=$(curl -fsSLI -o /dev/null -w '%{url_effective}' https://github.com/mrz1836/go-pre-commit/releases/latest | sed 's#.*/v##')
39+
OS=$(uname -s | tr '[:upper:]' '[:lower:]'); ARCH=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')
40+
F="go-pre-commit_${VER}_${OS}_${ARCH}.tar.gz"; U="https://github.com/mrz1836/go-pre-commit/releases/download/v${VER}"
41+
mkdir -p ~/.local/bin && cd "$(mktemp -d)" && curl -fsSLO "$U/$F" \
42+
&& WANT=$(curl -fsSL "$U/go-pre-commit_${VER}_checksums.txt" | awk -v f="$F" '$2==f{print $1}') \
43+
&& GOT=$( { command -v sha256sum >/dev/null && sha256sum "$F" || shasum -a 256 "$F"; } | awk '{print $1}') \
44+
&& [ -n "$WANT" ] && [ "$WANT" = "$GOT" ] \
45+
&& tar -xzf "$F" -C ~/.local/bin go-pre-commit
3946

4047
# Install hooks in your repository
4148
go-pre-commit install

.github/tech-conventions/pre-commit.md

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,15 @@
2929
### Installation
3030

3131
```bash
32-
# Install the go-pre-commit tool
33-
go install github.com/mrz1836/go-pre-commit/cmd/go-pre-commit@latest
32+
# Install the latest go-pre-commit release into ~/.local/bin (user-writable, no sudo), verified against checksums.txt
33+
VER=$(curl -fsSLI -o /dev/null -w '%{url_effective}' https://github.com/mrz1836/go-pre-commit/releases/latest | sed 's#.*/v##')
34+
OS=$(uname -s | tr '[:upper:]' '[:lower:]'); ARCH=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')
35+
F="go-pre-commit_${VER}_${OS}_${ARCH}.tar.gz"; U="https://github.com/mrz1836/go-pre-commit/releases/download/v${VER}"
36+
mkdir -p ~/.local/bin && cd "$(mktemp -d)" && curl -fsSLO "$U/$F" \
37+
&& WANT=$(curl -fsSL "$U/go-pre-commit_${VER}_checksums.txt" | awk -v f="$F" '$2==f{print $1}') \
38+
&& GOT=$( { command -v sha256sum >/dev/null && sha256sum "$F" || shasum -a 256 "$F"; } | awk '{print $1}') \
39+
&& [ -n "$WANT" ] && [ "$WANT" = "$GOT" ] \
40+
&& tar -xzf "$F" -C ~/.local/bin go-pre-commit
3441

3542
# Install hooks in your repository
3643
cd your-go-project
@@ -40,6 +47,10 @@ go-pre-commit install
4047
go-pre-commit --version
4148
```
4249

50+
> `~/.local/bin` must be on your `PATH` — add `export PATH="$HOME/.local/bin:$PATH"` to
51+
> your shell profile if `go-pre-commit` isn't found. Installing the release binary into a
52+
> user-writable directory also lets `go-pre-commit update` self-update it in place later.
53+
4354
### First Usage
4455

4556
```bash
@@ -241,10 +252,10 @@ The project has migrated from the embedded GoFortress pre-commit system (`.githu
241252

242253
| Aspect | Old (Embedded) | New (External) |
243254
|------------------|--------------------------------------------|------------------------------------------------------------------------|
244-
| **Location** | `.github/pre-commit/gofortress-pre-commit` | `go install github.com/mrz1836/go-pre-commit/cmd/go-pre-commit@latest` |
255+
| **Location** | `.github/pre-commit/gofortress-pre-commit` | Release binary in `~/.local/bin` (see [Installation](#installation)) |
245256
| **Installation** | `cd .github/pre-commit && magex build` | `go-pre-commit install` |
246257
| **Maintenance** | Part of repository | External tool, versioned independently |
247-
| **Updates** | Manual code updates | `go install` latest version |
258+
| **Updates** | Manual code updates | `go-pre-commit update` |
248259
| **Distribution** | Repository-specific | Reusable across Go projects |
249260

250261
### Migration Steps
@@ -257,10 +268,7 @@ The project has migrated from the embedded GoFortress pre-commit system (`.githu
257268

258269
2. **Install new system**:
259270
```bash
260-
# Install external tool
261-
go install github.com/mrz1836/go-pre-commit/cmd/go-pre-commit@latest
262-
263-
# Install hooks
271+
# Install the go-pre-commit release binary (see Installation above), then:
264272
go-pre-commit install
265273
```
266274

@@ -295,12 +303,9 @@ The project has migrated from the embedded GoFortress pre-commit system (`.githu
295303

296304
```bash
297305
# "go-pre-commit not found"
298-
# Fix: Ensure GOPATH/bin is in your PATH
299-
echo 'export PATH=$PATH:$(go env GOPATH)/bin' >> ~/.bashrc
306+
# Fix: Ensure the install directory (~/.local/bin) is in your PATH
307+
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
300308
source ~/.bashrc
301-
302-
# Alternative: Install to a directory in your PATH
303-
go install github.com/mrz1836/go-pre-commit/cmd/go-pre-commit@latest
304309
```
305310

306311
**Hook Issues:**
@@ -379,17 +384,24 @@ magex tidy # Test mod-tidy integration
379384

380385
**Developer Onboarding:**
381386
```bash
382-
# Include in developer setup scripts
383-
go install github.com/mrz1836/go-pre-commit/cmd/go-pre-commit@latest
387+
# Include in developer setup scripts (installs the verified release binary into ~/.local/bin)
388+
VER=$(curl -fsSLI -o /dev/null -w '%{url_effective}' https://github.com/mrz1836/go-pre-commit/releases/latest | sed 's#.*/v##')
389+
OS=$(uname -s | tr '[:upper:]' '[:lower:]'); ARCH=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')
390+
F="go-pre-commit_${VER}_${OS}_${ARCH}.tar.gz"; U="https://github.com/mrz1836/go-pre-commit/releases/download/v${VER}"
391+
mkdir -p ~/.local/bin && cd "$(mktemp -d)" && curl -fsSLO "$U/$F" \
392+
&& WANT=$(curl -fsSL "$U/go-pre-commit_${VER}_checksums.txt" | awk -v f="$F" '$2==f{print $1}') \
393+
&& GOT=$( { command -v sha256sum >/dev/null && sha256sum "$F" || shasum -a 256 "$F"; } | awk '{print $1}') \
394+
&& [ -n "$WANT" ] && [ "$WANT" = "$GOT" ] \
395+
&& tar -xzf "$F" -C ~/.local/bin go-pre-commit
384396
go-pre-commit install
385397
```
386398

387399
### Maintenance
388400

389401
**Regular Updates:**
390402
```bash
391-
# Update go-pre-commit itself
392-
go install github.com/mrz1836/go-pre-commit/cmd/go-pre-commit@latest
403+
# Update go-pre-commit itself (self-update; alias: upgrade)
404+
go-pre-commit update
393405
394406
# Update tool versions in 10-pre-commit.env
395407
GO_PRE_COMMIT_GOLANGCI_LINT_VERSION=v2.6.0
@@ -414,7 +426,7 @@ go-pre-commit transforms the pre-commit experience for Go projects by providing:
414426
The migration from the embedded GoFortress system to the external tool provides better maintainability and reusability while preserving all performance benefits.
415427

416428
**Next Steps:**
417-
1. Install go-pre-commit: `go install github.com/mrz1836/go-pre-commit/cmd/go-pre-commit@latest`
429+
1. Install go-pre-commit: download the release binary (see [Installation](#installation))
418430
2. Set up hooks: `go-pre-commit install`
419431
3. Verify with: `go-pre-commit run --all-files`
420432
4. Start enjoying faster, more reliable pre-commit checks

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949

5050
# Initializes the CodeQL tools for scanning.
5151
- name: Initialize CodeQL
52-
uses: github/codeql-action/init@f205ea1c3313d32999d8d6a48b4f6530d4437b38 # v4.37.4
52+
uses: github/codeql-action/init@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6
5353
with:
5454
languages: ${{ matrix.language }}
5555
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -60,7 +60,7 @@ jobs:
6060
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
6161
# If this step fails, then you should remove it and run the build manually (see below)
6262
- name: Autobuild
63-
uses: github/codeql-action/autobuild@f205ea1c3313d32999d8d6a48b4f6530d4437b38 # v4.37.4
63+
uses: github/codeql-action/autobuild@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6
6464

6565
# ℹ️ Command-line programs to run using the OS shell.
6666
# 📚 https://git.io/JvXDl
@@ -70,4 +70,4 @@ jobs:
7070
# uses a compiled language
7171

7272
- name: Perform CodeQL Analysis
73-
uses: github/codeql-action/analyze@f205ea1c3313d32999d8d6a48b4f6530d4437b38 # v4.37.4
73+
uses: github/codeql-action/analyze@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6

0 commit comments

Comments
 (0)