mcpField
B
building-vulnerability-dashboard-with-defectdojo

building-vulnerability-dashboard-with-defectdojo

github.com/mukul975安全35.2k202 次安装8 周前更新
代码仓库

关于 building-vulnerability-dashboard-with-defectdojo

这是一份将 DefectDojo 部署为漏洞管理中心的指南,面向安全团队,介绍扫描结果导入、修复跟踪、仪表板和 REST API 自动化。

主要功能

  1. 01汇总多个安全扫描器的发现
  2. 02去重并跟踪漏洞
  3. 03监控修复进度
  4. 04查看高管仪表板指标
  5. 05通过 REST API 自动化

适用场景

  1. 01集中管理多个扫描器的结果
  2. 02跟踪不同产品评估中的修复
  3. 03从 CI/CD 上传扫描结果
  4. 04查看严重性和 SLA 指标

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill building-vulnerability-dashboard-with-defectdojo

安装后在 Claude Code 中输入/building-vulnerability-dashboard-with-defectdojo确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

LICENSE
assets/
template.md
references/
api-reference.md
standards.md
workflows.md
scripts/
agent.py
process.py

详细介绍

使用 DefectDojo 构建漏洞仪表板

概述

DefectDojo 是一个开源应用程序漏洞管理平台,可汇总来自 200 多种安全工具的发现结果,对结果进行去重,跟踪修复进度,并提供高管仪表板。它可作为漏洞管理的中央枢纽,与 CI/CD 流水线集成,并可与 Jira 集成用于工单管理、与 Slack 集成用于通知。DefectDojo 支持基于 OWASP 的分类,并提供用于自动化的 REST API。

适用场景

  • 在环境中部署或配置使用 DefectDojo 构建漏洞仪表板的能力时
  • 建立与合规要求一致的安全控制时
  • 为该领域构建或改进安全架构时
  • 执行需要此实现的安全评估时

前置条件

  • Docker 和 Docker Compose
  • 4GB+ 内存,2+ CPU 核心,20GB+ 磁盘
  • PostgreSQL 12+(Docker 部署中已包含)
  • 用于 API 集成脚本的 Python 3.9+
  • Jira 实例(可选,用于工单集成)

部署

Docker Compose 部署
# Clone DefectDojo repository
git clone https://github.com/DefectDojo/django-DefectDojo.git
cd django-DefectDojo

# Start with Docker Compose (production mode)
./dc-up-d.sh

# Alternative: manual Docker Compose
docker compose up -d

# Check service status
docker compose ps

# View initial admin credentials
docker compose logs initializer 2>&1 | grep "Admin password"

# Access DefectDojo at http://localhost:8080
环境配置
# Key environment variables in docker-compose.yml
DD_DATABASE_ENGINE=django.db.backends.postgresql
DD_DATABASE_HOST=postgres
DD_DATABASE_PORT=5432
DD_DATABASE_NAME=defectdojo
DD_DATABASE_USER=defectdojo
DD_DATABASE_PASSWORD=<secure_password>
DD_ALLOWED_HOSTS=*
DD_SECRET_KEY=<random_64_char_key>
DD_CREDENTIAL_AES_256_KEY=<random_128_bit_key>
DD_SOCIAL_AUTH_GOOGLE_OAUTH2_ENABLED=True

组织结构

层级结构
Product Type (Business Unit)
  └── Product (Application/Service)
       └── Engagement (Assessment/Sprint)
            └── Test (Scanner Run)
                 └── Finding (Individual Vulnerability)
通过 API 设置
import requests

DD_URL = "http://localhost:8080/api/v2"
API_KEY = "your_api_key_here"
HEADERS = {"Authorization": f"Token {API_KEY}", "Content-Type": "application/json"}

# Create Product Type
resp = requests.post(f"{DD_URL}/product_types/", headers=HEADERS, json={
    "name": "Web Applications",
    "description": "Customer-facing web application portfolio"
})
product_type_id = resp.json()["id"]

# Create Product
resp = requests.post(f"{DD_URL}/products/", headers=HEADERS, json={
    "name": "Customer Portal",
    "description": "Main customer-facing web application",
    "prod_type": product_type_id,
    "sla_configuration": 1,
})
product_id = resp.json()["id"]

# Create Engagement
resp = requests.post(f"{DD_URL}/engagements/", headers=HEADERS, json={
    "name": "Q1 2024 Security Assessment",
    "product": product_id,
    "target_start": "2024-01-01",
    "target_end": "2024-03-31",
    "engagement_type": "CI/CD",
    "status": "In Progress",
})
engagement_id = resp.json()["id"]

扫描器集成

通过 API 导入扫描结果
# Upload Nessus scan results
curl -X POST "${DD_URL}/reimport-scan/" \
  -H "Authorization: Token ${API_KEY}" \
  -F "scan_type=Nessus Scan" \
  -F "file=@nessus_report.csv" \
  -F "product_name=Customer Portal" \
  -F "engagement_name=Q1 2024 Security Assessment" \
  -F "auto_create_context=true" \
  -F "deduplication_on_engagement=true"

# Upload OWASP ZAP results
curl -X POST "${DD_URL}/reimport-scan/" \
  -H "Authorization: Token ${API_KEY}" \
  -F "scan_type=ZAP Scan" \
  -F "file=@zap_report.xml" \
  -F "product_name=Customer Portal" \
  -F "engagement_name=Q1 2024 Security Assessment" \
  -F "auto_create_context=true"

# Upload Trivy container scan
curl -X POST "${DD_URL}/reimport-scan/" \
  -H "Authorization: Token ${API_KEY}" \
  -F "scan_type=Trivy Scan" \
  -F "file=@trivy_results.json" \
  -F "product_name=Customer Portal" \
  -F "engagement_name=Q1 2024 Security Assessment" \
  -F "auto_create_context=true"
支持的扫描器类型(部分列表)
扫描器类型字符串格式
NessusNessus ScanCSV/XML
OpenVASOpenVAS CSVCSV
QualysQualys ScanXML
OWASP ZAPZAP ScanXML/JSON
Burp SuiteBurp XMLXML
TrivyTrivy ScanJSON
SemgrepSemgrep JSON ReportJSON
SnykSnyk ScanJSON
SonarQubeSonarQube ScanJSON
CheckovCheckov ScanJSON
CI/CD 集成(GitHub Actions)
# .github/workflows/security-scan.yml
name: Security Scan
on: [push]
jobs:
  scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Run Semgrep
        run: |
          pip install semgrep
          semgrep --config auto --json -o semgrep_results.json .
      - name: Upload to DefectDojo
        run: |
          curl -X POST "${{ secrets.DD_URL }}/api/v2/reimport-scan/" \
            -H "Authorization: Token ${{ secrets.DD_API_KEY }}" \
            -F "scan_type=Semgrep JSON Report" \
            -F "file=@semgrep_results.json" \
            -F "product_name=${{ github.event.repository.name }}" \
            -F "engagement_name=CI/CD" \
            -F "auto_create_context=true"

Jira 集成

# Configure Jira integration in DefectDojo settings
jira_config = {
    "url": "https://company.atlassian.net",
    "username": "[email protected]",
    "password": "jira_api_token",
    "default_issue_type": "Bug",
    "critical_mapping_severity": "Blocker",
    "high_mapping_severity": "Critical",
    "medium_mapping_severity": "Major",
    "low_mapping_severity": "Minor",
    "finding_text": "**Vulnerability**: {{ finding.title }}\n**Severity**: {{ finding.severity }}\n**CVE**: {{ finding.cve }}\n**Description**: {{ finding.description }}",
    "accepted_mapping_resolution": "Done",
    "close_status_key": 6,
}

指标与仪表板

关键指标 API 查询
# Get finding counts by severity
resp = requests.get(f"{DD_URL}/findings/?limit=0&active=true",
                    headers=HEADERS)
findings = resp.json()

# Get SLA breach counts
resp = requests.get(f"{DD_URL}/findings/?limit=0&active=true&sla_breached=true",
                    headers=HEADERS)

# Get product-level metrics
resp = requests.get(f"{DD_URL}/products/{product_id}/",
                    headers=HEADERS)
product_data = resp.json()

参考资料

评论

支持 Markdown