| name | dependency-security |
| description | Enforce dependency security scanning and SBOM generation. Use when adding dependencies, reviewing package.json, or during security audits. Covers OWASP dependency check, npm audit, and supply chain security. |
| allowed-tools | Read, Glob, Grep, Edit, Write, Bash |
| license | MIT |
| metadata | {"author":"antigravity-team","version":"1.0"} |
Dependency Security
์์กด์ฑ ๋ณด์ ์ค์บ ๋ฐ SBOM(Software Bill of Materials) ์์ฑ์ ๊ฐ์ ํ๋ ์คํฌ์
๋๋ค.
2025 Context
OWASP Top 10 2025์์ "Vulnerable and Outdated Components"๊ฐ A03์ผ๋ก ์์น
EU Cyber Resilience Act: 2024๋
๋ถํฐ SBOM ์๋ฌดํ ์์
Supply Chain ๊ณต๊ฒฉ ๊ธ์ฆ: 2024๋
๋๋น 300% ์ฆ๊ฐ
Core Rules
| ๊ท์น | ์ํ | ์ค๋ช
|
|---|
| npm audit ํต๊ณผ | ๐ด ํ์ | high/critical ์ทจ์ฝ์ 0๊ฐ |
| ์์กด์ฑ ์ต์ ํ | ๐ก ๊ถ์ฅ | ์ฃผ์ ๋ณด์ ํจ์น ์ ์ฉ |
| SBOM ์์ฑ | ๐ก ๊ถ์ฅ | ์์กด์ฑ ๋ชฉ๋ก ๋ฌธ์ํ |
| lockfile ์ปค๋ฐ | ๐ด ํ์ | ์ฌํ ๊ฐ๋ฅํ ๋น๋ |
Security Audit
npm audit
npm audit
npm audit fix
npm audit fix --force
npm audit --json
๊ฒฐ๊ณผ ํด์
Severity levels:
- critical: ๐ด ์ฆ์ ์์ ํ์
- high: ๐ด ์ฆ์ ์์ ํ์
- moderate: ๐ก ์กฐ์ํ ์์
- low: ๐ข ๋ค์ ์
๋ฐ์ดํธ ์ ์์
CI ํตํฉ ์์
- name: Security Audit
run: |
npm audit --audit-level=high
if [ $? -ne 0 ]; then
echo "Security vulnerabilities found!"
exit 1
fi
Dependency Management
์์กด์ฑ ์
๋ฐ์ดํธ ํ์ธ
npm outdated
npx npm-check-updates
npx npm-check-updates -i
์์ ํ ์
๋ฐ์ดํธ ์ ๋ต
npm outdated > outdated-$(date +%Y%m%d).txt
npx npm-check-updates -u --target patch
npx npm-check-updates -u --target minor
npm test
git add package-lock.json
git commit -m "chore: update dependencies (security patch)"
SBOM (Software Bill of Materials)
SBOM ์์ฑ
npx @cyclonedx/cyclonedx-npm --output-file sbom.json
npx spdx-sbom-generator
SBOM ํฌํจ ์ ๋ณด
{
"bomFormat": "CycloneDX",
"specVersion": "1.4",
"components": [
{
"name": "react",
"version": "18.2.0",
"purl": "pkg:npm/react@18.2.0",
"licenses": [{ "license": { "id": "MIT" } }]
}
]
}
CI์์ SBOM ์๋ ์์ฑ
- name: Generate SBOM
run: npx @cyclonedx/cyclonedx-npm --output-file sbom.json
- name: Upload SBOM
uses: actions/upload-artifact@v3
with:
name: sbom
path: sbom.json
Supply Chain Security
Lockfile ๋ณด์
git add package-lock.json
npm ci
.npmrc ๋ณด์ ์ค์
ignore-scripts=true
strict-ssl=true
registry=https://registry.npmjs.org/
์์ฌ์ค๋ฌ์ด ํจํค์ง ํ์ธ
npm info <package-name>
npx npm-check <package-name>
npx license-checker
Detection Patterns
์ํ ์ ํธ
๐ด ์ํ:
- critical/high ์ทจ์ฝ์ ์กด์ฌ
- 1๋
์ด์ ์
๋ฐ์ดํธ ์๋ ์์กด์ฑ
- deprecated ํจํค์ง ์ฌ์ฉ
- ์ ์ ์๋ ์ถ์ฒ์ ํจํค์ง
๐ก ์ฃผ์:
- moderate ์ทจ์ฝ์
- 6๊ฐ์ ์ด์ ์
๋ฐ์ดํธ ์์
- ๋ฎ์ ๋ค์ด๋ก๋ ์
๊ฒ์ฌ ๋ช
๋ น์ด
npm ls 2>&1 | grep -i deprecated
npx license-checker --failOn "GPL;AGPL"
npm ls --depth=0
Workflow
1. ์ ์์กด์ฑ ์ถ๊ฐ ์
์ถ๊ฐ ์ ์ฒดํฌ:
1. npm info๋ก ํจํค์ง ์ ๋ณด ํ์ธ
2. ๋ค์ด๋ก๋ ์ ๋ฐ ์ ์ง๋ณด์ ์ํ ํ์ธ
3. ๋ผ์ด์ ์ค ํธํ์ฑ ํ์ธ
4. ๋์ ํจํค์ง ๊ฒํ
์ถ๊ฐ ํ:
1. npm audit ์คํ
2. lockfile ์ปค๋ฐ
2. ์ ๊ธฐ ๋ณด์ ์ ๊ฒ (์ฃผ๊ฐ/์๊ฐ)
npm audit
npm outdated
npx @cyclonedx/cyclonedx-npm --output-file sbom.json
3. CI/CD ํ์ดํ๋ผ์ธ
name: Security Check
on: [push, pull_request]
jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: npm ci
- name: Security audit
run: npm audit --audit-level=high
- name: Check outdated
run: npm outdated || true
- name: Generate SBOM
run: npx @cyclonedx/cyclonedx-npm --output-file sbom.json
๋๊ตฌ ์ถ์ฒ
| ๋๊ตฌ | ์ฉ๋ | ๋ช
๋ น์ด |
|---|
| npm audit | ์ทจ์ฝ์ ์ค์บ | npm audit |
| Snyk | ๊ณ ๊ธ ์ทจ์ฝ์ ๋ถ์ | npx snyk test |
| OWASP Dependency-Check | OWASP ํ์ค ์ค์บ | CLI ๋๊ตฌ |
| CycloneDX | SBOM ์์ฑ | npx @cyclonedx/cyclonedx-npm |
| npm-check-updates | ์์กด์ฑ ์
๋ฐ์ดํธ | npx ncu |
Checklist
์ ํ๋ก์ ํธ
์์กด์ฑ ์ถ๊ฐ ์
์ ๊ธฐ ์ ๊ฒ
References