name: dependency-scan
description: Scans project dependencies for known vulnerabilities, outdated packages, and license compliance issues. Supports vulnerability scanning (CVE detection), SBOM generation, license compliance checking, and supply chain security analysis across multiple ecosystems (npm, pip, cargo, go, maven, etc.). Trigger keywords: dependency scan, vulnerability, CVE, Snyk, Dependabot, Renovate, npm audit, cargo audit, pip-audit, safety, outdated packages, SBOM, software bill of materials, license compliance, supply chain, security advisory, transitive dependency, lock file.
allowed-tools: Read, Grep, Glob, Bash
Dependency Scan
Overview
This skill focuses on identifying security vulnerabilities, outdated packages, and license compliance issues in project dependencies. It covers multiple package ecosystems (JavaScript/Node.js, Python, Rust, Go, Ruby, Java, .NET, PHP) and provides remediation guidance, SBOM generation, and supply chain security analysis.
When to Use
- Scanning dependencies for CVEs and security advisories
- Checking for outdated or unmaintained packages
- Generating Software Bill of Materials (SBOM)
- Verifying license compliance and compatibility
- Analyzing supply chain risks and transitive dependencies
- Setting up automated dependency updates (Dependabot, Renovate, Snyk)
- Investigating security alerts from GitHub/GitLab
- Auditing dependencies before production deployment
Instructions
1. Identify Dependencies
- Parse manifest files (package.json, requirements.txt, etc.)
- Build complete dependency tree
- Identify direct vs transitive dependencies
- Check for phantom dependencies
2. Vulnerability Scanning
- Check against CVE databases
- Identify severity levels
- Find affected versions
- Check for available patches
3. Assess Risks
- Evaluate exploitability
- Check for active exploitation
- Assess impact on application
- Prioritize remediations
4. Report and Remediate
- Document all findings
- Provide upgrade paths
- Suggest alternatives
- Create remediation plan
5. Language-Specific Scanning
JavaScript/Node.js:
- Use
npm audit or yarn audit for vulnerability scanning
- Check
package-lock.json or yarn.lock for reproducibility
- Consider
npm-check-updates for upgrade analysis
- Use
license-checker for license compliance
Python:
- Use
pip-audit or safety for CVE scanning
- Check
requirements.txt and Pipfile.lock
- Use
pip-compile with --generate-hashes for integrity
- Consider
pipdeptree for dependency visualization
Rust:
- Use
cargo audit for RustSec advisories
- Check
Cargo.lock for reproducible builds
- Use
cargo outdated for version analysis
- Consider
cargo deny for policy enforcement
Go:
- Use
govulncheck for vulnerability scanning
- Check
go.sum for module integrity
- Use
go list -m all to enumerate dependencies
- Consider
nancy for OSS Index checking
6. SBOM Generation
Generate Software Bill of Materials for supply chain transparency:
CycloneDX:
npm install -g @cyclonedx/cyclonedx-npm && cyclonedx-npm --output-file sbom.json
cargo install cargo-cyclonedx && cargo cyclonedx
pip install cyclonedx-bom && cyclonedx-py
SPDX:
- Use
syft (universal tool): syft . -o spdx-json > sbom.spdx.json
- Use
trivy for container images: trivy image --format spdx-json myimage:tag
Purpose: Track all components for vulnerability management, license compliance, and incident response.
7. License Compliance Checking
Ensure all dependencies have compatible licenses:
Automated Tools:
- Node.js:
npx license-checker --onlyAllow 'MIT;Apache-2.0;BSD-2-Clause;BSD-3-Clause;ISC'
- Rust:
cargo deny check licenses
- Python:
pip-licenses
- Universal:
fossology, scancode-toolkit
License Categories:
- Permissive: MIT, Apache-2.0, BSD (generally safe)
- Weak Copyleft: MPL, LGPL (check linking requirements)
- Strong Copyleft: GPL, AGPL (may require source disclosure)
- Unknown/Missing: Investigate before use
Best Practices
- Regular Scanning: Automate daily/weekly scans
- Lock Files: Use lockfiles for reproducibility
- Minimal Dependencies: Only include what's needed
- Verify Sources: Use trusted registries
- Review Updates: Don't blindly update
- License Compliance: Ensure compatible licenses
- SBOM: Maintain software bill of materials
Examples
Example 1: Scanning Commands by Ecosystem
# JavaScript/Node.js
npm audit
npm audit --json > audit-report.json
npm outdated
npx npm-check-updates
# Python
pip-audit
safety check
pip list --outdated
pip-compile --generate-hashes
# Rust
cargo audit
cargo outdated
cargo deny check
# Go
go list -m all | nancy sleuth
govulncheck ./...
# Ruby
bundle audit
bundle outdated
# Java/Maven
mvn dependency-check:check
mvn versions:display-dependency-updates
# .NET
dotnet list package --vulnerable
dotnet list package --outdated
# PHP
composer audit
composer outdated
Example 2: GitHub Actions Dependency Scanning
name: Dependency Scanning
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: "0 6 * * *" # Daily at 6 AM
jobs:
dependency-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: "fs"
scan-ref: "."
format: "sarif"
output: "trivy-results.sarif"
severity: "CRITICAL,HIGH"
- name: Upload Trivy scan results
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: "trivy-results.sarif"
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Run npm audit
run: |
npm ci
npm audit --audit-level=high
- name: Check for outdated packages
run: npm outdated || true
- name: License check
run: npx license-checker --onlyAllow 'MIT;Apache-2.0;BSD-2-Clause;BSD-3-Clause;ISC'
snyk-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/node@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --severity-threshold=high
Example 3: Dependency Analysis Report Template
# Dependency Security Report
**Generated:** 2024-01-15
**Project:** my-application
**Total Dependencies:** 245 (42 direct, 203 transitive)
## Summary
| Severity | Count | Status |
| -------- | ----- | ------------------ |
| Critical | 2 | Action Required |
| High | 5 | Action Required |
| Medium | 12 | Review Recommended |
| Low | 8 | Monitor |
## Critical Vulnerabilities
### CVE-2024-1234 - Remote Code Execution in lodash
- **Package:** lodash@4.17.20
- **Severity:** Critical (CVSS 9.8)
- **Affected Versions:** < 4.17.21
- **Fixed Version:** 4.17.21
- **Path:** my-app > express > lodash
- **Description:** Prototype pollution vulnerability allowing RCE
- **Remediation:** `npm update lodash`
### CVE-2024-5678 - SQL Injection in sequelize
- **Package:** sequelize@6.28.0
- **Severity:** Critical (CVSS 9.1)
- **Affected Versions:** < 6.29.0
- **Fixed Version:** 6.29.0
- **Path:** my-app > sequelize
- **Description:** SQL injection via raw query methods
- **Remediation:** `npm update sequelize`
## License Compliance
| License | Count | Compliance |
| ------------ | ----- | -------------------- |
| MIT | 180 | Approved |
| Apache-2.0 | 45 | Approved |
| BSD-3-Clause | 15 | Approved |
| GPL-3.0 | 3 | Review Required |
| Unknown | 2 | Investigation Needed |
## Recommendations
1. **Immediate:** Update lodash and sequelize to fix critical vulnerabilities
2. **Short-term:** Review GPL-licensed dependencies for compatibility
3. **Ongoing:** Enable Dependabot/Renovate for automated updates
Example 4: Renovate Configuration
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:base", ":semanticCommits", ":preserveSemverRanges"],
"schedule": ["before 6am on Monday"],
"vulnerabilityAlerts": {
"enabled": true,
"labels": ["security"]
},
"packageRules": [
{
"matchUpdateTypes": ["major"],
"labels": ["major-update"],
"automerge": false
},
{
"matchUpdateTypes": ["minor", "patch"],
"matchCurrentVersion": "!/^0/",
"automerge": true,
"automergeType": "pr",
"platformAutomerge": true
},
{
"matchPackagePatterns": ["^@types/"],
"automerge": true,
"groupName": "type definitions"
},
{
"matchDepTypes": ["devDependencies"],
"automerge": true,
"groupName": "dev dependencies"
}
],
"prConcurrentLimit": 5,
"prHourlyLimit": 2
}
1---2name: dependency-scan3description: This skill focuses on identifying security vulnerabilities, outdated packages, and license compliance issues in project dependencies. It covers multiple package ecosystems (JavaScript/Node.js, Python,4---5
6---
7name: dependency-scan
8description: Scans project dependencies for known vulnerabilities, outdated packages, and license compliance issues. Supports vulnerability scanning (CVE detection), SBOM generation, license compliance checking, and supply chain security analysis across multiple ecosystems (npm, pip, cargo, go, maven, etc.). Trigger keywords: dependency scan, vulnerability, CVE, Snyk, Dependabot, Renovate, npm audit, cargo audit, pip-audit, safety, outdated packages, SBOM, software bill of materials, license compliance, supply chain, security advisory, transitive dependency, lock file.
9allowed-tools: Read, Grep, Glob, Bash
10---
11
12# Dependency Scan
13
14## Overview
15
16This skill focuses on identifying security vulnerabilities, outdated packages, and license compliance issues in project dependencies. It covers multiple package ecosystems (JavaScript/Node.js, Python, Rust, Go, Ruby, Java, .NET, PHP) and provides remediation guidance, SBOM generation, and supply chain security analysis.
17
18## When to Use
19
20- Scanning dependencies for CVEs and security advisories
21- Checking for outdated or unmaintained packages
22- Generating Software Bill of Materials (SBOM)
23- Verifying license compliance and compatibility
24- Analyzing supply chain risks and transitive dependencies
25- Setting up automated dependency updates (Dependabot, Renovate, Snyk)
26- Investigating security alerts from GitHub/GitLab
27- Auditing dependencies before production deployment
28
29## Instructions
30
31### 1. Identify Dependencies
32
33- Parse manifest files (package.json, requirements.txt, etc.)
34- Build complete dependency tree
35- Identify direct vs transitive dependencies
36- Check for phantom dependencies
37
38### 2. Vulnerability Scanning
39
40- Check against CVE databases
41- Identify severity levels
42- Find affected versions
43- Check for available patches
44
45### 3. Assess Risks
46
47- Evaluate exploitability
48- Check for active exploitation
49- Assess impact on application
50- Prioritize remediations
51
52### 4. Report and Remediate
53
54- Document all findings
55- Provide upgrade paths
56- Suggest alternatives
57- Create remediation plan
58
59### 5. Language-Specific Scanning
60
61**JavaScript/Node.js:**
62
63- Use `npm audit` or `yarn audit` for vulnerability scanning
64- Check `package-lock.json` or `yarn.lock` for reproducibility
65- Consider `npm-check-updates` for upgrade analysis
66- Use `license-checker` for license compliance
67
68**Python:**
69
70- Use `pip-audit` or `safety` for CVE scanning
71- Check `requirements.txt` and `Pipfile.lock`
72- Use `pip-compile` with `--generate-hashes` for integrity
73- Consider `pipdeptree` for dependency visualization
74
75**Rust:**
76
77- Use `cargo audit` for RustSec advisories
78- Check `Cargo.lock` for reproducible builds
79- Use `cargo outdated` for version analysis
80- Consider `cargo deny` for policy enforcement
81
82**Go:**
83
84- Use `govulncheck` for vulnerability scanning
85- Check `go.sum` for module integrity
86- Use `go list -m all` to enumerate dependencies
87- Consider `nancy` for OSS Index checking
88
89### 6. SBOM Generation
90
91Generate Software Bill of Materials for supply chain transparency:
92
93**CycloneDX:**
94
95- `npm install -g @cyclonedx/cyclonedx-npm && cyclonedx-npm --output-file sbom.json`
96- `cargo install cargo-cyclonedx && cargo cyclonedx`
97- `pip install cyclonedx-bom && cyclonedx-py`
98
99**SPDX:**
100
101- Use `syft` (universal tool): `syft . -o spdx-json > sbom.spdx.json`
102- Use `trivy` for container images: `trivy image --format spdx-json myimage:tag`
103
104**Purpose:** Track all components for vulnerability management, license compliance, and incident response.
105
106### 7. License Compliance Checking
107
108Ensure all dependencies have compatible licenses:
109
110**Automated Tools:**
111
112- Node.js: `npx license-checker --onlyAllow 'MIT;Apache-2.0;BSD-2-Clause;BSD-3-Clause;ISC'`
113- Rust: `cargo deny check licenses`
114- Python: `pip-licenses`
115- Universal: `fossology`, `scancode-toolkit`
116
117**License Categories:**
118
119- Permissive: MIT, Apache-2.0, BSD (generally safe)
120- Weak Copyleft: MPL, LGPL (check linking requirements)
121- Strong Copyleft: GPL, AGPL (may require source disclosure)
122- Unknown/Missing: Investigate before use
123
124## Best Practices
125
1261. **Regular Scanning**: Automate daily/weekly scans
1272. **Lock Files**: Use lockfiles for reproducibility
1283. **Minimal Dependencies**: Only include what's needed
1294. **Verify Sources**: Use trusted registries
1305. **Review Updates**: Don't blindly update
1316. **License Compliance**: Ensure compatible licenses
1327. **SBOM**: Maintain software bill of materials
133
134## Examples
135
136### Example 1: Scanning Commands by Ecosystem
137
138```bash
139# JavaScript/Node.js
140npm audit
141npm audit --json > audit-report.json
142npm outdated
143npx npm-check-updates
144
145# Python
146pip-audit
147safety check
148pip list --outdated
149pip-compile --generate-hashes
150
151# Rust
152cargo audit
153cargo outdated
154cargo deny check
155
156# Go
157go list -m all | nancy sleuth
158govulncheck ./...
159
160# Ruby
161bundle audit
162bundle outdated
163
164# Java/Maven
165mvn dependency-check:check
166mvn versions:display-dependency-updates
167
168# .NET
169dotnet list package --vulnerable
170dotnet list package --outdated
171
172# PHP
173composer audit
174composer outdated
175```
176
177### Example 2: GitHub Actions Dependency Scanning
178
179```yaml
180name: Dependency Scanning
181
182on:
183 push:
184 branches: [main]
185 pull_request:
186 branches: [main]
187 schedule:
188 - cron: "0 6 * * *" # Daily at 6 AM
189
190jobs:
191 dependency-scan:
192 runs-on: ubuntu-latest
193
194 steps:
195 - uses: actions/checkout@v4
196
197 - name: Run Trivy vulnerability scanner
198 uses: aquasecurity/trivy-action@master
199 with:
200 scan-type: "fs"
201 scan-ref: "."
202 format: "sarif"
203 output: "trivy-results.sarif"
204 severity: "CRITICAL,HIGH"
205
206 - name: Upload Trivy scan results
207 uses: github/codeql-action/upload-sarif@v2
208 with:
209 sarif_file: "trivy-results.sarif"
210
211 - name: Setup Node.js
212 uses: actions/setup-node@v4
213 with:
214 node-version: "20"
215
216 - name: Run npm audit
217 run: |
218 npm ci
219 npm audit --audit-level=high
220
221 - name: Check for outdated packages
222 run: npm outdated || true
223
224 - name: License check
225 run: npx license-checker --onlyAllow 'MIT;Apache-2.0;BSD-2-Clause;BSD-3-Clause;ISC'
226
227 snyk-scan:
228 runs-on: ubuntu-latest
229 steps:
230 - uses: actions/checkout@v4
231
232 - name: Run Snyk to check for vulnerabilities
233 uses: snyk/actions/node@master
234 env:
235 SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
236 with:
237 args: --severity-threshold=high
238```
239
240### Example 3: Dependency Analysis Report Template
241
242```markdown
243# Dependency Security Report
244
245**Generated:** 2024-01-15
246**Project:** my-application
247**Total Dependencies:** 245 (42 direct, 203 transitive)
248
249## Summary
250
251| Severity | Count | Status |
252| -------- | ----- | ------------------ |
253| Critical | 2 | Action Required |
254| High | 5 | Action Required |
255| Medium | 12 | Review Recommended |
256| Low | 8 | Monitor |
257
258## Critical Vulnerabilities
259
260### CVE-2024-1234 - Remote Code Execution in lodash
261
262- **Package:** lodash@4.17.20
263- **Severity:** Critical (CVSS 9.8)
264- **Affected Versions:** < 4.17.21
265- **Fixed Version:** 4.17.21
266- **Path:** my-app > express > lodash
267- **Description:** Prototype pollution vulnerability allowing RCE
268- **Remediation:** `npm update lodash`
269
270### CVE-2024-5678 - SQL Injection in sequelize
271
272- **Package:** sequelize@6.28.0
273- **Severity:** Critical (CVSS 9.1)
274- **Affected Versions:** < 6.29.0
275- **Fixed Version:** 6.29.0
276- **Path:** my-app > sequelize
277- **Description:** SQL injection via raw query methods
278- **Remediation:** `npm update sequelize`
279
280## License Compliance
281
282| License | Count | Compliance |
283| ------------ | ----- | -------------------- |
284| MIT | 180 | Approved |
285| Apache-2.0 | 45 | Approved |
286| BSD-3-Clause | 15 | Approved |
287| GPL-3.0 | 3 | Review Required |
288| Unknown | 2 | Investigation Needed |
289
290## Recommendations
291
2921. **Immediate:** Update lodash and sequelize to fix critical vulnerabilities
2932. **Short-term:** Review GPL-licensed dependencies for compatibility
2943. **Ongoing:** Enable Dependabot/Renovate for automated updates
295```
296
297### Example 4: Renovate Configuration
298
299```json
300{
301 "$schema": "https://docs.renovatebot.com/renovate-schema.json",
302 "extends": ["config:base", ":semanticCommits", ":preserveSemverRanges"],
303 "schedule": ["before 6am on Monday"],
304 "vulnerabilityAlerts": {
305 "enabled": true,
306 "labels": ["security"]
307 },
308 "packageRules": [
309 {
310 "matchUpdateTypes": ["major"],
311 "labels": ["major-update"],
312 "automerge": false
313 },
314 {
315 "matchUpdateTypes": ["minor", "patch"],
316 "matchCurrentVersion": "!/^0/",
317 "automerge": true,
318 "automergeType": "pr",
319 "platformAutomerge": true
320 },
321 {
322 "matchPackagePatterns": ["^@types/"],
323 "automerge": true,
324 "groupName": "type definitions"
325 },
326 {
327 "matchDepTypes": ["devDependencies"],
328 "automerge": true,
329 "groupName": "dev dependencies"
330 }
331 ],
332 "prConcurrentLimit": 5,
333 "prHourlyLimit": 2
334}
335```