container-hadolint
為 Dockerfile 進行安全性問題的 Lint 檢查
容器映像常包含安全性錯誤設定,造成部署風險。本技能整合 Hadolint,自動依據 CIS Docker Benchmark 要求驗證 Dockerfile,於映像建置前偵測如套件未釘版本、使用 root 使用者與硬編碼機密等問題。
下载技能 ZIP
在 Claude 中上传
前往 设置 → 功能 → 技能 → 上传技能
开启并开始使用
测试它
正在使用“container-hadolint”。 Scan my Dockerfile with hadolint and explain the findings
预期结果:
- DL3002 Error: Never switch back to root - Create a dedicated non-root user and switch to it early in the Dockerfile
- DL3008 Warning: Pin versions in apt-get install - Add specific version numbers to prevent supply chain attacks
- DL3020 Error: Use COPY instead of ADD - ADD can fetch from URLs and auto-extract archives, creating security risks
- DL3025 Warning: Use JSON notation for CMD/ENTRYPOINT - Shell form enables injection attacks
正在使用“container-hadolint”。 How do I set up hadolint in GitHub Actions?
预期结果:
- Use the hadolint/hadolint-action@v3.1.0 in your workflow
- Configure failure-threshold to control build behavior (error, warning, or none)
- Output SARIF format to see results in GitHub Security tab
- Add trusted registries configuration for your organization's requirements
正在使用“container-hadolint”。 What are the most important hadolint rules for production?
预期结果:
- DL3002: Always create and use non-root user
- DL3020: Use COPY instead of ADD to prevent URL fetching
- DL3008: Pin all package versions to prevent supply chain attacks
- DL3025: Use JSON notation for CMD/ENTRYPOINT to prevent shell injection
安全审计
安全This is a pure documentation skill with no executable code. All 200 static findings are false positives triggered by documentation examples showing Dockerfile patterns. The skill provides legitimate security documentation for Hadolint, an open-source Dockerfile linter. No scripts, network calls, or filesystem modifications exist. Behavior matches the stated purpose of Dockerfile security linting guidance.
风险因素
⚙️ 外部命令 (147)
🌐 网络访问 (22)
📁 文件系统访问 (1)
质量评分
你能构建什么
CI/CD 安全性關卡
將 Hadolint 整合到 GitHub Actions 或 GitLab CI,阻止不安全的 Dockerfile 被部署。
合規性驗證
依據 CIS Docker Benchmark 控制項驗證容器設定並產出稽核報告。
本機安全檢查
在開發期間掃描 Dockerfile,於提交程式碼前攔截安全問題。
试试这些提示
使用 hadolint 掃描我的 Dockerfile,並回報找到的任何安全性問題。
建立一個 GitHub Actions 工作流程,對所有 Dockerfile 執行 hadolint 並將結果上傳到 Security 分頁。
產生一份安全性合規報告,顯示我的 Dockerfile 驗證了哪些 CIS Docker Benchmark 控制項。
提供逐步修復計畫,用安全程式碼範例修正 Dockerfile 中的 hadolint 警告。
最佳实践
- 在建置容器映像前於 CI/CD 流水線執行 hadolint,及早攔截問題
- 生產映像使用嚴格設定,對既有 Dockerfile 遷移採用較寬鬆設定
- 結合 hadolint 與 Trivy 或 Grype 等映像掃描器,以取得完整容器安全性
避免
- 忽略 hadolint 警告而未紀錄風險接受決策
- 對基底映像使用 :latest 標籤而非含摘要的釘定版本
- 在 ENV 或 ARG 指令中放入憑證,導致其留存在映像層