npm audit, pip-audit) in every CI build, layer Dependabot or Snyk for automated fix PRs, and use Trivy or OSV-Scanner for multi-ecosystem or container scanning.npm audit --audit-level=high (Node.js), pip-audit (Python), trivy fs . (multi-language), osv-scanner --lockfile=package-lock.json (OSV database)| # | Tool | Ecosystem | Free Tier | CI Integration | Auto-Fix PRs | Vuln Database | Key Differentiator |
|---|---|---|---|---|---|---|---|
| 1 | npm audit | Node.js | Built-in | npm audit --audit-level=high | npm audit fix | npm Advisory DB (GitHub) | Zero setup, ships with npm 6+ |
| 2 | pip-audit | Python | Free/OSS | pip-audit --strict --fix | --fix flag | OSV (PyPA Advisory DB) | Official PyPA tool, resolves full tree |
| 3 | Snyk Open Source | 13+ languages | Free (100 tests/mo) | CLI, GitHub App, IDE | Auto PR + Snyk patches | Snyk Intel DB (3x NVD) | Reachability analysis, priority score 0-1000 |
| 4 | GitHub Dependabot | All GitHub ecosystems | Free on GitHub | Built-in to GitHub | Auto security PRs | GitHub Advisory DB (GHSA) | Zero config on GitHub repos, auto-triage rules |
| 5 | Trivy | OS + 10+ app ecosystems | Free/OSS | trivy fs . or trivy image | No (detection only) | NVD, GHSA, OSV, vendor DBs | Scans containers, filesystems, IaC, SBOM, secrets |
| 6 | OWASP Dependency-Check | Java, .NET, Ruby, Python | Free/OSS | Maven/Gradle plugin, CLI | No (detection only) | NVD (requires API key) | CPE-based matching, HTML/JSON reports, CRA compliance |
| 7 | OSV-Scanner | All OSV ecosystems | Free/OSS | osv-scanner --lockfile= | Guided remediation (v2) | OSV.dev (38k+ advisories) | Google-backed, aggregates 16 ecosystem DBs |
| 8 | cargo audit | Rust | Free/OSS | cargo audit in CI | cargo audit fix (nightly) | RustSec Advisory DB | Native Rust tooling, checks unmaintained crates |
| 9 | govulncheck | Go | Free/OSS | govulncheck ./... | No | Go Vulnerability DB | Official Go tool, call-graph reachability analysis |
| 10 | Grype | Multi-language | Free/OSS | grype dir:. or grype image | No (detection only) | NVD, GHSA, vendor feeds | Pairs with Syft SBOM generator, fast image scanning |
START: What is your primary ecosystem?
├── Node.js/npm?
│ ├── YES → Use npm audit in CI + Dependabot for auto-fix PRs
│ └── NO ↓
├── Python/pip?
│ ├── YES → Use pip-audit in CI + Dependabot or Snyk for auto-fix PRs
│ └── NO ↓
├── Java/Maven/Gradle?
│ ├── YES → Use OWASP Dependency-Check or Snyk + Dependabot
│ └── NO ↓
├── Go?
│ ├── YES → Use govulncheck (reachability-aware) + Dependabot
│ └── NO ↓
├── Rust?
│ ├── YES → Use cargo audit + Dependabot
│ └── NO ↓
├── Multi-language or container images?
│ ├── YES → Use Trivy or OSV-Scanner for unified scanning
│ └── NO ↓
└── DEFAULT → Start with OSV-Scanner + Dependabot
Need auto-fix PRs?
├── GitHub repo → Enable Dependabot security updates (free)
├── Any platform → Snyk (free tier: 100 tests/month)
└── Self-hosted → Renovate Bot (open source)
Start with the built-in audit command for your ecosystem. These require zero additional setup and catch the majority of known vulnerabilities. [src1]
# Node.js: Fail CI on high/critical vulnerabilities
npm audit --audit-level=high --omit=dev
# Python: Audit current environment
pip install pip-audit
pip-audit --strict
Verify: npm audit exits with code 0 (clean) or non-zero (vulnerabilities found).
Dependabot monitors your dependency graph and creates pull requests to upgrade vulnerable packages. [src4]
# .github/dependabot.yml
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
Verify: Check the Security tab > Dependabot alerts after enabling.
Trivy scans filesystems, container images, and IaC configs in a single tool. [src5]
# Scan project filesystem
trivy fs --severity HIGH,CRITICAL .
# Scan container image
trivy image --severity HIGH,CRITICAL myapp:latest
# Generate SBOM
trivy fs --format cyclonedx --output sbom.cdx.json .
Verify: trivy fs . outputs a vulnerability table grouped by severity.
Create a workflow that runs vulnerability scanning on every push and pull request. [src1] [src5]
# .github/workflows/security-scan.yml
name: Dependency Security Scan
on:
push:
branches: [main]
pull_request:
schedule:
- cron: '0 6 * * 1'
jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '20' }
- run: npm ci
- run: npm audit --audit-level=high --omit=dev
- uses: aquasecurity/[email protected]
with:
scan-type: fs
severity: HIGH,CRITICAL
exit-code: '1'
Verify: Push a commit -- the Actions tab should show scanning jobs. HIGH/CRITICAL findings fail the build.
Snyk provides the deepest vulnerability intelligence with reachability analysis. [src3]
# Install and authenticate
npm install -g snyk && snyk auth
# Test project for vulnerabilities
snyk test --severity-threshold=high
# Monitor continuously
snyk monitor
Verify: snyk test outputs a vulnerability report with priority scores.
Produce a Software Bill of Materials alongside vulnerability scanning for supply chain transparency. [src5] [src7]
# Generate SBOM with Trivy (CycloneDX format)
trivy fs --format cyclonedx --output sbom.cdx.json .
# Scan SBOM for vulnerabilities with Grype
grype sbom:sbom.cdx.json --fail-on high
# Scan SBOM with OSV-Scanner
osv-scanner --sbom=sbom.cdx.json
Verify: sbom.cdx.json contains a components array listing all dependencies with versions.
# .github/workflows/dependency-scan.yml
# Input: Push/PR to main branch, or weekly schedule
# Output: Build fails on HIGH/CRITICAL vulnerabilities
name: Dependency Vulnerability Scan
on:
push:
branches: [main]
pull_request:
schedule:
- cron: '0 6 * * 1'
jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '20' }
- run: npm ci
- run: npm audit --audit-level=high --omit=dev
- uses: aquasecurity/[email protected]
with:
scan-type: fs
severity: HIGH,CRITICAL
exit-code: '1'
const { execSync } = require('child_process');
function auditDependencies() {
try {
const out = execSync('npm audit --json --omit=dev',
{ encoding: 'utf-8', maxBuffer: 10*1024*1024 });
const report = JSON.parse(out);
return report.metadata.vulnerabilities;
} catch (err) {
return JSON.parse(err.stdout).metadata.vulnerabilities;
}
}
import subprocess, json, sys
def audit_python_deps():
result = subprocess.run(
["pip-audit", "--format=json", "--strict"],
capture_output=True, text=True)
if result.returncode == 0:
return []
vulns = json.loads(result.stdout)
for v in vulns:
print(f" {v['name']}=={v['version']}: {v['id']}")
return vulns
if __name__ == "__main__":
sys.exit(1 if audit_python_deps() else 0)
#!/usr/bin/env bash
set -euo pipefail
SEVERITY="HIGH,CRITICAL"
echo "=== Scanning filesystem ==="
trivy fs --severity "$SEVERITY" --exit-code 1 .
echo "=== Generating SBOM ==="
trivy fs --format cyclonedx --output sbom.cdx.json .
if [ -f Dockerfile ]; then
echo "=== Scanning container image ==="
IMAGE="$(basename "$(pwd)"):scan"
docker build -t "$IMAGE" .
trivy image --severity "$SEVERITY" --exit-code 1 "$IMAGE"
fi
// BAD -- checking only top-level packages, missing transitive vulnerabilities
{ "scripts": { "security": "npm ls --depth=0 | grep -i vulnerable" } }
// Misses 80%+ of vulnerability surface area
// GOOD -- npm audit resolves the full transitive tree automatically
{ "scripts": { "security": "npm audit --audit-level=high --omit=dev" } }
# BAD -- suppressing all audit output to avoid CI failures
npm audit || true
# GOOD -- ignore specific CVEs with justification
pip-audit --ignore-vuln PYSEC-2024-XXXXX
# Always document WHY the exception is safe
# BAD -- vulnerabilities enter through unscanned PRs
on:
push:
branches: [main]
# GOOD -- catch vulnerabilities before merge + new disclosures
on:
push:
branches: [main]
pull_request:
schedule:
- cron: '0 6 * * 1'
# BAD -- CVSS 9.8 in unreachable dep wastes time
npm audit --audit-level=critical
# GOOD -- Snyk provides reachability + priority scoring
snyk test --severity-threshold=high
# GOOD -- govulncheck only reports vulns in called functions
govulncheck ./...
npm audit without npm ci first may scan an outdated dependency tree. Fix: Always run npm ci before auditing in CI. [src1]NVD_API_KEY. [src6]--force flag upgrades to major versions, introducing breaking changes. Fix: Use npm audit fix (without force) first, manually review remaining issues. [src1]suppressions.xml to suppress confirmed false positives. [src6]pip-audit -r requirements.txt and trivy fs . for broader coverage. [src2]open-pull-requests-limit. [src4]trivy fs . for app deps only, trivy image for full container analysis. [src5]trivy fs --format cyclonedx) and store as build artifact. [src7]# Check npm for known vulnerabilities (Node.js)
npm audit --json | jq '.metadata.vulnerabilities'
# List all vulnerable Python packages
pip-audit --format=json | jq '.[] | "\(.name)==\(.version): \(.id)"'
# Scan filesystem with Trivy (all severities)
trivy fs --severity HIGH,CRITICAL .
# Scan container image
trivy image --severity HIGH,CRITICAL myapp:latest
# Scan with OSV-Scanner
osv-scanner --lockfile=package-lock.json
# Check Go project for reachable vulnerabilities
govulncheck ./...
# Scan Rust project
cargo audit
# Generate SBOM in CycloneDX format
trivy fs --format cyclonedx --output sbom.cdx.json .
# OWASP Dependency-Check CLI scan (Java)
dependency-check --project myapp --scan ./lib --format HTML --nvdApiKey $NVD_API_KEY
| Tool | Current Version | Status | Key Changes |
|---|---|---|---|
| npm audit | npm 10.x | Current | Signature verification, --omit=dev flag |
| npm audit | npm 9.x | Supported | Added npm audit signatures validation |
| pip-audit | 2.x | Current | OSV backend, --fix flag, multiple output formats |
| Snyk CLI | 1.x | Current | Reachability analysis, priority scoring |
| Dependabot | v2 | Current | Auto-triage rules, grouped updates |
| Trivy | 0.58.x | Current | SBOM scanning, guided remediation, VEX support |
| OWASP Dep-Check | 11.x | Current | Requires NVD API key, CRA alignment |
| OSV-Scanner | 2.x | Current | Guided remediation, call-graph analysis |
| govulncheck | 1.x | Current | Call-graph reachability, stdlib coverage |
| cargo audit | 0.21.x | Current | Binary scanning, cargo audit fix (nightly) |
| Use When | Don't Use When | Use Instead |
|---|---|---|
| Any project with third-party dependencies | Project has zero external dependencies | No scanning needed |
| CI/CD pipeline should block vulnerable builds | You only want informational alerts | Enable Dependabot alerts only |
| Need multi-ecosystem scanning in one tool | Only using one language ecosystem | Native audit tool is simpler |
| Need reachability analysis to reduce noise | Budget is zero and noise tolerance is high | Free tools (npm audit, OSV-Scanner, Trivy) |
| Compliance requires SBOM generation | Internal-only prototype with no compliance needs | Basic audit commands suffice |
| Container images need full OS + app scanning | Only scanning application code | trivy fs or native audit tools |
npm audit fix --force and Dependabot major version PRs can introduce breaking changes -- never auto-merge without a passing test suite.