| name | dependency-scanning |
| description | Scan package dependencies for known vulnerabilities using Snyk, Dependabot, and OWASP Dependency-Check. Identify and remediate vulnerable libraries in your software supply chain. Use when managing third-party dependencies or implementing software composition analysis. |
| license | MIT |
| metadata | {"author":"devops-skills","version":"1.0"} |
Dependency Scanning
Identify vulnerabilities in third-party dependencies and libraries.
When to Use This Skill
Use this skill when:
- Managing third-party dependencies
- Implementing software composition analysis
- Meeting compliance requirements
- Securing the software supply chain
- Automating vulnerability detection
Prerequisites
- Package manifest files (package.json, requirements.txt, etc.)
- CI/CD pipeline access
- Dependency scanning tool
Tool Comparison
| Tool | Type | Languages | Best For |
|---|
| Snyk | Commercial/Free | Many | Comprehensive SCA |
| Dependabot | Free (GitHub) | Many | Automated PRs |
| OWASP Dep-Check | OSS | Many | Free scanning |
| npm audit | Built-in | Node.js | Quick checks |
| pip-audit | OSS | Python | Python projects |
| Trivy | OSS | Many | Container deps |
Snyk
CLI Usage
npm install -g snyk
snyk auth
snyk test
snyk monitor
snyk test --file=package.json
snyk test --file=requirements.txt
snyk test --json > snyk-results.json
snyk test --sarif > snyk-results.sarif
snyk fix
snyk ignore --id=SNYK-JS-LODASH-567746 --expiry=2024-12-31 --reason="No exploit path"
CI Integration
name: Snyk Security
on:
push:
branches: [main]
pull_request:
jobs:
snyk:
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
- name: Upload results to GitHub
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: snyk.sarif
Policy File
version: v1.25.0
ignore:
SNYK-JS-LODASH-567746:
- '*':
reason: No user input reaches this function
expires: 2024-12-31
created: 2024-01-15
'snyk:lic:npm:gpl-3.0':
- '*':
reason: Internal use only
patch: {}
GitHub Dependabot
Configuration
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
open-pull-requests-limit: 10
reviewers:
- "security-team"
labels:
- "dependencies"
- "security"
ignore:
- dependency-name: "aws-sdk"
update-types: ["version-update:semver-major"]
groups:
development-dependencies:
dependency-type: "development"
update-types:
- "minor"
- "patch"
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
Security Alerts
OWASP Dependency-Check
Installation
wget https://github.com/jeremylong/DependencyCheck/releases/download/v9.0.0/dependency-check-9.0.0-release.zip
unzip dependency-check-9.0.0-release.zip
brew install dependency-check
Usage
dependency-check --project "MyProject" \
--scan /path/to/project \
--out /path/to/reports \
--format HTML \
--format JSON
dependency-check --project "MyProject" \
--scan . \
--enableExperimental \
--disableRetireJS
dependency-check --project "MyProject" \
--scan . \
--format JSON \
--failOnCVSS 7 \
--suppression suppression.xml
Suppression File
<?xml version="1.0" encoding="UTF-8"?>
<suppressions xmlns="https://jeremylong.github.io/DependencyCheck/dependency-suppression.1.3.xsd">
<suppress>
<notes>False positive - not using vulnerable function</notes>
<packageUrl regex="true">^pkg:npm/lodash@.*$</packageUrl>
<cve>CVE-2021-23337</cve>
</suppress>
<suppress until="2024-12-31">
<notes>Risk accepted - mitigated by WAF</notes>
<cpe>cpe:/a:apache:struts:2.5.0</cpe>
<vulnerabilityName>CVE-2023-12345</vulnerabilityName>
</suppress>
</suppressions>
Maven Integration
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>9.0.0</version>
<configuration>
<failBuildOnCVSS>7</failBuildOnCVSS>
<suppressionFiles>
<suppressionFile>suppression.xml</suppressionFile>
</suppressionFiles>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
Language-Specific Tools
Node.js (npm audit)
npm audit
npm audit --json
npm audit fix
npm audit fix --force
npm audit --production
Python (pip-audit)
pip install pip-audit
pip-audit
pip-audit -r requirements.txt
pip-audit --format json
pip-audit --format cyclonedx-json
pip-audit --fix
Go (govulncheck)
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...
govulncheck -json ./...
Ruby (bundler-audit)
gem install bundler-audit
bundle-audit update
bundle-audit check
bundle-audit check --format json
SBOM Generation
CycloneDX
npx @cyclonedx/cyclonedx-npm --output-file sbom.json
pip install cyclonedx-bom
cyclonedx-py -o sbom.json
go install github.com/CycloneDX/cyclonedx-gomod/cmd/cyclonedx-gomod@latest
cyclonedx-gomod mod -json > sbom.json
Syft
curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s
syft dir:/path/to/project -o cyclonedx-json > sbom.json
syft dir:/path/to/project -o spdx-json > sbom-spdx.json
syft myimage:latest -o cyclonedx-json > sbom.json
CI/CD Pipeline
name: Dependency Security
on:
push:
branches: [main]
pull_request:
schedule:
- cron: '0 8 * * *'
jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: npm audit
run: npm audit --audit-level=high
- name: Snyk scan
uses: snyk/actions/node@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --severity-threshold=high
- name: Generate SBOM
run: npx @cyclonedx/cyclonedx-npm --output-file sbom.json
- name: Upload SBOM
uses: actions/upload-artifact@v4
with:
name: sbom
path: sbom.json
Common Issues
Issue: Too Many Alerts
Problem: Overwhelmed by vulnerability count
Solution: Prioritize by exploitability, filter by severity
Issue: No Fix Available
Problem: Vulnerable dependency has no patch
Solution: Consider alternatives, implement compensating controls
Issue: Breaking Updates
Problem: Security fix breaks functionality
Solution: Review changelogs, test thoroughly, use lockfiles
Best Practices
- Scan on every build
- Use lockfiles for reproducibility
- Set severity thresholds
- Generate and track SBOMs
- Document exceptions properly
- Update dependencies regularly
- Monitor for new vulnerabilities
- Automate PR creation for updates
Related Skills