yadakrishna245/DockerShield

GitHub: yadakrishna245/DockerShield

一款 Docker 镜像安全扫描器,可在容器镜像进入生产环境前检测 CVE 漏洞、泄露密钥、恶意软件、配置错误及供应链风险。

Stars: 0 | Forks: 0

# 🛡️ DockerShield [![Python](https://img.shields.io/badge/Python-3.9%2B-blue?logo=python)](https://python.org) [![Docker](https://img.shields.io/badge/Docker-Supported-2496ED?logo=docker)](https://docker.com) [![Security](https://img.shields.io/badge/Security-Scanner-green?logo=shield)](https://github.com/yadakrishna245/DockerShield) [![License](https://img.shields.io/badge/License-MIT-yellow)](LICENSE) **在易受攻击的容器启动前将其拦截。** DockerShield 是一款全面的 Docker 镜像安全扫描器,可通过单条 CLI 命令检测 CVE、泄露的机密、恶意软件、配置错误以及供应链风险。 ## ✨ 功能 | 检查项 | 检测内容 | |-------|----------------| | 🔍 **CVE 扫描** | 已知的易受攻击包(log4j、openssl、curl、glibc 等) | | 🔑 **机密检测** | AWS key、GitHub token、私钥、ENV/层中的密码 | | 🦠 **恶意软件特征** | 加密挖矿程序(xmrig、minerd)、反向 shell、可疑的 cron 任务 | | ⚙️ **配置错误** | 以 root 用户运行、敏感端口、无 healthcheck、过度臃肿的镜像 | | 🔗 **供应链** | 不受信任的 registry、未签名的镜像、陈旧的构建、`latest` 标签 | ## 🚀 快速开始 ### 通过 pip 安装 ``` git clone https://github.com/yadakrishna245/DockerShield.git cd DockerShield pip install . ``` ### 直接运行 ``` python dockershield.py nginx:latest ``` ### 使用选项 ``` # JSON 输出 python dockershield.py myapp:v2.1 --json # HTML 报告 python dockershield.py myapp:v2.1 --html report.html # 按 severity 筛选 python dockershield.py myapp:v2.1 --severity high ``` ### Docker 运行 ``` docker build -t dockershield . docker run --rm -v /var/run/docker.sock:/var/run/docker.sock dockershield nginx:latest ``` ### GitHub Action ``` - uses: yadakrishna245/DockerShield@main with: image: "myapp:latest" severity: "medium" output-format: "json" ``` ## 📋 示例输出 ``` ╔══════════════════════════════════════════╗ ║ DockerShield v1.0.0 ║ ║ Scanning: nginx:latest ║ ╚══════════════════════════════════════════╝ [1/5] Scanning for CVEs... [2/5] Scanning for secrets... [3/5] Scanning for malware... [4/5] Scanning for misconfigurations... [5/5] Scanning supply chain... ╭──────────────────────────────────────────────────────────────────╮ │ Category │ Severity │ Finding │ Remediation │ ├──────────────────┼──────────┼──────────────────────┼─────────────┤ │ CVE │ CRITICAL │ CVE-2022-25235 │ Update pkg │ │ Misconfiguration │ HIGH │ Runs as root │ Add USER │ │ Supply Chain │ MEDIUM │ Using 'latest' tag │ Pin version │ ╰──────────────────────────────────────────────────────────────────╯ Status: FAIL | Total: 3 | Critical: 1 High: 1 Medium: 1 Low: 0 ``` ## 🏗️ 架构 ``` ┌─────────────────────────────────────────────────┐ │ DockerShield CLI │ ├─────────────────────────────────────────────────┤ │ Input: image name ──► Docker SDK (pull/inspect) │ │ │ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │ │CVE Scan │ │ Secrets │ │ Malware │ │ │ └────┬────┘ └────┬────┘ └────┬────┘ │ │ │ │ │ │ │ ┌────┴────┐ ┌────┴────┐ │ │ │ Misconf │ │ Supply │ │ │ │ igure │ │ Chain │ │ │ └────┬────┘ └────┬────┘ │ │ │ │ │ │ ▼ ▼ │ │ ┌─────────────────────────┐ │ │ │ Findings Aggregator │ │ │ └────────────┬────────────┘ │ │ │ │ │ ┌─────────┼─────────┐ │ │ ▼ ▼ ▼ │ │ [Terminal] [JSON] [HTML] │ └─────────────────────────────────────────────────┘ ``` ## 🔄 对比 | 功能 | DockerShield | Trivy | Grype | |---------|:---:|:---:|:---:| | CVE 扫描 | ✅ | ✅ | ✅ | | 机密检测 | ✅ | ✅ | ❌ | | 恶意软件检测 | ✅ | ❌ | ❌ | | 配置错误 | ✅ | ✅ | ❌ | | 供应链 | ✅ | ⚠️ | ❌ | | 单文件工具 | ✅ | ❌ | ❌ | | GitHub Action | ✅ | ✅ | ✅ | | HTML 报告 | ✅ | ❌ | ❌ | | 零配置 | ✅ | ✅ | ✅ | | 加密挖矿检测 | ✅ | ❌ | ❌ | ## 📄 许可证 MIT 许可证 — 查看 [LICENSE](LICENSE) ## 👤 作者 **Krishna Chaithanya Yada** - GitHub: [@yadakrishna245](https://github.com/yadakrishna245)
标签:Docker, Python, 安全防御评估, 无后门, 活动识别, 请求拦截, 逆向工具, 镜像扫描