kavinu1/dockerfile-compose-reviewer
GitHub: kavinu1/dockerfile-compose-reviewer
一款结合 Hadolint、Trivy 与本地 Ollama 大模型的 AI 驱动 Dockerfile 及镜像安全审查工具,自动生成优先级排序的安全强化报告。
Stars: 0 | Forks: 0
# Dockerfile / Compose 审查工具
一款由 AI 驱动的 DevSecOps 工具,使用 **Hadolint**、**Trivy**、**Python** 和 **Ollama (Hermes 3)** 对 Dockerfile 和 Docker 镜像进行审查。
该应用程序会分析 Dockerfile 中的最佳实践违规情况,扫描 Docker 镜像中的已知漏洞,并将结果整合到一份 AI 生成的安全审查报告中。该代理会生成一份按优先级排序的强化报告以及一份 pull request 风格的摘要,以帮助开发者提升容器安全性。
# 功能
- 使用 Hadolint 进行 Dockerfile 最佳实践分析
- 使用 Trivy 进行容器漏洞扫描
- 使用 Ollama (Hermes 3) 进行 AI 驱动的安全分析
- 按优先级排序的安全建议
- Pull request 风格的强化摘要
- 生成 Markdown 安全报告
- 本地优先架构(无需云 AI)
# 架构
```
+------------------------+
| Dockerfile |
+-----------+------------+
|
|
+-------v-------+
| Hadolint |
+-------+-------+
|
|
|
Docker Image |
| |
v |
+-------------+ |
| Trivy |-----------------+
+------+------+
|
v
+------------------------+
| Python Agent |
+-----------+------------+
|
|
v
+------------------------+
| Ollama (Hermes 3) |
+-----------+------------+
|
|
v
+------------------------+
| AI Security Review |
| Markdown Report |
| PR Description |
+------------------------+
```
# 使用的技术
- Docker
- Docker Compose
- Python
- Hadolint
- Trivy
- Ollama
- Hermes 3
- Markdown
# 项目结构
```
dockerfile-compose-reviewer/
│
├── agent/
│ ├── app.py
│ ├── requirements.txt
│ └── .venv/
│
├── sample/
│ ├── Dockerfile
│ └── docker-compose.yml
│
├── scans/
│ ├── hadolint.txt
│ └── trivy.txt
│
├── reports/
│ └── security-review.md
│
├── .gitignore
└── README.md
```
# 前置条件
- Docker Desktop
- Python 3.11+
- Ollama
- Hermes 3 模型
- Hadolint
- Trivy
安装所需的工具:
```
brew install hadolint
brew install trivy
ollama pull hermes3
```
# 快速开始
## 克隆仓库
```
git clone https://github.com//dockerfile-compose-reviewer.git
cd dockerfile-compose-reviewer
```
## 构建示例 Docker 镜像
```
cd sample
docker build -t sample-app .
cd ..
```
## 运行 Hadolint
```
hadolint sample/Dockerfile > scans/hadolint.txt
```
## 运行 Trivy
```
trivy image sample-app > scans/trivy.txt
```
## 创建虚拟环境
```
cd agent
python3 -m venv .venv
source .venv/bin/activate
```
## 安装依赖
```
pip install -r requirements.txt
```
## 运行 AI 审查工具
```
python app.py
```
# 示例输出
```
======================================================================
AI SECURITY REVIEW
======================================================================
Executive Summary
Highest Priority Risks
Dockerfile Best Practice Issues
Security Vulnerabilities
Recommended Fixes
Example Pull Request Description
======================================================================
Report saved to reports/security-review.md
```
# 生成的报告
每次执行都会生成:
```
reports/
└── security-review.md
```
示例:
```
# Docker 安全审查
Generated:
2026-07-05
## 执行摘要
...
## 最高优先级风险
...
## 建议修复
...
```
# 工作流
```
Dockerfile
↓
Hadolint
↓
Docker Image
↓
Trivy
↓
Python Agent
↓
Hermes 3
↓
AI Security Review
↓
Markdown Report
```
# 未来改进
- GitHub Pull Request 集成
- GitHub Actions 工作流
- 生成 SARIF 报告
- 支持多个 Dockerfile
- Docker Compose 安全分析
- 基于 CVSS 的优先级排序
- 生成 HTML 报告
- Slack 通知
# 许可证
本项目基于 MIT 许可证授权。
标签:AI风险缓解, DevSecOps, Docker, Web截图, 上游代理, 人工智能, 安全防御评估, 容器安全, 本地大模型, 版权保护, 用户模式Hook绕过, 请求拦截, 逆向工具