ShanKonduru/sec-report-kit

GitHub: ShanKonduru/sec-report-kit

将 Trivy、pip-audit、Bandit、Gitleaks 等多种安全扫描工具的 JSON 输出统一渲染为可读的 HTML 漏洞报告,并通过 MCP 协议让 AI 助手直接调用报告生成与汇总能力。

Stars: 1 | Forks: 0

# sec-report-kit 通过 CLI 和 MCP 服务器,从 Trivy、pip-audit、Bandit 和 Gitleaks JSON 生成 HTML 漏洞报告。 ## 安装说明 ``` pip install -e . ``` 包含 MCP 支持: ``` pip install -e .[mcp] ``` ## CLI 用法 以下两个命令均可用: - `srk` - `sec-report-kit` 渲染 Trivy JSON: ``` srk render trivy --input security_reports/trivy-image-report-v1.0.21.json --output security_reports/report-trivy.html --target shankonduru/cpkc-poc:v1.0.21 ``` 渲染 pip-audit JSON: ``` srk render pip-audit --input pip-audit.json --output security_reports/report-pip-audit.html --target requirements.txt ``` ## 辅助脚本 (bat/sh) 跨平台辅助脚本可在 `scripts/` 目录中找到。 安装此包和 pip-audit: ``` # Linux/macOS bash scripts/install_tools.sh # Windows scripts\install_tools.bat ``` 在本地运行所有单元测试并生成覆盖率报告: ``` # Linux/macOS (可选参数: ) bash scripts/run_unit_tests_with_coverage.sh bash scripts/run_unit_tests_with_coverage.sh htmlcov # Windows (可选参数: ) scripts\run_unit_tests_with_coverage.bat scripts\run_unit_tests_with_coverage.bat htmlcov ``` 运行 pip-audit 并写入 JSON 输出: ``` # Linux/macOS (可选参数: ) bash scripts/run_pip_audit.sh bash scripts/run_pip_audit.sh reports requirements.txt # Windows (可选参数: ) scripts\run_pip_audit.bat scripts\run_pip_audit.bat reports requirements.txt ``` 将 pip-audit JSON 报告转换为 HTML: ``` # Linux/macOS (可选参数: ) bash scripts/render_pip_audit_html.sh bash scripts/render_pip_audit_html.sh reports requirements.txt # Windows (可选参数: ) scripts\render_pip_audit_html.bat scripts\render_pip_audit_html.bat reports requirements.txt ``` 这些渲染辅助工具会生成 HTML 文件,并自动在您的默认浏览器中将其打开。 将示例 Trivy JSON 报告转换为 HTML: ``` # Linux/macOS (可选参数: ) bash scripts/render_trivy_html.sh bash scripts/render_trivy_html.sh security_reports my-image # Windows (可选参数: ) scripts\render_trivy_html.bat scripts\render_trivy_html.bat security_reports my-image ``` 将示例 Bandit JSON 报告转换为 HTML: ``` # Linux/macOS (可选参数: ) bash scripts/render_bandit_html.sh bash scripts/render_bandit_html.sh security_reports my-python-project # Windows (可选参数: ) scripts\render_bandit_html.bat scripts\render_bandit_html.bat security_reports my-python-project ``` 将示例 Gitleaks JSON 报告转换为 HTML: ``` # Linux/macOS (可选参数: ) bash scripts/render_gitleaks_html.sh bash scripts/render_gitleaks_html.sh security_reports my-repository # Windows (可选参数: ) scripts\render_gitleaks_html.bat scripts\render_gitleaks_html.bat security_reports my-repository ``` 默认情况下,JSON 会写入 `reports/pip-audit.json`,而 HTML 会写入 `reports/pip-audit-report.html`。 渲染 Bandit JSON: ``` srk render bandit --input bandit-report.json --output security_reports/report-bandit.html --target my-python-project ``` 渲染 Gitleaks JSON: ``` srk render gitleaks --input gitleaks-report.json --output security_reports/report-gitleaks.html --target my-repository ``` ## MCP 服务器 通过 stdio 运行 MCP 服务器: ``` srk mcp serve --transport stdio ``` ### 可用的 MCP 工具 | 工具 | 描述 | |---|---| | `summarize_json` | 按严重程度汇总 JSON 文件中的漏洞 | | `render_report_from_json` | 解析 JSON 并将 HTML 报告渲染到磁盘 | | `validate_input` | 验证 JSON 文件是否可解析并返回发现项计数 | 所有工具均接受 `source_type`(`"trivy"`、`"pip-audit"`、`"bandit"`、`"gitleaks"` 或 `"auto"`)和 `input_path`(JSON 文件的绝对路径)。 ### VS Code (GitHub Copilot Agent / MCP 扩展) 添加到您的 VS Code `settings.json`(或工作区中的 `.vscode/mcp.json`): ``` { "mcp": { "servers": { "sec-report-kit": { "type": "stdio", "command": "srk", "args": ["mcp", "serve", "--transport", "stdio"] } } } } ``` ### Claude Desktop 编辑 `%APPDATA%\Claude\claude_desktop_config.json` (Windows) 或 `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS): ``` { "mcpServers": { "sec-report-kit": { "command": "srk", "args": ["mcp", "serve", "--transport", "stdio"] } } } ``` ### Cursor 打开 **Cursor Settings → MCP** 并添加一个新的服务器条目: ``` { "sec-report-kit": { "command": "srk", "args": ["mcp", "serve", "--transport", "stdio"] } } ``` 或将其添加到项目根目录的 `.cursor/mcp.json` 中: ``` { "mcpServers": { "sec-report-kit": { "command": "srk", "args": ["mcp", "serve", "--transport", "stdio"] } } } ``` ### Windsurf (Codeium) 编辑 `~/.codeium/windsurf/mcp_config.json`: ``` { "mcpServers": { "sec-report-kit": { "command": "srk", "args": ["mcp", "serve", "--transport", "stdio"] } } } ``` ### 使用虚拟环境 如果包安装在 `.venv` 中,请使用完整路径以避免 PATH 问题: **Windows:** ``` { "command": "C:/MyProjects/sec-report-kit/.venv/Scripts/srk.exe", "args": ["mcp", "serve", "--transport", "stdio"] } ``` **macOS / Linux:** ``` { "command": "/home/user/sec-report-kit/.venv/bin/srk", "args": ["mcp", "serve", "--transport", "stdio"] } ``` ## 包发布 构建: ``` python -m build ``` 上传至 TestPyPI: ``` python -m twine upload --repository testpypi dist/* ``` 上传至 PyPI: ``` python -m twine upload dist/* ```
标签:Bandit, DevSecOps, Gitleaks, HTML报告, IP 地址批量处理, JSON解析, LIDS, MCP Server, pip-audit, Python包管理, SAST, 上游代理, 依赖安全, 多模态安全, 安全合规, 安全工具集成, 安全报告生成, 搜索语句(dork), 文档安全, 文档结构分析, 盲注攻击, 网络代理, 自动化安全审计, 跨平台脚本, 逆向工具, 静态应用安全测试