关于 Dockerfile Audit
Dockerfile Audit 是用于静态检查 Dockerfile 安全与质量问题的 MCP 服务。它为开发者和 Agent 提供带行号、严重级别、修复说明及 Dockerfile 片段的发现项。
主要功能
- 01审计 Dockerfile 文本或 HTTPS URL
- 02检查基础镜像与指令
- 03查找安全和密钥处理问题
- 04审查构建效率做法
- 05按严重级别筛选发现项
- 06提供行号、修复说明和片段
适用场景
- 01构建镜像前审查 Dockerfile
- 02查找以 root 运行或硬编码密钥
- 03定位过时镜像标签和指令问题
MCP 相关
向 MCP 客户端提供完整审计及按类别检查工具,接收 Dockerfile 内容或 HTTPS URL。结果包含严重级别、行号、修复说明和 Dockerfile 修复片段。
配置
远程服务无需本地安装。选择你使用的客户端,复制配置或使用一键安装。
https://unbearable-dev--dockerfile-audit.apify.actor/mcpclaude mcp add --transport http unbearabledev-dockerfile-audit https://unbearable-dev--dockerfile-audit.apify.actor/mcp{"mcpServers":{"unbearabledev-dockerfile-audit":{"type":"http","url":"https://unbearable-dev--dockerfile-audit.apify.actor/mcp"}}}在 Cursor 中打开{"servers":{"unbearabledev-dockerfile-audit":{"type":"http","url":"https://unbearable-dev--dockerfile-audit.apify.actor/mcp"}}}在 VS Code 中打开{"mcpServers":{"unbearabledev-dockerfile-audit":{"type":"http","url":"https://unbearable-dev--dockerfile-audit.apify.actor/mcp"}}}{"mcpServers":{"unbearabledev-dockerfile-audit":{"serverUrl":"https://unbearable-dev--dockerfile-audit.apify.actor/mcp"}}}命令在终端中运行;JSON 粘贴到对应客户端的 MCP 配置后重启。需要授权的服务会在首次连接时提示登录。
https://unbearable-dev--dockerfile-audit.apify.actor/mcp需要授权工具
详细介绍
Dockerfile 安全与质量审计
以 MCP 服务形式提供 Hadolint 级别的 Dockerfile 审计。涵盖 5 个类别、18 项以上检查,每条发现都附带严重性、行号、修复说明和可直接复制粘贴的 Dockerfile 代码片段。
由 Unbearable Labs 构建。 按事件付费——仅在实际调用工具时计费。
可用平台
- Apify Actor Store — 主要平台,按量计费(PPE)
- MCPize — 待提交
- MCP.so — 待提交
- PulseMCP — 待提交
- Smithery — 待提交
- Glama — 待提交
Newsletter: Unbearable TechTips Weekly · 所有 Actor: github.com/UnbearableDev
功能
让任何支持 MCP 的客户端(Claude Desktop、Cursor、n8n、Make、Zapier、自定义 Agent)连接此服务,传入 Dockerfile,即可获得结构化报告:
- 严重性 — 高 / 中 / 低 / 信息
- 行号 — 文件中的确切位置
- 描述 — 问题所在及其重要性
- 修复方法 — 应如何处理
- 修复代码片段 — 可直接粘贴的 Dockerfile 语法
工具
| 工具 | 用途 |
|---|---|
audit_dockerfile(dockerfile_content? | dockerfile_url?, min_severity='low') | 运行所有检查 |
check_base_image(...) | 仅检查 FROM、标签、摘要和注册表 |
check_instructions(...) | CMD 格式、ADD 与 COPY、MAINTAINER 等 |
check_security(...) | USER、sudo、chmod 777、curl|bash、硬编码机密、HEALTHCHECK |
check_efficiency(...) | apt 缓存清理、pip 缓存 |
check_secrets(...) | 名称符合机密模式的 ARG |
list_checks(category?) | 浏览完整检查目录 |
请提供 dockerfile_content(粘贴文件内容)或 dockerfile_url(HTTPS URL,例如 GitHub raw)中的一个,且只能提供一个。
检查目录(v1:涵盖 5 个类别的 18 项检查)
| ID | 类别 | 严重性 | 标题 |
|---|---|---|---|
| DFA-001 | base_image | 中 | 镜像使用 :latest 标签或未指定标签 |
| DFA-002 | base_image | 信息 | FROM 未固定 SHA256 摘要 |
| DFA-003 | base_image | 中 | 不受信任的注册表 |
| DFA-010 | instructions | 低 | CMD 使用 shell 格式 |
| DFA-011 | instructions | 低 | ENTRYPOINT 使用 shell 格式 |
| DFA-012 | instructions | 信息 | MAINTAINER 指令已弃用 |
| DFA-013 | instructions | 中 | 可使用 COPY 的场景却使用了 ADD |
| DFA-020 | security | 中 | 未指定 USER 指令(以 root 身份运行) |
| DFA-021 | security | 高 | 显式设置 USER root |
| DFA-022 | security | 高 | 在 RUN 中调用 sudo |
| DFA-023 | security | 高 | 在 RUN 中使用 chmod 777 |
| DFA-024 | security | 中 | 在 RUN 中使用 curl|bash 模式 |
| DFA-025 | security | 高 | ENV 中包含硬编码机密 |
| DFA-027 | security | 低 | 未设置 HEALTHCHECK |
| DFA-030 | efficiency | 低 | apt-get update 未搭配 install |
| DFA-031 | efficiency | 低 | apt-get install 未使用 --no-install-recommends |
| DFA-032 | efficiency | 低 | pip install 未使用 --no-cache-dir |
| DFA-040 | secrets | 中 | ARG 名称符合机密模式 |
使用 list_checks 获取权威且最新的目录。
定价
| 事件 | USD |
|---|---|
| 任意审计 / check_* 工具调用 | $0.02 |
list_checks 查询 | $0.005 |
响应示例(已截断)
{
"summary": {
"total_findings": 6,
"by_severity": {"high": 2, "medium": 2, "low": 2, "info": 0}
},
"findings": [
{
"id": "DFA-021",
"category": "security",
"severity": "high",
"instruction": "USER",
"line_number": 3,
"title": "USER root set explicitly",
"description": "...",
"remediation": "Switch to a non-root UID after any root-required RUN steps.",
"fix_dockerfile_snippet": "USER 10001:10001",
"references": ["CIS-Docker-4.1"]
}
]
}
从 Claude Desktop 连接
{
"mcpServers": {
"dockerfile-audit": {
"transport": "streamable-http",
"url": "https://YOUR-ACTOR-URL.apify.actor/mcp"
}
}
}
限制
- Dockerfile 大小: 每次审计上限为 200 KB
- URL 获取: 超时 5s,最多重定向 3 次,仅支持 HTTPS
- 会话超时: 不活动 5 分钟后超时
暂不支持的功能
- 实时镜像漏洞扫描(请使用 Trivy / Grype)
- 多阶段构建优化分析(DFA-004 / DFA-005 — 已列入路线图)
- Compose 文件审计(独立 MCP:
docker-compose-audit)
Unbearable Labs 的相关 MCP
docker-compose-audit— 用于docker-compose.yml的同类工具hu-postcode-validator— 匈牙利邮政编码查询
源码 / 联系方式
问题和想法:[email protected],或联系 GitHub 组织 UnbearableDev。
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。