Sca Trivy 标志

Sca Trivy

组织
AgentSecOps
sca-trivy

使用 Aqua Trivy 进行软件成分分析(SCA)和容器漏洞扫描,识别依赖项、容器镜像和 IaC 配置错误中的 CVE 漏洞,以及许可证合规风险。适用于:(1)扫描容器镜像和文件系统中的漏洞及配置错误;(2)分析多种语言(Go、Python、Node.js、Java 等)的依赖项,查找已知 CVE;(3)检测 Terraform、Kubernetes 和 Dockerfile 中的 IaC 安全问题;(4)在 CI/CD 流水线中集成漏洞扫描并输出 SARIF;(5)以 CycloneDX 或 SPDX 格式生成软件物料清单(SBOM);(6)根据 CVSS 评分和可利用性确定修复优先级。

Add to TypingMind

概览

发布者AgentSecOps
代码仓库SecOpsAgentKit
技能名称sca-trivy
星标数
225
复刻数
44
附带文件
仅含指令
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 指令自成一体

    模型所需的一切都包含在指令中,无需同步额外文件。

  • 开源

    由 AgentSecOps 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Sca Trivy AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/AgentSecOps/SecOpsAgentKit/tree/main/skills/devsecops/sca-trivy
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/AgentSecOps/SecOpsAgentKit.git /tmp/SecOpsAgentKit
mkdir -p .claude/skills
cp -r /tmp/SecOpsAgentKit/skills/devsecops/sca-trivy .claude/skills/sca-trivy
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Sca Trivy,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Sca Trivy。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Sca Trivy 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Software Composition Analysis with Trivy

Overview

Trivy is a comprehensive security scanner for containers, filesystems, and git repositories. It detects vulnerabilities (CVEs) in OS packages and application dependencies, IaC misconfigurations, exposed secrets, and software licenses. This skill provides workflows for vulnerability scanning, SBOM generation, CI/CD integration, and remediation prioritization aligned with CVSS and OWASP standards.

Quick Start

Scan a container image for vulnerabilities:

bash
# Install Trivy
brew install trivy  # macOS
# or: apt-get install trivy  # Debian/Ubuntu
# or: docker pull aquasec/trivy:latest

# Scan container image
trivy image nginx:latest

# Scan local filesystem for dependencies
trivy fs .

# Scan IaC files for misconfigurations
trivy config .

# Generate SBOM
trivy image --format cyclonedx --output sbom.json nginx:latest

Core Workflows

Workflow 1: Container Image Security Assessment

Progress: [ ] 1. Identify target container image (repository:tag) [ ] 2. Run comprehensive Trivy scan with trivy image <image-name> [ ] 3. Analyze vulnerability findings by severity (CRITICAL, HIGH, MEDIUM, LOW) [ ] 4. Map CVE findings to CWE categories and OWASP references [ ] 5. Check for available patches and updated base images [ ] 6. Generate prioritized remediation report with upgrade recommendations

Work through each step systematically. Check off completed items.

Workflow 2: Dependency Vulnerability Scanning

Scan project dependencies for known vulnerabilities:

bash
# Scan filesystem for all dependencies
trivy fs --severity CRITICAL,HIGH .

# Scan specific package manifest
trivy fs --scanners vuln package-lock.json

# Generate JSON report for analysis
trivy fs --format json --output trivy-report.json .

# Generate SARIF for GitHub/GitLab integration
trivy fs --format sarif --output trivy.sarif .

For each vulnerability:

  1. Review CVE details and CVSS score
  2. Check if fixed version is available
  3. Consult references/remediation_guide.md for language-specific guidance
  4. Update dependency to patched version
  5. Re-scan to validate fix

Workflow 3: Infrastructure as Code Security

Detect misconfigurations in IaC files:

bash
# Scan Terraform configurations
trivy config ./terraform --severity CRITICAL,HIGH

# Scan Kubernetes manifests
trivy config ./k8s --severity CRITICAL,HIGH

# Scan Dockerfile best practices
trivy config --file-patterns dockerfile:Dockerfile .

# Generate report with remediation guidance
trivy config --format json --output iac-findings.json .

Review findings by category:

  • Security: Authentication, authorization, encryption
  • Compliance: CIS benchmarks, security standards
  • Best Practices: Resource limits, immutability, least privilege

Workflow 4: CI/CD Pipeline Integration

GitHub Actions
yaml
name: Trivy Security Scan
on: [push, pull_request]

jobs:
  scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Run Trivy vulnerability scanner
        uses: aquasecurity/trivy-action@master
        with:
          scan-type: 'fs'
          scan-ref: '.'
          format: 'sarif'
          output: 'trivy-results.sarif'
          severity: 'CRITICAL,HIGH'

      - name: Upload results to GitHub Security
        uses: github/codeql-action/upload-sarif@v2
        with:
          sarif_file: 'trivy-results.sarif'
GitLab CI
yaml
trivy-scan:
  stage: test
  image: aquasec/trivy:latest
  script:
    - trivy fs --exit-code 1 --severity CRITICAL,HIGH --format json --output trivy-report.json .
  artifacts:
    reports:
      dependency_scanning: trivy-report.json
    when: always
  allow_failure: false

Use bundled templates from assets/ci_integration/ for additional platforms.

Workflow 5: SBOM Generation

Generate Software Bill of Materials for supply chain transparency:

bash
# Generate CycloneDX SBOM
trivy image --format cyclonedx --output sbom-cyclonedx.json nginx:latest

# Generate SPDX SBOM
trivy image --format spdx-json --output sbom-spdx.json nginx:latest

# SBOM for filesystem/project
trivy fs --format cyclonedx --output project-sbom.json .

SBOM use cases:

  • Vulnerability tracking: Monitor dependencies for new CVEs
  • License compliance: Identify license obligations and risks
  • Supply chain security: Verify component provenance
  • Regulatory compliance: Meet CISA SBOM requirements

Security Considerations

Sensitive Data Handling

  • Registry credentials: Use environment variables or credential helpers, never hardcode
  • Scan reports: Contain vulnerability details and package versions - treat as sensitive
  • SBOM files: May reveal internal architecture - control access appropriately
  • Secret scanning: Enable with --scanners secret to detect exposed credentials in images

Access Control

  • Container registry access: Requires pull permissions for image scanning
  • Filesystem access: Read permissions for dependency manifests and IaC files
  • CI/CD integration: Secure API tokens and registry credentials in secrets management
  • Report storage: Restrict access to vulnerability reports and SBOM artifacts

Audit Logging

Log the following for compliance and incident response:

  • Scan execution timestamps and scope (image, filesystem, repository)
  • Vulnerability counts by severity level
  • Policy violations and blocking decisions
  • SBOM generation and distribution events
  • Remediation actions and version updates

Compliance Requirements

  • PCI-DSS 6.2: Ensure system components protected from known vulnerabilities
  • SOC2 CC7.1: Detect and act upon changes that could affect security
  • NIST 800-53 SI-2: Flaw remediation and vulnerability scanning
  • CIS Benchmarks: Container and Kubernetes security hardening
  • OWASP Top 10 A06: Vulnerable and Outdated Components
  • CWE-1104: Use of Unmaintained Third-Party Components

Bundled Resources

Scripts (scripts/)

  • trivy_scan.py - Comprehensive scanning with JSON/SARIF output and severity filtering
  • sbom_generator.py - SBOM generation with CycloneDX and SPDX format support
  • vulnerability_report.py - Parse Trivy output and generate remediation reports with CVSS scores
  • baseline_manager.py - Baseline creation for tracking new vulnerabilities only

References (references/)

  • scanner_types.md - Detailed guide for vulnerability, misconfiguration, secret, and license scanning
  • remediation_guide.md - Language and ecosystem-specific remediation strategies
  • cvss_prioritization.md - CVSS score interpretation and vulnerability prioritization framework
  • iac_checks.md - Complete list of IaC security checks with CIS benchmark mappings

Assets (assets/)

  • trivy.yaml - Custom Trivy configuration with security policies and ignore rules
  • ci_integration/github-actions.yml - Complete GitHub Actions workflow with security gates
  • ci_integration/gitlab-ci.yml - Complete GitLab CI pipeline with dependency scanning
  • ci_integration/jenkins.groovy - Jenkins pipeline with Trivy integration
  • policy_template.rego - OPA policy template for custom vulnerability policies

Common Patterns

Pattern 1: Multi-Stage Security Scanning

Comprehensive security assessment combining multiple scan types:

bash
# 1. Scan container image for vulnerabilities
trivy image --severity CRITICAL,HIGH myapp:latest

# 2. Scan IaC for misconfigurations
trivy config ./infrastructure --severity CRITICAL,HIGH

# 3. Scan filesystem for dependency vulnerabilities
trivy fs --severity CRITICAL,HIGH ./app

# 4. Scan for exposed secrets
trivy fs --scanners secret ./app

# 5. Generate comprehensive SBOM
trivy image --format cyclonedx --output sbom.json myapp:latest

Pattern 2: Baseline Vulnerability Tracking

Implement baseline scanning to track only new vulnerabilities:

bash
# Initial scan - create baseline
trivy image --format json --output baseline.json nginx:latest

# Subsequent scans - detect new vulnerabilities
trivy image --format json --output current.json nginx:latest
./scripts/baseline_manager.py --baseline baseline.json --current current.json

Pattern 3: License Compliance Scanning

Detect license compliance risks:

bash
# Scan for license information
trivy image --scanners license --format json --output licenses.json myapp:latest

# Filter by license type
trivy image --scanners license --severity HIGH,CRITICAL myapp:latest

Review findings:

  • High Risk: GPL, AGPL (strong copyleft)
  • Medium Risk: LGPL, MPL (weak copyleft)
  • Low Risk: Apache, MIT, BSD (permissive)

Pattern 4: Custom Policy Enforcement

Apply custom security policies with OPA:

bash
# Create Rego policy in assets/policy_template.rego
# Deny images with CRITICAL vulnerabilities or outdated packages

# Run scan with policy enforcement
trivy image --format json --output scan.json myapp:latest
trivy image --ignore-policy assets/policy_template.rego myapp:latest

Integration Points

CI/CD Integration

  • GitHub Actions: Native aquasecurity/trivy-action with SARIF upload to Security tab
  • GitLab CI: Dependency scanning report format for Security Dashboard
  • Jenkins: Docker-based scanning with JUnit XML report generation
  • CircleCI: Docker executor with artifact storage
  • Azure Pipelines: Task-based integration with results publishing

Container Platforms

  • Docker: Image scanning before push to registry
  • Kubernetes: Admission controllers with trivy-operator for runtime scanning
  • Harbor: Built-in Trivy integration for registry scanning
  • AWS ECR: Scan images on push with enhanced scanning
  • Google Artifact Registry: Vulnerability scanning integration

Security Tools Ecosystem

  • SIEM Integration: Export JSON findings to Splunk, ELK, or Datadog
  • Vulnerability Management: Import SARIF/JSON into Snyk, Qualys, or Rapid7
  • SBOM Tools: CycloneDX and SPDX compatibility with dependency-track and GUAC
  • Policy Enforcement: OPA/Rego integration for custom policy as code

Troubleshooting

Issue: High False Positive Rate

Symptoms: Many vulnerabilities reported that don't apply to your use case

Solution:

  1. Use .trivyignore file to suppress specific CVEs with justification
  2. Filter by exploitability: trivy image --ignore-unfixed myapp:latest
  3. Apply severity filtering: --severity CRITICAL,HIGH
  4. Review vendor-specific security advisories for false positive validation
  5. See references/false_positives.md for common patterns

Issue: Performance Issues on Large Images

Symptoms: Scans taking excessive time or high memory usage

Solution:

  1. Use cached DB: trivy image --cache-dir /path/to/cache myapp:latest
  2. Skip unnecessary scanners: --scanners vuln (exclude config, secret)
  3. Use offline mode after initial DB download: --offline-scan
  4. Increase timeout: --timeout 30m
  5. Scan specific layers: --removed-pkgs to exclude removed packages

Issue: Missing Vulnerabilities for Specific Languages

Symptoms: Expected CVEs not detected in application dependencies

Solution:

  1. Verify language support: Check supported languages and file patterns
  2. Ensure dependency manifests are present (package.json, go.mod, requirements.txt)
  3. Include lock files for accurate version detection
  4. For compiled binaries, scan source code separately
  5. Consult references/scanner_types.md for language-specific requirements

Issue: Registry Authentication Failures

Symptoms: Unable to scan private container images

Solution:

bash
# Use Docker credential helper
docker login registry.example.com
trivy image registry.example.com/private/image:tag

# Or use environment variables
export TRIVY_USERNAME=user
export TRIVY_PASSWORD=pass
trivy image registry.example.com/private/image:tag

# Or use credential file
trivy image --username user --password pass registry.example.com/private/image:tag

Advanced Configuration

Custom Trivy Configuration

Create trivy.yaml configuration file:

yaml
# trivy.yaml
vulnerability:
  type: os,library
severity: CRITICAL,HIGH,MEDIUM
ignorefile: .trivyignore
ignore-unfixed: false
skip-files:
  - "test/**"
  - "**/node_modules/**"

cache:
  dir: /tmp/trivy-cache

db:
  repository: ghcr.io/aquasecurity/trivy-db:latest

output:
  format: json
  severity-sort: true

Use with: trivy image --config trivy.yaml myapp:latest

Trivy Ignore File

Create .trivyignore to suppress specific CVEs:

# .trivyignore
# False positive - patched in vendor fork
CVE-0000-12345

# Risk accepted by security team - JIRA-1234
CVE-0000-67890

# No fix available, compensating controls in place
CVE-0000-11111

Offline Air-Gapped Scanning

For air-gapped environments:

bash
# On internet-connected machine:
trivy image --download-db-only --cache-dir /path/to/db

# Transfer cache to air-gapped environment

# On air-gapped machine:
trivy image --skip-db-update --cache-dir /path/to/db --offline-scan myapp:latest

References

常见问题

Sca Trivy AI 技能有什么作用?

使用 Aqua Trivy 进行软件成分分析(SCA)和容器漏洞扫描,识别依赖项、容器镜像和 IaC 配置错误中的 CVE 漏洞,以及许可证合规风险。适用于:(1)扫描容器镜像和文件系统中的漏洞及配置错误;(2)分析多种语言(Go、Python、Node.js、Java 等)的依赖项,查找已知 CVE;(3)检测 Terraform、Kubernetes 和 Dockerfile 中的 IaC 安全问题;(4)在 CI/CD 流水线中集成漏洞扫描并输出 SARIF;(5)以 CycloneDX 或 SPDX 格式生成软件物料清单(SBOM);(6)根据 CVSS 评分和可利用性确定修复优先级。

为什么在 TypingMind 中使用 Sca Trivy?

因为您只需安装一次,就能搭配任何模型使用。Sca Trivy 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Sca Trivy?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/AgentSecOps/SecOpsAgentKit/tree/main/skills/devsecops/sca-trivy。TypingMind 会读取其中的 SKILL.md,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Sca Trivy?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Sca Trivy 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Sca Trivy 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Sca Trivy AI 技能免费吗?

AgentSecOps 已在 GitHub 上发布了该技能。请查看代码仓库了解许可条款。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇