Skip to content

Commit 7c240e5

Browse files
author
Parship Chowdhury
authored
Add support for sonatype nancy vulnerability scanning (#153)
* added sonatype nancy vulnerability scanning Signed-off-by: Parship Chowdhury <i.am.parship@gmail.com> * fix 1 Signed-off-by: Parship Chowdhury <i.am.parship@gmail.com> * fix 2 Signed-off-by: Parship Chowdhury <i.am.parship@gmail.com> * vulnerability check fixed Signed-off-by: Parship Chowdhury <i.am.parship@gmail.com> --------- Signed-off-by: Parship Chowdhury <i.am.parship@gmail.com>
1 parent da2b3fb commit 7c240e5

File tree

5 files changed

+95
-3
lines changed

5 files changed

+95
-3
lines changed

.github/workflows/ci.yaml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212

1313
env:
1414
# Common versions
15-
GO_VERSION: '1.22'
15+
GO_VERSION: '1.23'
1616
GOLANGCI_VERSION: 'v1.55.2'
1717

1818
jobs:
@@ -86,3 +86,38 @@ jobs:
8686
- name: Test
8787
run: |
8888
make test
89+
90+
security-scan:
91+
name: Security Vulnerability Scan
92+
runs-on: ubuntu-24.04
93+
steps:
94+
- name: Checkout
95+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
96+
with:
97+
submodules: true
98+
99+
- name: Setup Go
100+
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
101+
with:
102+
go-version: ${{ env.GO_VERSION }}
103+
104+
- name: Cache Go Dependencies
105+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
106+
with:
107+
path: ~/go/pkg/mod
108+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
109+
restore-keys: ${{ runner.os }}-go-
110+
111+
- name: Generate go.list file for Nancy
112+
run: go list -json -deps ./... > go.list
113+
114+
- name: Run Nancy vulnerability scan
115+
uses: sonatype-nexus-community/nancy-github-action@main
116+
with:
117+
nancyCommand: sleuth
118+
goListFile: go.list
119+
120+
- name: Install and run govulncheck
121+
run: |
122+
go install golang.org/x/vuln/cmd/govulncheck@latest
123+
govulncheck ./...

.nancy-ignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Temporary exclusion - proxy/tokenizer vulnerabilities don't affect our usage
2+
CVE-2025-22870
3+
CVE-2025-22872

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,60 @@ kubectl kruise migrate CloneSet --from Deployment --src-name deployment-demo --d
198198
#### kubectl kruise autoscale SUBCOMMAND [options]
199199
* [ ] kubectl kruise autoscale
200200

201+
## Security
202+
203+
This project includes automated vulnerability scanning to ensure the security of dependencies.
204+
205+
### Vulnerability Scanning
206+
207+
We use two complementary tools to scan for vulnerabilities in our Go dependencies:
208+
209+
1. **Nancy by Sonatype** - Comprehensive dependency scanning against the Sonatype OSS Index
210+
2. **govulncheck** - Official Go vulnerability scanner with call graph analysis to reduce false positives
211+
212+
### CI/CD Security Integration
213+
214+
Security scans are automatically run:
215+
- On every push to `master` and `release*` branches
216+
- On every pull request
217+
- Daily at 2 AM UTC via scheduled workflow
218+
219+
### Handling Vulnerabilities
220+
221+
If vulnerabilities are found:
222+
223+
1. **Review the vulnerability report** - Check if the vulnerability affects your usage
224+
2. **Update dependencies** - Upgrade to a non-vulnerable version if available
225+
3. **Apply workarounds** - If no update is available, consider alternative approaches
226+
4. **Temporary exclusions** - For false positives or accepted risks, add the CVE ID to `.nancy-ignore`
227+
228+
#### Excluding Vulnerabilities
229+
230+
To exclude specific vulnerabilities from Nancy scans, add the CVE ID or OSS Index ID to the `.nancy-ignore` file:
231+
232+
```
233+
# Example: Exclude a specific CVE
234+
CVE-2021-12345
235+
# Example: Exclude by OSS Index ID
236+
9eb9a5bc-8310-4104-bf85-3a820d28ba79
237+
```
238+
239+
### Running Security Scans Locally
240+
241+
To run vulnerability scans locally:
242+
243+
```bash
244+
# Install tools
245+
go install github.com/sonatype-nexus-community/nancy@latest
246+
go install golang.org/x/vuln/cmd/govulncheck@latest
247+
248+
# Run Nancy scan
249+
go list -json -deps ./... > go.list
250+
nancy sleuth --loud
251+
252+
# Run govulncheck
253+
govulncheck ./...
254+
```
201255

202256
### Contributing
203257
We encourage you to help out by reporting issues, improving documentation, fixing bugs, or adding new features.

go.list

12.1 MB
Binary file not shown.

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module github.com/openkruise/kruise-tools
22

3-
go 1.22.0
3+
go 1.23.0
44

5-
toolchain go1.22.4
5+
toolchain go1.23.4
66

77
require (
88
github.com/go-errors/errors v1.4.2

0 commit comments

Comments
 (0)