SKILL.md--- 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 ```bash # 취약점 검사 npm audit # 자동 수정 (가능한 경우) npm audit fix # 강제 수정 (major 버전 업데이트 포함) npm audit fix --force # ⚠️ 주의: 호환성 문제 가능 # JSON 출력 (CI용) npm audit --json ``` ### 결과 해석 ``` Severity levels: - critical: 🔴 즉시 수정 필수 - high: 🔴 즉시 수정 필수 - moderate: 🟡 조속히 수정 - low: 🟢 다음 업데이트 시 수정 ``` ### CI 통합 예시 ```yaml # GitHub Actions - name: Security Audit run: | npm audit --audit-level=high if [ $? -ne 0 ]; then echo "Security vulnerabilities found!" exit 1 fi ``` ## Dependency Management ### 의존성 업데이트 확인 ```bash # 오래된 패키지 확인 npm outdated # 업데이트 가능한 패키지 npx npm-check-updates # 대화형 업데이트 npx npm-check-updates -i ``` ### 안전한 업데이트 전략 ```bash # 1. 현재 상태 기록 npm outdated > outdated-$(date +%Y%m%d).txt # 2. patch 버전만 업데이트 (가장 안전) npx npm-check-updates -u --target patch # 3. minor 버전 업데이트 npx npm-check-updates -u --target minor # 4. 테스트 실행 npm test # 5. lockfile 커밋 git add package-lock.json git commit -m "chore: update dependencies (security patch)" ``` ## SBOM (Software Bill of Materials) ### SBOM 생성 ```bash # CycloneDX 형식 (권장) npx @cyclonedx/cyclonedx-npm --output-file sbom.json # SPDX 형식 npx spdx-sbom-generator ``` ### SBOM 포함 정보 ```json { "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 자동 생성 ```yaml # GitHub Actions - 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 보안 ```bash # package-lock.json 항상 커밋 git add package-lock.json # CI에서 정확한 버전 설치 npm ci # (npm install이 아님!) ``` ### .npmrc 보안 설정 ```ini # .npmrc # 스크립트 자동 실행 금지 ignore-scripts=true # 엄격한 SSL strict-ssl=true # 레지스트리 고정 registry=https://registry.npmjs.org/ ``` ### 의심스러운 패키지 확인 ```bash # 패키지 정보 확인 npm info <package-name> # 다운로드 수, 유지보수 상태 확인 npx npm-check <package-name> # 라이선스 확인 npx license-checker ``` ## Detection Patterns ### 위험 신호 ``` 🔴