filipi86/drogonsec
GitHub: filipi86/drogonsec
这是一个集成了静态应用安全测试、软件成分分析、密钥检测及基础设施即代码审计的高性能开源扫描器,专为开发者和 CI/CD 流水线设计,用于全面发现代码与配置中的安全风险。
Stars: 36 | Forks: 11
# 🛡️ DragonSec Security Scanner
[](https://github.com/filipi86/drogonsec/actions)
[](LICENSE)
[](https://owasp.org/Top10/2025/)
[](https://golang.org)
## 文档
📖 **完整文档:** --> [Drogonsec Doc](https://cross-intel.com/opensource/drogonsec)
## 功能
| 引擎 | 描述 |
|--------|-------------|
| **SAST** | 支持 20 多种语言的静态应用程序安全测试 |
| **SCA** | 软件成分分析 — 扫描依赖项中的 CVE |
| **Leaks** | 密钥检测 — 50 多种模式(AWS、GCP、GitHub、JWT、SSH 密钥等) |
| **IaC** | 基础设施即代码配置错误(Terraform、Kubernetes) |
| **AI** | AI 驱动的修复建议(即将推出) |
### 安全框架
- **OWASP Top 10:2025** — 覆盖全部 10 个类别(包括 2 个新增类别:供应链与异常处理不当)
- **CWE** — 通用弱点枚举映射
- **CVSS 3.1** — 严重性评分
- **SARIF 2.1** — GitHub/Azure DevOps 集成
### 支持的语言
`Python` `Java` `JavaScript` `TypeScript` `Go` `Kotlin` `C#` `PHP` `Ruby` `Swift` `Dart` `Elixir` `Erlang` `Shell` `C/C++` `HTML` `Terraform` `Kubernetes` `Nginx`
## 快速开始
### 安装
**Go Install(需要 Go 1.22+):**
```
go install github.com/filipi86/drogonsec/cmd/drogonsec@latest
```
**从源码安装:**
```
git clone https://github.com/filipi86/drogonsec
cd drogonsec
make install
```
**Docker:**
```
docker run --rm -v $(pwd):/scan ghcr.io/filipi86/drogonsec scan /scan
```
### 基本用法
```
# 扫描当前目录
drogonsec scan .
# 使用 JSON 输出扫描
drogonsec scan ./myproject --format json --output report.json
# 使用 HTML 报告扫描
drogonsec scan . --format html --output report.html
# 使用 AI 修复扫描(即将推出)(需要 AI_API_KEY)
export AI_API_KEY="..."
drogonsec scan . --enable-ai
# 扫描 git 历史记录中的 secrets
drogonsec scan . --git-history
# 仅报告 HIGH 和 CRITICAL
drogonsec scan . --severity HIGH
# 禁用特定引擎
drogonsec scan . --no-sca
drogonsec scan . --no-leaks
drogonsec scan . --no-sast
```
## 输出格式
### 文本(默认)
```
🛡 DragonSec Security Scanner
═══════════════════════════════════════════
Target : /path/to/project
SAST : enabled
SCA : enabled
Leaks : enabled
═══════════════════════════════════════════
═══ SAST FINDINGS ══════════════════════
#1 [HIGH] SQL Injection via string formatting
File : src/users.py:42
Rule : PY-001
OWASP : A05:2025 - Injection
CWE : CWE-89 CVSS: 9.8
Fix : Use parameterized queries...
```
### JSON
```
{
"version": "0.1.0",
"stats": { "total_findings": 5, "critical": 1, "high": 3 },
"sast_findings": [ ... ],
"sca_findings": [ ... ],
"leak_findings": [ ... ]
}
```
### SARIF(GitHub Security 集成)
```
# .github/workflows/security.yml
- name: DragonSec Scan
run: drogonsec scan . --format sarif --output results.sarif
- name: Upload to GitHub Security
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif
```
## 配置
在项目根目录下创建 `.drogonsec.yaml`:
```
scan:
min_severity: LOW
workers: 4
git_history: false
ignore_paths:
- node_modules
- vendor
- dist
engines:
sast:
enabled: true
sca:
enabled: true
leaks:
enabled: true
min_entropy: 3.5
ai:
enabled: false
high_severity_only: true
fail_on:
critical: true
high: true
```
## AI 集成(即将推出)
DrogonSec 包含 AI 驱动的修复功能(即将推出),为检测到的漏洞提供智能的、上下文感知的修复建议:
```
# 设置您的 AI provider API key
export AI_API_KEY="..."
# 启用 AI 修复
drogonsec scan . --enable-ai
# 即将推出:使用您自己的 AI provider
drogonsec scan . --enable-ai \
--ai-provider openai \
--ai-model gpt-4o \
--ai-endpoint https://your-endpoint/v1/messages
# 示例输出:
# 🤖 AI Remediation:
# 第 42 行的 SQL injection 允许攻击者操纵您的查询...
# 修正后的代码:
# cursor.execute("SELECT * FROM users WHERE id = %s", (user_id,))
```
## OWASP Top 10:2025 覆盖范围
| # | 类别 | 状态 |
|---|----------|--------|
| A01 | 失效的访问控制 | ✅ 23 条规则 |
| A02 | 安全配置错误 | ✅ 31 条规则 |
| A03 | 软件供应链故障 🆕 | ✅ SCA 引擎 |
| A04 | 加密失败 | ✅ 18 条规则 |
| A05 | 注入 | ✅ 45 条规则 |
| A06 | 不安全的设计 | ✅ 15 条规则 |
| A07 | 身份验证失败 | ✅ 20 条规则 |
| A08 | 软件和数据完整性故障 | ✅ 9 条规则 |
| A09 | 安全日志和监控故障 | ✅ 11 条规则 |
| A10 | 异常处理不当 🆕 | ✅ 8 条规则 |
## 密钥检测模式
DragonSec 可检测 50 多种密钥模式,包括:
- **云服务:** AWS Access Keys、GCP API Keys、Azure Storage Keys
- **源代码管理:** GitHub tokens(classic、fine-grained、OAuth、App)
- **支付:** Stripe Secret/Restricted Keys
- **通讯:** Slack Bot/App tokens、Webhook URLs
- **邮件:** SendGrid API Keys
- **加密:** RSA/EC/SSH/PGP 私钥、JWT tokens
- **数据库:** 连接字符串(PostgreSQL、MySQL、MongoDB、Redis)
- **通用:** 硬编码密码、API keys、secrets
## 架构
```
drogonsec/
├── cmd/drogonsec/ # CLI entrypoint
├── internal/
│ ├── analyzer/ # Main orchestrator
│ ├── engine/ # SAST rules engine (20+ languages)
│ ├── leaks/ # Secret detection engine
│ ├── sca/ # Dependency analysis engine
│ ├── reporter/ # Text/JSON/SARIF/HTML reporters
│ ├── ai/ # AI remediation engine (Coming soon)
│ └── config/ # Types and configuration
└── rules/ # YAML rule definitions (community-extensible)
```
## 贡献
欢迎贡献!您可以贡献的领域:
- 针对任何语言的新安全规则
- 额外的密钥模式
- 解析器改进
- 文档
- 错误修复
请参阅 [CONTRIBUTING](CONTRIBUTING.md) 了解指南。
## 许可证
Apache License 2.0 — 请参阅 [LICENSE](LICENSE)
## 致谢
灵感来源于 Horusec。DragonSec 是其现代化版本,积极维护并更新了增强功能。
构建工具:Go、Cobra、Viper、go-git。
## 维护者
该开源项目由 **[CROSS-INTEL](https://cross-intel.com)** 维护和支持。标签:Chrome Headless, Claude, CVE检测, CVSS评分, DevSecOps, Docker, EVTX分析, Go语言, GraphQL安全矩阵, IaC扫描, Kubernetes安全, OWASP Top 10, SARIF, SAST, Secret Detection, SOC Prime, Terraform扫描, Web截图, 上游代理, 依赖漏洞扫描, 多语言支持, 安全扫描器, 安全测试框架, 安全漏洞利用, 安全防御评估, 容器安全, 密钥泄露检测, 开发工具, 开源框架, 持续集成, 日志审计, 盲注攻击, 程序破解, 结构化查询, 自动化安全, 请求拦截, 静态应用安全测试