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-scan-23description: 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.4---56---7name: dependency-scan8description: 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, Bash10---1112# Dependency Scan1314## Overview1516This 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.1718## When to Use1920- Scanning dependencies for CVEs and security advisories21- Checking for outdated or unmaintained packages22- Generating Software Bill of Materials (SBOM)23- Verifying license compliance and compatibility24- Analyzing supply chain risks and transitive dependencies25- Setting up automated dependency updates (Dependabot, Renovate, Snyk)26- Investigating security alerts from GitHub/GitLab27- Auditing dependencies before production deployment2829## Instructions3031### 1. Identify Dependencies3233- Parse manifest files (package.json, requirements.txt, etc.)34- Build complete dependency tree35- Identify direct vs transitive dependencies36- Check for phantom dependencies3738### 2. Vulnerability Scanning3940- Check against CVE databases41- Identify severity levels42- Find affected versions43- Check for available patches4445### 3. Assess Risks4647- Evaluate exploitability48- Check for active exploitation49- Assess impact on application50- Prioritize remediations5152### 4. Report and Remediate5354- Document all findings55- Provide upgrade paths56- Suggest alternatives57- Create remediation plan5859### 5. Language-Specific Scanning6061**JavaScript/Node.js:**62- Use `npm audit` or `yarn audit` for vulnerability scanning63- Check `package-lock.json` or `yarn.lock` for reproducibility64- Consider `npm-check-updates` for upgrade analysis65- Use `license-checker` for license compliance6667**Python:**68- Use `pip-audit` or `safety` for CVE scanning69- Check `requirements.txt` and `Pipfile.lock`70- Use `pip-compile` with `--generate-hashes` for integrity71- Consider `pipdeptree` for dependency visualization7273**Rust:**74- Use `cargo audit` for RustSec advisories75- Check `Cargo.lock` for reproducible builds76- Use `cargo outdated` for version analysis77- Consider `cargo deny` for policy enforcement7879**Go:**80- Use `govulncheck` for vulnerability scanning81- Check `go.sum` for module integrity82- Use `go list -m all` to enumerate dependencies83- Consider `nancy` for OSS Index checking8485### 6. SBOM Generation8687Generate Software Bill of Materials for supply chain transparency:8889**CycloneDX:**90- `npm install -g @cyclonedx/cyclonedx-npm && cyclonedx-npm --output-file sbom.json`91- `cargo install cargo-cyclonedx && cargo cyclonedx`92- `pip install cyclonedx-bom && cyclonedx-py`9394**SPDX:**95- Use `syft` (universal tool): `syft . -o spdx-json > sbom.spdx.json`96- Use `trivy` for container images: `trivy image --format spdx-json myimage:tag`9798**Purpose:** Track all components for vulnerability management, license compliance, and incident response.99100### 7. License Compliance Checking101102Ensure all dependencies have compatible licenses:103104**Automated Tools:**105- Node.js: `npx license-checker --onlyAllow 'MIT;Apache-2.0;BSD-2-Clause;BSD-3-Clause;ISC'`106- Rust: `cargo deny check licenses`107- Python: `pip-licenses`108- Universal: `fossology`, `scancode-toolkit`109110**License Categories:**111- Permissive: MIT, Apache-2.0, BSD (generally safe)112- Weak Copyleft: MPL, LGPL (check linking requirements)113- Strong Copyleft: GPL, AGPL (may require source disclosure)114- Unknown/Missing: Investigate before use115116## Best Practices1171181. **Regular Scanning**: Automate daily/weekly scans1192. **Lock Files**: Use lockfiles for reproducibility1203. **Minimal Dependencies**: Only include what's needed1214. **Verify Sources**: Use trusted registries1225. **Review Updates**: Don't blindly update1236. **License Compliance**: Ensure compatible licenses1247. **SBOM**: Maintain software bill of materials125126## Examples127128### Example 1: Scanning Commands by Ecosystem129130```bash131# JavaScript/Node.js132npm audit133npm audit --json > audit-report.json134npm outdated135npx npm-check-updates136137# Python138pip-audit139safety check140pip list --outdated141pip-compile --generate-hashes142143# Rust144cargo audit145cargo outdated146cargo deny check147148# Go149go list -m all | nancy sleuth150govulncheck ./...151152# Ruby153bundle audit154bundle outdated155156# Java/Maven157mvn dependency-check:check158mvn versions:display-dependency-updates159160# .NET161dotnet list package --vulnerable162dotnet list package --outdated163164# PHP165composer audit166composer outdated167```168169### Example 2: GitHub Actions Dependency Scanning170171```yaml172name: Dependency Scanning173174on:175 push:176 branches: [main]177 pull_request:178 branches: [main]179 schedule:180 - cron: "0 6 * * *" # Daily at 6 AM181182jobs:183 dependency-scan:184 runs-on: ubuntu-latest185186 steps:187 - uses: actions/checkout@v4188189 - name: Run Trivy vulnerability scanner190 uses: aquasecurity/trivy-action@master191 with:192 scan-type: "fs"193 scan-ref: "."194 format: "sarif"195 output: "trivy-results.sarif"196 severity: "CRITICAL,HIGH"197198 - name: Upload Trivy scan results199 uses: github/codeql-action/upload-sarif@v2200 with:201 sarif_file: "trivy-results.sarif"202203 - name: Setup Node.js204 uses: actions/setup-node@v4205 with:206 node-version: "20"207208 - name: Run npm audit209 run: |210 npm ci211 npm audit --audit-level=high212213 - name: Check for outdated packages214 run: npm outdated || true215216 - name: License check217 run: npx license-checker --onlyAllow 'MIT;Apache-2.0;BSD-2-Clause;BSD-3-Clause;ISC'218219 snyk-scan:220 runs-on: ubuntu-latest221 steps:222 - uses: actions/checkout@v4223224 - name: Run Snyk to check for vulnerabilities225 uses: snyk/actions/node@master226 env:227 SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}228 with:229 args: --severity-threshold=high230```231232### Example 3: Dependency Analysis Report Template233234```markdown235# Dependency Security Report236237**Generated:** 2024-01-15238**Project:** my-application239**Total Dependencies:** 245 (42 direct, 203 transitive)240241## Summary242243| Severity | Count | Status |244| -------- | ----- | ------------------ |245| Critical | 2 | Action Required |246| High | 5 | Action Required |247| Medium | 12 | Review Recommended |248| Low | 8 | Monitor |249250## Critical Vulnerabilities251252### CVE-2024-1234 - Remote Code Execution in lodash253254- **Package:** lodash@4.17.20255- **Severity:** Critical (CVSS 9.8)256- **Affected Versions:** < 4.17.21257- **Fixed Version:** 4.17.21258- **Path:** my-app > express > lodash259- **Description:** Prototype pollution vulnerability allowing RCE260- **Remediation:** `npm update lodash`261262### CVE-2024-5678 - SQL Injection in sequelize263264- **Package:** sequelize@6.28.0265- **Severity:** Critical (CVSS 9.1)266- **Affected Versions:** < 6.29.0267- **Fixed Version:** 6.29.0268- **Path:** my-app > sequelize269- **Description:** SQL injection via raw query methods270- **Remediation:** `npm update sequelize`271272## License Compliance273274| License | Count | Compliance |275| ------------ | ----- | -------------------- |276| MIT | 180 | Approved |277| Apache-2.0 | 45 | Approved |278| BSD-3-Clause | 15 | Approved |279| GPL-3.0 | 3 | Review Required |280| Unknown | 2 | Investigation Needed |281282## Recommendations2832841. **Immediate:** Update lodash and sequelize to fix critical vulnerabilities2852. **Short-term:** Review GPL-licensed dependencies for compatibility2863. **Ongoing:** Enable Dependabot/Renovate for automated updates287```288289### Example 4: Renovate Configuration290291```json292{293 "$schema": "https://docs.renovatebot.com/renovate-schema.json",294 "extends": ["config:base", ":semanticCommits", ":preserveSemverRanges"],295 "schedule": ["before 6am on Monday"],296 "vulnerabilityAlerts": {297 "enabled": true,298 "labels": ["security"]299 },300 "packageRules": [301 {302 "matchUpdateTypes": ["major"],303 "labels": ["major-update"],304 "automerge": false305 },306 {307 "matchUpdateTypes": ["minor", "patch"],308 "matchCurrentVersion": "!/^0/",309 "automerge": true,310 "automergeType": "pr",311 "platformAutomerge": true312 },313 {314 "matchPackagePatterns": ["^@types/"],315 "automerge": true,316 "groupName": "type definitions"317 },318 {319 "matchDepTypes": ["devDependencies"],320 "automerge": true,321 "groupName": "dev dependencies"322 }323 ],324 "prConcurrentLimit": 5,325 "prHourlyLimit": 2326}327```