スキル一覧に戻る
lorenzogirardi

trivy

by lorenzogirardi

0🍴 0📅 2026年1月22日
GitHubで見るManusで実行

SKILL.md


name: trivy description: >- Security vulnerability scanning using Trivy for ecommerce project. Scans dependencies, container images, and IaC. Blocks CRITICAL and HIGH severity. Triggers on "trivy", "vulnerability scan", "security scan", "container scan", "cve", "dependency scan", "npm audit", "docker scan", "security check". PROACTIVE: MUST invoke before committing code with new dependencies. allowed-tools: Read, Write, Edit, Bash, Glob, Grep

ABOUTME: Security vulnerability scanning skill using Trivy

ABOUTME: Enforces CRITICAL/HIGH blocking before commits

Trivy Security Scanning Skill

Quick Reference

Scan TypeCommandWhen
Dependenciestrivy fs .package.json changes
Containertrivy image <name>Dockerfile changes
IaCtrivy config .Terraform changes

When to Scan

TriggerAction
package.json changedScan filesystem
package-lock.json changedScan filesystem
Dockerfile modifiedScan config + image
*.tf files changedScan IaC config
Before commit with depsMANDATORY scan

Scan Commands

Filesystem Scan (Dependencies)

# Most common - scan Node.js dependencies
trivy fs \
    --severity CRITICAL,HIGH \
    --exit-code 1 \
    --ignore-unfixed \
    --format table \
    .

Container Image Scan

# Build image first
docker build -t local-scan:latest .

# Scan the image
trivy image \
    --severity CRITICAL,HIGH \
    --exit-code 1 \
    --ignore-unfixed \
    local-scan:latest

IaC Configuration Scan

# Scan Terraform files
trivy config \
    --severity CRITICAL,HIGH \
    --exit-code 1 \
    infra/terraform/

Severity Policy

SeverityActionCommit Allowed
CRITICALBLOCK - Fix immediatelyNO
HIGHBLOCK - Fix or upgradeNO
MEDIUMWARN - Plan remediationYES
LOWINFO - DocumentYES

Remediation Strategies

Strategy 1: Upgrade Package

# Check which version fixes the CVE
npm audit

# Upgrade specific package
npm install package@latest

# Or use npm audit fix
npm audit fix

Strategy 2: Find Fixed Version

# Show fixed versions in JSON
trivy fs --severity CRITICAL,HIGH --format json . | \
  jq '.Results[].Vulnerabilities[] | {pkg: .PkgName, installed: .InstalledVersion, fixed: .FixedVersion}'

Strategy 3: Override Transitive Dependency

// package.json
{
  "overrides": {
    "vulnerable-package": "^X.Y.Z"
  }
}

Strategy 4: Exclude False Positive

Create .trivyignore:

# CVE-2023-XXXXX: Not exploitable - we don't use affected feature
CVE-2023-XXXXX

WARNING: Every exclusion MUST have documented justification.


Ecommerce-Specific Patterns

Backend Scan

cd apps/backend
trivy fs --severity CRITICAL,HIGH --exit-code 1 .

Frontend Scan

cd apps/frontend
trivy fs --severity CRITICAL,HIGH --exit-code 1 .

Docker Compose Scan

# Build all images
docker-compose -f docker-compose.full.yml build

# Scan each
trivy image ecommerce-demo-backend:latest
trivy image ecommerce-demo-frontend:latest

Terraform Scan

trivy config --severity CRITICAL,HIGH infra/terraform/

CI Integration

The project has Trivy in CI (.github/workflows/backend-ci.yml):

- name: Run Trivy vulnerability scanner
  uses: aquasecurity/trivy-action@master
  with:
    scan-type: 'fs'
    scan-ref: 'apps/backend'
    format: 'json'
    output: 'security/reports/trivy-backend-${{ github.sha }}.json'

Reports saved to security/reports/ for Claude CVE analysis.


CVE Analysis Workflow

When Trivy finds vulnerabilities:

  1. Get the report

    trivy fs --format json --output report.json .
    
  2. Ask Claude to analyze

    Analyze report.json for contextual CVE prioritization.
    For each CVE:
    - Search codebase for usage of affected library
    - Evaluate if attack vector is exposed
    - Provide remediation priority
    
  3. Follow remediation plan


Checklist

Before committing with dependency changes:

  • Trivy installed (brew install trivy)
  • Ran trivy fs --severity CRITICAL,HIGH --exit-code 1 .
  • No CRITICAL vulnerabilities
  • No HIGH vulnerabilities (or documented exception)
  • Any .trivyignore entries justified
  • Container images scanned (if Dockerfile changed)
  • IaC scanned (if Terraform changed)

Troubleshooting

IssueSolution
trivy: command not foundbrew install trivy
Slow scanUse --skip-update after first run
False positiveAdd to .trivyignore with justification
Transitive dependencyUse overrides in package.json
Old DBRun trivy --download-db-only

スコア

総合スコア

40/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です