@hybridlabor-api/aos 4.8.0 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/{agents.md → AGENTS.md} +3 -1
- package/.agents/nodes.json +3 -1
- package/.agents/vendor-manifest.json +23 -1
- package/.claude/agents/godmode-media-eventtech.md +1 -1
- package/.claude/hooks/conventional-commits.mjs +125 -0
- package/.claude/hooks/env-file-protection.mjs +105 -0
- package/.claude/hooks/go-gate.mjs +101 -81
- package/.claude/hooks/memb-inject.mjs +29 -1
- package/.claude/settings.json +13 -0
- package/.claude/workflows/startcycle-dispatch.mjs +23 -1
- package/.opencode/agents/godmode-media-eventtech.md +1 -1
- package/.opencode/plugins/bdb-aos.js +31 -4
- package/CLAUDE.md +0 -571
- package/README.de.md +1 -1
- package/README.md +1 -1
- package/README.pt.md +1 -1
- package/THIRD_PARTY_NOTICES.md +126 -0
- package/bin/aos-doctor.mjs +1 -1
- package/docs/skills_table.md +1 -1
- package/installer.js +187 -55
- package/package.json +7 -3
- package/packages/aos-cli/README.md +80 -0
- package/packages/aos-cli/bin/aos-cli.mjs +134 -0
- package/packages/aos-cli/core-skills.json +12 -0
- package/packages/aos-cli/extensions/aos.ts +321 -0
- package/packages/aos-cli/package-lock.json +1923 -0
- package/packages/aos-cli/package.json +29 -0
- package/packages/aos-cli/scripts/check-theme.mjs +63 -0
- package/packages/aos-cli/themes/aos.json +97 -0
- package/scripts/build-plugin-manifest.mjs +131 -0
- package/scripts/validate-skills.mjs +81 -6
- package/skills/basic/ao-orchestrator/SKILL.md +116 -0
- package/skills/basic/bdb-eventagency-skill/SKILL.md +252 -0
- package/skills/basic/bdb-shipping-skill/SKILL.md +161 -0
- package/skills/basic/godmode-eventtech/SKILL.md +4 -1
- package/skills/global_config/agenttrail/SKILL.md +6 -1
- package/skills/global_config/aos-project-init/SKILL.md +2 -0
- package/skills/global_config/aos-project-init/assets/AGENTS.template.md +1 -1
- package/skills/global_config/aos-project-init/scripts/aos-project-doctor.mjs +1 -1
- package/skills/global_config/aos-setup/SKILL.md +1 -1
- package/skills/global_config/aos-setup/scripts/aos-doctor.mjs +1 -1
- package/skills/global_config/ask-tim/SKILL.md +7 -7
- package/skills/global_config/bash-script-generator/SKILL.md +201 -0
- package/skills/global_config/bash-script-generator/assets/templates/standard-template.sh +96 -0
- package/skills/global_config/bash-script-generator/docs/bash-scripting-guide.md +729 -0
- package/skills/global_config/bash-script-generator/docs/generation-best-practices.md +193 -0
- package/skills/global_config/bash-script-generator/docs/script-patterns.md +566 -0
- package/skills/global_config/bash-script-generator/docs/text-processing-guide.md +437 -0
- package/skills/global_config/bash-script-generator/examples/log-analyzer.sh +92 -0
- package/skills/global_config/bash-script-generator/scripts/generate_script_template.sh +123 -0
- package/skills/global_config/bash-script-generator/scripts/run_ci_checks.sh +172 -0
- package/skills/global_config/bash-script-generator/scripts/test_generator.sh +413 -0
- package/skills/global_config/bash-script-validator/SKILL.md +249 -0
- package/skills/global_config/bash-script-validator/docs/awk-reference.md +449 -0
- package/skills/global_config/bash-script-validator/docs/bash-reference.md +468 -0
- package/skills/global_config/bash-script-validator/docs/common-mistakes.md +623 -0
- package/skills/global_config/bash-script-validator/docs/grep-reference.md +395 -0
- package/skills/global_config/bash-script-validator/docs/regex-reference.md +391 -0
- package/skills/global_config/bash-script-validator/docs/sed-reference.md +454 -0
- package/skills/global_config/bash-script-validator/docs/shell-reference.md +463 -0
- package/skills/global_config/bash-script-validator/docs/shellcheck-reference.md +399 -0
- package/skills/global_config/bash-script-validator/examples/bad-bash.sh +55 -0
- package/skills/global_config/bash-script-validator/examples/bad-shell.sh +54 -0
- package/skills/global_config/bash-script-validator/examples/good-bash.sh +71 -0
- package/skills/global_config/bash-script-validator/examples/good-shell.sh +69 -0
- package/skills/global_config/bash-script-validator/scripts/run_ci_checks.sh +23 -0
- package/skills/global_config/bash-script-validator/scripts/shellcheck_wrapper.sh +174 -0
- package/skills/global_config/bash-script-validator/scripts/test_validate.sh +446 -0
- package/skills/global_config/bash-script-validator/scripts/validate.sh +512 -0
- package/skills/global_config/ci-pipeline/SKILL.md +135 -0
- package/skills/global_config/deja-memory/SKILL.md +3 -1
- package/skills/global_config/dispatching-parallel-agents/SKILL.md +170 -0
- package/skills/global_config/dockerfile-generator/SKILL.md +1038 -0
- package/skills/global_config/dockerfile-generator/examples/example.dockerignore +95 -0
- package/skills/global_config/dockerfile-generator/examples/golang-distroless.Dockerfile +34 -0
- package/skills/global_config/dockerfile-generator/examples/java-springboot.Dockerfile +45 -0
- package/skills/global_config/dockerfile-generator/examples/nextjs-production.Dockerfile +49 -0
- package/skills/global_config/dockerfile-generator/examples/nodejs-multistage.Dockerfile +55 -0
- package/skills/global_config/dockerfile-generator/examples/python-fastapi.Dockerfile +48 -0
- package/skills/global_config/dockerfile-generator/references/language_specific_guides.md +510 -0
- package/skills/global_config/dockerfile-generator/references/multistage_builds.md +570 -0
- package/skills/global_config/dockerfile-generator/references/optimization_patterns.md +492 -0
- package/skills/global_config/dockerfile-generator/references/security_best_practices.md +375 -0
- package/skills/global_config/dockerfile-generator/scripts/generate_dockerignore.sh +199 -0
- package/skills/global_config/dockerfile-generator/scripts/generate_golang.sh +172 -0
- package/skills/global_config/dockerfile-generator/scripts/generate_java.sh +185 -0
- package/skills/global_config/dockerfile-generator/scripts/generate_nodejs.sh +279 -0
- package/skills/global_config/dockerfile-generator/scripts/generate_python.sh +218 -0
- package/skills/global_config/dockerfile-generator/scripts/test_generator.sh +210 -0
- package/skills/global_config/dockerfile-validator/SKILL.md +300 -0
- package/skills/global_config/dockerfile-validator/examples/.dockerignore.example +34 -0
- package/skills/global_config/dockerfile-validator/examples/bad-example.Dockerfile +37 -0
- package/skills/global_config/dockerfile-validator/examples/golang-distroless.Dockerfile +50 -0
- package/skills/global_config/dockerfile-validator/examples/good-example.Dockerfile +52 -0
- package/skills/global_config/dockerfile-validator/examples/python-optimized.Dockerfile +53 -0
- package/skills/global_config/dockerfile-validator/examples/security-issues.Dockerfile +42 -0
- package/skills/global_config/dockerfile-validator/references/docker_best_practices.md +348 -0
- package/skills/global_config/dockerfile-validator/references/optimization_guide.md +473 -0
- package/skills/global_config/dockerfile-validator/references/security_checklist.md +208 -0
- package/skills/global_config/dockerfile-validator/scripts/dockerfile-validate.sh +699 -0
- package/skills/global_config/dockerfile-validator/scripts/test_validate.sh +35 -0
- package/skills/global_config/dockerfile-validator/tests/fixtures/copy-before-yarn-lock-read.Dockerfile +6 -0
- package/skills/global_config/dockerfile-validator/tests/fixtures/copy-before-yarn.Dockerfile +6 -0
- package/skills/global_config/dockerfile-validator/tests/fixtures/from-platform-nonroot.Dockerfile +7 -0
- package/skills/global_config/dockerfile-validator/tests/test_regression.sh +164 -0
- package/skills/global_config/finishing-a-development-branch/SKILL.md +228 -0
- package/skills/global_config/github-actions-generator/SKILL.md +353 -0
- package/skills/global_config/github-actions-generator/assets/templates/action/composite/action.yml +82 -0
- package/skills/global_config/github-actions-generator/assets/templates/action/docker/Dockerfile +25 -0
- package/skills/global_config/github-actions-generator/assets/templates/action/docker/action.yml +42 -0
- package/skills/global_config/github-actions-generator/assets/templates/action/docker/entrypoint.sh +27 -0
- package/skills/global_config/github-actions-generator/assets/templates/action/javascript/action.yml +33 -0
- package/skills/global_config/github-actions-generator/assets/templates/action/javascript/index.js +50 -0
- package/skills/global_config/github-actions-generator/assets/templates/action/javascript/package.json +27 -0
- package/skills/global_config/github-actions-generator/assets/templates/workflow/basic_workflow.yml +242 -0
- package/skills/global_config/github-actions-generator/assets/templates/workflow/reusable_workflow.yml +106 -0
- package/skills/global_config/github-actions-generator/examples/README.md +147 -0
- package/skills/global_config/github-actions-generator/examples/actions/setup-node-cached/action.yml +93 -0
- package/skills/global_config/github-actions-generator/examples/caching/docker-buildkit.yml +256 -0
- package/skills/global_config/github-actions-generator/examples/security/dependency-review.yml +62 -0
- package/skills/global_config/github-actions-generator/examples/security/sbom-attestation.yml +119 -0
- package/skills/global_config/github-actions-generator/examples/triggers/chatops-commands.yml +475 -0
- package/skills/global_config/github-actions-generator/examples/triggers/repository-dispatch.yml +418 -0
- package/skills/global_config/github-actions-generator/examples/triggers/workflow-orchestration.yml +404 -0
- package/skills/global_config/github-actions-generator/examples/workflows/docker-build-push.yml +68 -0
- package/skills/global_config/github-actions-generator/examples/workflows/go-ci.yml +161 -0
- package/skills/global_config/github-actions-generator/examples/workflows/monorepo-ci.yml +340 -0
- package/skills/global_config/github-actions-generator/examples/workflows/multi-environment-deploy.yml +406 -0
- package/skills/global_config/github-actions-generator/examples/workflows/nodejs-ci.yml +122 -0
- package/skills/global_config/github-actions-generator/examples/workflows/python-ci.yml +157 -0
- package/skills/global_config/github-actions-generator/examples/workflows/scheduled-tasks.yml +376 -0
- package/skills/global_config/github-actions-generator/references/advanced-triggers.md +917 -0
- package/skills/global_config/github-actions-generator/references/best-practices.md +755 -0
- package/skills/global_config/github-actions-generator/references/common-actions.md +715 -0
- package/skills/global_config/github-actions-generator/references/custom-actions.md +320 -0
- package/skills/global_config/github-actions-generator/references/expressions-and-contexts.md +688 -0
- package/skills/global_config/github-actions-generator/references/modern-features.md +421 -0
- package/skills/global_config/github-actions-generator/scripts/test_generator.sh +344 -0
- package/skills/global_config/github-actions-templates/SKILL.md +7 -0
- package/skills/global_config/github-actions-validator/SKILL.md +576 -0
- package/skills/global_config/github-actions-validator/examples/README.md +88 -0
- package/skills/global_config/github-actions-validator/examples/outdated-versions.yml +76 -0
- package/skills/global_config/github-actions-validator/examples/valid-ci.yml +79 -0
- package/skills/global_config/github-actions-validator/examples/with-errors.yml +47 -0
- package/skills/global_config/github-actions-validator/references/act_usage.md +233 -0
- package/skills/global_config/github-actions-validator/references/action_versions.md +122 -0
- package/skills/global_config/github-actions-validator/references/actionlint_usage.md +343 -0
- package/skills/global_config/github-actions-validator/references/common_errors.md +512 -0
- package/skills/global_config/github-actions-validator/references/modern_features.md +384 -0
- package/skills/global_config/github-actions-validator/references/runners.md +317 -0
- package/skills/global_config/github-actions-validator/scripts/install_tools.sh +113 -0
- package/skills/global_config/github-actions-validator/scripts/validate_workflow.sh +910 -0
- package/skills/global_config/github-actions-validator/tests/test_validate_workflow.sh +237 -0
- package/skills/global_config/makefile-generator/SKILL.md +614 -0
- package/skills/global_config/makefile-generator/assets/templates/.gitkeep +1 -0
- package/skills/global_config/makefile-generator/docs/makefile-structure.md +530 -0
- package/skills/global_config/makefile-generator/docs/optimization-guide.md +784 -0
- package/skills/global_config/makefile-generator/docs/patterns-guide.md +642 -0
- package/skills/global_config/makefile-generator/docs/security-guide.md +361 -0
- package/skills/global_config/makefile-generator/docs/targets-guide.md +642 -0
- package/skills/global_config/makefile-generator/docs/variables-guide.md +596 -0
- package/skills/global_config/makefile-generator/scripts/add_standard_targets.sh +539 -0
- package/skills/global_config/makefile-generator/scripts/generate_makefile_template.sh +690 -0
- package/skills/global_config/makefile-generator/test/test_helper_scripts.sh +190 -0
- package/skills/global_config/makefile-validator/SKILL.md +244 -0
- package/skills/global_config/makefile-validator/docs/bake-tool.md +1000 -0
- package/skills/global_config/makefile-validator/docs/best-practices.md +858 -0
- package/skills/global_config/makefile-validator/docs/common-mistakes.md +944 -0
- package/skills/global_config/makefile-validator/examples/bad-makefile.mk +77 -0
- package/skills/global_config/makefile-validator/examples/good-makefile.mk +103 -0
- package/skills/global_config/makefile-validator/scripts/test_validate.sh +382 -0
- package/skills/global_config/makefile-validator/scripts/validate_makefile.sh +712 -0
- package/skills/global_config/{MCP_Manage → mcp-manage}/SKILL.md +3 -3
- package/skills/global_config/plan-canvas/SKILL.md +9 -2
- package/skills/global_config/plan-canvas/scripts/lib/plan-canvas/ui.js +10 -2
- package/skills/global_config/plan-canvas/scripts/plan-canvas.js +1 -1
- package/skills/global_config/read-the-damn-docs/SKILL.md +175 -0
- package/skills/global_config/requesting-code-review/SKILL.md +98 -0
- package/skills/global_config/requesting-code-review/code-reviewer.md +198 -0
- package/skills/global_config/using-git-worktrees/SKILL.md +170 -0
- package/skills/global_config/verification-before-completion/SKILL.md +123 -0
- package/skills/global_config/writing-plans/SKILL.md +126 -46
- package/skills/global_config/writing-plans-legacy/SKILL.md +152 -0
- package/.claude/CLAUDE.md +0 -12
- package/mcps/RhinoMCP/docs/content/docs/getting-started/gemini.md +0 -61
- /package/{GEMINI.md → RULES.md} +0 -0
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dockerfile-validator
|
|
3
|
+
description: Validate, lint, audit, or scan a Dockerfile for security and best practices.
|
|
4
|
+
category: engineering-method
|
|
5
|
+
source: cc-devops-skills
|
|
6
|
+
date_added: "2026-09-25"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Dockerfile Validator
|
|
10
|
+
|
|
11
|
+
Validate Dockerfiles with deterministic stages, clear severity reporting, and explicit fallbacks when tools or network access are constrained.
|
|
12
|
+
|
|
13
|
+
## Trigger Phrases
|
|
14
|
+
|
|
15
|
+
Use this skill when the user asks for tasks like:
|
|
16
|
+
- "validate this Dockerfile"
|
|
17
|
+
- "lint/check my Dockerfile"
|
|
18
|
+
- "security scan Dockerfile"
|
|
19
|
+
- "optimize Docker image size/build time"
|
|
20
|
+
- "review Dockerfile before merge"
|
|
21
|
+
- "find issues in Dockerfile.prod/Dockerfile.dev"
|
|
22
|
+
|
|
23
|
+
## Use / Do Not Use
|
|
24
|
+
|
|
25
|
+
Use this skill for:
|
|
26
|
+
- Syntax and lint validation
|
|
27
|
+
- Security and secrets checks
|
|
28
|
+
- Best-practice and performance review
|
|
29
|
+
- Dockerfile hardening before CI/CD or production
|
|
30
|
+
|
|
31
|
+
Do not use this skill for:
|
|
32
|
+
- Generating a new Dockerfile from scratch (use `dockerfile-generator`)
|
|
33
|
+
- Running containers, debugging runtime behavior, or image registry operations
|
|
34
|
+
|
|
35
|
+
## Local Files In This Skill
|
|
36
|
+
|
|
37
|
+
- Validator script: `scripts/dockerfile-validate.sh`
|
|
38
|
+
- References:
|
|
39
|
+
- `references/security_checklist.md`
|
|
40
|
+
- `references/optimization_guide.md`
|
|
41
|
+
- `references/docker_best_practices.md`
|
|
42
|
+
- Example Dockerfiles: `examples/*.Dockerfile`
|
|
43
|
+
|
|
44
|
+
## Deterministic Execution Flow (Required)
|
|
45
|
+
|
|
46
|
+
Run these steps in order. Do not skip steps unless a documented fallback branch applies.
|
|
47
|
+
|
|
48
|
+
### 1. Preflight and Path Setup
|
|
49
|
+
|
|
50
|
+
Assume repo root as working directory:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
cd /path/to/repo
|
|
54
|
+
SKILL_DIR="devops-skills-plugin/skills/dockerfile-validator"
|
|
55
|
+
TARGET_DOCKERFILE="Dockerfile" # replace when user provides a path
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Validate inputs before running tools:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
test -f "$SKILL_DIR/scripts/dockerfile-validate.sh"
|
|
62
|
+
test -f "$TARGET_DOCKERFILE"
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
If either check fails, stop and report the exact missing path.
|
|
66
|
+
|
|
67
|
+
### 2. Read the Target Dockerfile Explicitly
|
|
68
|
+
|
|
69
|
+
Use explicit file-read commands (not abstract "Read tool" wording):
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
sed -n '1,220p' "$TARGET_DOCKERFILE"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
If needed for long files:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
sed -n '220,440p' "$TARGET_DOCKERFILE"
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 3. Run Validation Script
|
|
82
|
+
|
|
83
|
+
Primary command:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
bash "$SKILL_DIR/scripts/dockerfile-validate.sh" "$TARGET_DOCKERFILE"
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Optional captured run for structured reporting:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
bash "$SKILL_DIR/scripts/dockerfile-validate.sh" "$TARGET_DOCKERFILE" | tee /tmp/dockerfile-validator.out
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### 4. Classify Findings by Severity (Standard)
|
|
96
|
+
|
|
97
|
+
Use this standard severity model:
|
|
98
|
+
|
|
99
|
+
- `Critical`
|
|
100
|
+
- Hardcoded secrets/credentials
|
|
101
|
+
- Explicit root runtime with high-risk context
|
|
102
|
+
- High-impact security policy failures
|
|
103
|
+
- `High`
|
|
104
|
+
- Checkov failures for container hardening
|
|
105
|
+
- hadolint errors likely to cause insecure/unreliable builds
|
|
106
|
+
- Missing or unsafe runtime-user posture (`USER`)
|
|
107
|
+
- `Medium`
|
|
108
|
+
- `:latest` image tags, missing pinning, cache-cleanup misses
|
|
109
|
+
- Build cache inefficiency and layered install anti-patterns
|
|
110
|
+
- `Low`
|
|
111
|
+
- Style/info guidance and non-blocking optimization suggestions
|
|
112
|
+
|
|
113
|
+
### 5. No-Issue Fast Path (Required)
|
|
114
|
+
|
|
115
|
+
If validation has no actionable findings:
|
|
116
|
+
- Return a concise pass summary.
|
|
117
|
+
- Do **not** open reference files.
|
|
118
|
+
- Do **not** generate fix diffs.
|
|
119
|
+
|
|
120
|
+
Use fast path when all are true:
|
|
121
|
+
- Script reports overall pass.
|
|
122
|
+
- No security failures.
|
|
123
|
+
- No error/warning findings requiring user action.
|
|
124
|
+
|
|
125
|
+
### 6. Reference Loading Rules (Only When Findings Exist)
|
|
126
|
+
|
|
127
|
+
Only read references that match actual findings. Read each required file once.
|
|
128
|
+
|
|
129
|
+
Issue-to-reference mapping:
|
|
130
|
+
|
|
131
|
+
| Issue category | Trigger examples | Read this file |
|
|
132
|
+
|---|---|---|
|
|
133
|
+
| Secrets, root user, exposed sensitive ports, hardening gaps | `CKV_DOCKER_*`, hardcoded token/password, root runtime | `references/security_checklist.md` |
|
|
134
|
+
| Image size, layer count, multi-stage opportunities, cache efficiency, `.dockerignore` gaps | too many `RUN`, single-stage with build deps, cache misses | `references/optimization_guide.md` |
|
|
135
|
+
| Tag pinning, instruction usage, COPY vs ADD, WORKDIR/CMD/ENTRYPOINT conventions | `:latest`, unpinned packages, instruction-level best practices | `references/docker_best_practices.md` |
|
|
136
|
+
|
|
137
|
+
Explicit read commands:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
sed -n '1,220p' "$SKILL_DIR/references/security_checklist.md"
|
|
141
|
+
sed -n '1,220p' "$SKILL_DIR/references/optimization_guide.md"
|
|
142
|
+
sed -n '1,220p' "$SKILL_DIR/references/docker_best_practices.md"
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
For targeted extraction:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
rg -n "USER|secrets|EXPOSE|HEALTHCHECK" "$SKILL_DIR/references/security_checklist.md"
|
|
149
|
+
rg -n "multi-stage|cache|layer|dockerignore" "$SKILL_DIR/references/optimization_guide.md"
|
|
150
|
+
rg -n "FROM|COPY|ADD|WORKDIR|CMD|ENTRYPOINT|latest" "$SKILL_DIR/references/docker_best_practices.md"
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### 7. Produce Standard Report Output
|
|
154
|
+
|
|
155
|
+
Use this template for every non-fast-path run:
|
|
156
|
+
|
|
157
|
+
```markdown
|
|
158
|
+
## Dockerfile Validation Report
|
|
159
|
+
- Target: <path>
|
|
160
|
+
- Command: `bash <skill-script> <target>`
|
|
161
|
+
- Overall result: PASS | FAIL | PARTIAL (fallback)
|
|
162
|
+
|
|
163
|
+
### Critical
|
|
164
|
+
- <issue or `None`>
|
|
165
|
+
|
|
166
|
+
### High
|
|
167
|
+
- <issue or `None`>
|
|
168
|
+
|
|
169
|
+
### Medium
|
|
170
|
+
- <issue or `None`>
|
|
171
|
+
|
|
172
|
+
### Low
|
|
173
|
+
- <issue or `None`>
|
|
174
|
+
|
|
175
|
+
### Recommended Fixes
|
|
176
|
+
- <specific code-level fix per actionable issue>
|
|
177
|
+
|
|
178
|
+
### References Used
|
|
179
|
+
- <list only files actually read>
|
|
180
|
+
|
|
181
|
+
### Fallbacks Used
|
|
182
|
+
- `None` or exact fallback branch + reason
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### 8. Offer Fix Application
|
|
186
|
+
|
|
187
|
+
After reporting:
|
|
188
|
+
- Ask whether to apply fixes.
|
|
189
|
+
- If user approves, patch the Dockerfile and rerun validation.
|
|
190
|
+
|
|
191
|
+
## Fallback Behavior (Explicit)
|
|
192
|
+
|
|
193
|
+
When the primary script cannot complete, use deterministic fallback branches and report them.
|
|
194
|
+
|
|
195
|
+
### Fallback A: Python/Tool Install Constraint
|
|
196
|
+
|
|
197
|
+
Condition:
|
|
198
|
+
- Script exits with tool-install failure (for example Python missing, package install blocked, or restricted environment).
|
|
199
|
+
|
|
200
|
+
Action:
|
|
201
|
+
1. Report primary failure and why.
|
|
202
|
+
2. Run manual minimum checks:
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
# Basic syntax signal (if Docker is available)
|
|
206
|
+
DOCKERFILE_DIR="$(dirname "$TARGET_DOCKERFILE")"
|
|
207
|
+
docker build --no-cache -f "$TARGET_DOCKERFILE" "$DOCKERFILE_DIR"
|
|
208
|
+
|
|
209
|
+
# High-value static checks
|
|
210
|
+
grep -nEi "^[[:space:]]*FROM[[:space:]]+.*:latest" "$TARGET_DOCKERFILE" || true
|
|
211
|
+
grep -nEi "^[[:space:]]*(ENV|ARG)[[:space:]].*(password|secret|token|api[_-]?key)[[:space:]]*=" "$TARGET_DOCKERFILE" || true
|
|
212
|
+
grep -nEi "^[[:space:]]*USER[[:space:]]+(root|0(:0)?)$" "$TARGET_DOCKERFILE" || true
|
|
213
|
+
grep -nEi "^[[:space:]]*HEALTHCHECK[[:space:]]+" "$TARGET_DOCKERFILE" || true
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
3. Classify output with `PARTIAL` result and clearly label skipped checks.
|
|
217
|
+
|
|
218
|
+
### Fallback B: hadolint Not Available but Docker Available
|
|
219
|
+
|
|
220
|
+
Use hadolint container image:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
docker run --rm -i hadolint/hadolint < "$TARGET_DOCKERFILE"
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Fallback C: No Docker, No hadolint/checkov
|
|
227
|
+
|
|
228
|
+
Run only manual regex-based checks (Fallback A step 2), clearly mark as `PARTIAL`, and state which scanners were skipped.
|
|
229
|
+
|
|
230
|
+
## Quick Command Set
|
|
231
|
+
|
|
232
|
+
### Validate one Dockerfile
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
cd /path/to/repo
|
|
236
|
+
bash devops-skills-plugin/skills/dockerfile-validator/scripts/dockerfile-validate.sh Dockerfile
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Validate alternate file
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
cd /path/to/repo
|
|
243
|
+
bash devops-skills-plugin/skills/dockerfile-validator/scripts/dockerfile-validate.sh Dockerfile.prod
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Validate skill examples
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
cd /path/to/repo/devops-skills-plugin/skills/dockerfile-validator
|
|
250
|
+
bash scripts/dockerfile-validate.sh examples/good-example.Dockerfile
|
|
251
|
+
bash scripts/dockerfile-validate.sh examples/security-issues.Dockerfile
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Run regression checks (CI entrypoint)
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
cd /path/to/repo
|
|
258
|
+
bash devops-skills-plugin/skills/dockerfile-validator/scripts/test_validate.sh
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Optional strict mode for CI environments that must enforce ShellCheck:
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
STRICT_SHELLCHECK=true bash devops-skills-plugin/skills/dockerfile-validator/scripts/test_validate.sh
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## Progressive Disclosure Rules
|
|
268
|
+
|
|
269
|
+
- Always read the target Dockerfile first.
|
|
270
|
+
- Do not read any reference files unless findings require them.
|
|
271
|
+
- Read only the matching reference file(s) from the issue-to-reference mapping.
|
|
272
|
+
- Do not reread the same reference unless new issue categories appear.
|
|
273
|
+
|
|
274
|
+
## Done Criteria
|
|
275
|
+
|
|
276
|
+
Consider this skill execution complete only when all conditions below are satisfied:
|
|
277
|
+
|
|
278
|
+
- Trigger matched a Dockerfile validation/lint/security/optimization request.
|
|
279
|
+
- Target Dockerfile path was explicitly verified.
|
|
280
|
+
- Validation command (or explicit fallback) was executed.
|
|
281
|
+
- Findings were reported using severity buckets (`Critical`, `High`, `Medium`, `Low`).
|
|
282
|
+
- Reference usage matched issue categories and was explicitly listed.
|
|
283
|
+
- No-issue fast path skipped unnecessary reference reads.
|
|
284
|
+
- If fixes were applied, validation was rerun and final status reported.
|
|
285
|
+
|
|
286
|
+
## Resources
|
|
287
|
+
|
|
288
|
+
- Script: `scripts/dockerfile-validate.sh`
|
|
289
|
+
- CI/regression entrypoint: `scripts/test_validate.sh`
|
|
290
|
+
- Security reference: `references/security_checklist.md`
|
|
291
|
+
- Optimization reference: `references/optimization_guide.md`
|
|
292
|
+
- Best-practices reference: `references/docker_best_practices.md`
|
|
293
|
+
- Examples: `examples/good-example.Dockerfile`, `examples/bad-example.Dockerfile`, `examples/security-issues.Dockerfile`, `examples/python-optimized.Dockerfile`, `examples/golang-distroless.Dockerfile`
|
|
294
|
+
|
|
295
|
+
## Source Links
|
|
296
|
+
|
|
297
|
+
- [Docker Build Best Practices](https://docs.docker.com/build/building/best-practices/)
|
|
298
|
+
- [Dockerfile Reference](https://docs.docker.com/reference/dockerfile/)
|
|
299
|
+
- [Checkov Dockerfile Scanning](https://www.checkov.io/7.Scan%20Examples/Dockerfile.html)
|
|
300
|
+
- [hadolint](https://github.com/hadolint/hadolint)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# VCS
|
|
2
|
+
.git
|
|
3
|
+
.gitignore
|
|
4
|
+
|
|
5
|
+
# Local environment and secrets
|
|
6
|
+
.env
|
|
7
|
+
.env.*
|
|
8
|
+
*.pem
|
|
9
|
+
*.key
|
|
10
|
+
|
|
11
|
+
# Build and dependency artifacts
|
|
12
|
+
node_modules/
|
|
13
|
+
dist/
|
|
14
|
+
build/
|
|
15
|
+
target/
|
|
16
|
+
venv/
|
|
17
|
+
.venv/
|
|
18
|
+
__pycache__/
|
|
19
|
+
*.pyc
|
|
20
|
+
|
|
21
|
+
# Logs and temp files
|
|
22
|
+
*.log
|
|
23
|
+
*.tmp
|
|
24
|
+
tmp/
|
|
25
|
+
|
|
26
|
+
# Tooling and editor files
|
|
27
|
+
.idea/
|
|
28
|
+
.vscode/
|
|
29
|
+
.DS_Store
|
|
30
|
+
|
|
31
|
+
# Docker-related files not needed in image
|
|
32
|
+
Dockerfile*
|
|
33
|
+
docker-compose*.yml
|
|
34
|
+
.dockerignore
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Bad Example - Demonstrates common mistakes and anti-patterns
|
|
2
|
+
# DO NOT USE THIS IN PRODUCTION
|
|
3
|
+
|
|
4
|
+
# Issue 1: Using :latest tag (unpredictable, not reproducible)
|
|
5
|
+
FROM ubuntu:latest
|
|
6
|
+
|
|
7
|
+
# Issue 2: Running as root (security risk)
|
|
8
|
+
# Issue 3: No WORKDIR set (unclear where commands run)
|
|
9
|
+
|
|
10
|
+
# Issue 4: Separate RUN commands (creates unnecessary layers)
|
|
11
|
+
RUN apt-get update
|
|
12
|
+
RUN apt-get install -y curl
|
|
13
|
+
RUN apt-get install -y vim
|
|
14
|
+
RUN apt-get install -y git
|
|
15
|
+
# Issue 5: No cache cleanup (increases image size)
|
|
16
|
+
|
|
17
|
+
# Issue 6: Using shell form instead of exec form
|
|
18
|
+
WORKDIR app
|
|
19
|
+
|
|
20
|
+
# Issue 7: Copying everything before installing dependencies (poor caching)
|
|
21
|
+
COPY . .
|
|
22
|
+
|
|
23
|
+
# Issue 8: No version pinning for packages
|
|
24
|
+
RUN pip install flask
|
|
25
|
+
|
|
26
|
+
# Issue 9: Potential secret exposure
|
|
27
|
+
ENV API_KEY=secret123
|
|
28
|
+
ENV PASSWORD=admin
|
|
29
|
+
|
|
30
|
+
# Issue 10: Exposing SSH port (security risk)
|
|
31
|
+
EXPOSE 22
|
|
32
|
+
EXPOSE 80
|
|
33
|
+
|
|
34
|
+
# Issue 11: No HEALTHCHECK defined
|
|
35
|
+
# Issue 12: No USER directive (runs as root)
|
|
36
|
+
# Issue 13: Shell form instead of exec form (poor signal handling)
|
|
37
|
+
CMD python app.py
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# syntax=docker/dockerfile:1
|
|
2
|
+
|
|
3
|
+
# Multi-stage Go Dockerfile with distroless runtime
|
|
4
|
+
# Demonstrates minimal attack surface and optimal size
|
|
5
|
+
|
|
6
|
+
# Build stage
|
|
7
|
+
FROM golang:1.21-alpine AS builder
|
|
8
|
+
|
|
9
|
+
# Install build dependencies
|
|
10
|
+
# hadolint ignore=DL3018
|
|
11
|
+
RUN apk add --no-cache git ca-certificates
|
|
12
|
+
|
|
13
|
+
WORKDIR /src
|
|
14
|
+
|
|
15
|
+
# Copy go mod files for dependency caching
|
|
16
|
+
COPY go.mod go.sum ./
|
|
17
|
+
RUN go mod download
|
|
18
|
+
|
|
19
|
+
# Copy source code
|
|
20
|
+
COPY . .
|
|
21
|
+
|
|
22
|
+
# Build static binary
|
|
23
|
+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
|
|
24
|
+
-ldflags='-w -s -extldflags "-static"' \
|
|
25
|
+
-a \
|
|
26
|
+
-o /app/server \
|
|
27
|
+
./cmd/server
|
|
28
|
+
|
|
29
|
+
# Runtime stage - distroless (minimal, secure)
|
|
30
|
+
# checkov:skip=CKV_DOCKER_2:Distroless runtime uses external liveness/readiness probes instead of in-container HEALTHCHECK.
|
|
31
|
+
# checkov:skip=CKV_DOCKER_3:distroless:nonroot image already runs as a non-root user.
|
|
32
|
+
FROM gcr.io/distroless/static-debian11:nonroot
|
|
33
|
+
|
|
34
|
+
# Copy CA certificates for HTTPS
|
|
35
|
+
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
|
36
|
+
|
|
37
|
+
# Copy binary from builder
|
|
38
|
+
COPY --from=builder /app/server /server
|
|
39
|
+
|
|
40
|
+
# Expose port
|
|
41
|
+
EXPOSE 8080
|
|
42
|
+
|
|
43
|
+
# Already running as non-root (distroless:nonroot)
|
|
44
|
+
# User is automatically set to uid:gid 65532:65532
|
|
45
|
+
|
|
46
|
+
# Health check (limited in distroless, use external checks)
|
|
47
|
+
# HEALTHCHECK not available in distroless
|
|
48
|
+
|
|
49
|
+
# Exec form entrypoint
|
|
50
|
+
ENTRYPOINT ["/server"]
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# syntax=docker/dockerfile:1
|
|
2
|
+
|
|
3
|
+
# Example of a well-structured, secure, and optimized Dockerfile
|
|
4
|
+
# This demonstrates Docker best practices for a Node.js application
|
|
5
|
+
|
|
6
|
+
# Build stage - includes all build dependencies
|
|
7
|
+
FROM node:21-alpine AS builder
|
|
8
|
+
|
|
9
|
+
# Set working directory
|
|
10
|
+
WORKDIR /app
|
|
11
|
+
|
|
12
|
+
# Copy package files first for better layer caching
|
|
13
|
+
COPY package.json package-lock.json ./
|
|
14
|
+
|
|
15
|
+
# Install dependencies with cache mount for faster rebuilds
|
|
16
|
+
RUN --mount=type=cache,target=/root/.cache/npm \
|
|
17
|
+
npm ci --only=production
|
|
18
|
+
|
|
19
|
+
# Copy application source
|
|
20
|
+
COPY . .
|
|
21
|
+
|
|
22
|
+
# Build the application (if needed)
|
|
23
|
+
RUN npm run build
|
|
24
|
+
|
|
25
|
+
# Runtime stage - minimal image with only necessary runtime dependencies
|
|
26
|
+
FROM node:21-alpine AS runtime
|
|
27
|
+
|
|
28
|
+
# Create non-root user
|
|
29
|
+
RUN addgroup -g 1001 -S nodejs && \
|
|
30
|
+
adduser -S nodejs -u 1001
|
|
31
|
+
|
|
32
|
+
# Set working directory
|
|
33
|
+
WORKDIR /app
|
|
34
|
+
|
|
35
|
+
# Copy built application and dependencies from builder stage
|
|
36
|
+
COPY --from=builder --chown=nodejs:nodejs /app/node_modules ./node_modules
|
|
37
|
+
COPY --from=builder --chown=nodejs:nodejs /app/dist ./dist
|
|
38
|
+
COPY --from=builder --chown=nodejs:nodejs /app/package.json ./
|
|
39
|
+
|
|
40
|
+
# Switch to non-root user
|
|
41
|
+
USER nodejs
|
|
42
|
+
|
|
43
|
+
# Expose application port
|
|
44
|
+
EXPOSE 3000
|
|
45
|
+
|
|
46
|
+
# Add healthcheck for container monitoring
|
|
47
|
+
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
48
|
+
CMD node -e "require('http').get('http://localhost:3000/health', (res) => { process.exit(res.statusCode === 200 ? 0 : 1); })"
|
|
49
|
+
|
|
50
|
+
# Use exec form for better signal handling
|
|
51
|
+
ENTRYPOINT ["node"]
|
|
52
|
+
CMD ["dist/index.js"]
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# syntax=docker/dockerfile:1
|
|
2
|
+
|
|
3
|
+
# Multi-stage Python Dockerfile with best practices
|
|
4
|
+
# Optimized for size and security
|
|
5
|
+
|
|
6
|
+
# Build stage
|
|
7
|
+
FROM python:3.12-slim AS builder
|
|
8
|
+
|
|
9
|
+
WORKDIR /app
|
|
10
|
+
|
|
11
|
+
# Install build dependencies
|
|
12
|
+
# hadolint ignore=DL3008
|
|
13
|
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
14
|
+
gcc \
|
|
15
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
16
|
+
|
|
17
|
+
# Copy requirements first for layer caching
|
|
18
|
+
COPY requirements.txt ./
|
|
19
|
+
|
|
20
|
+
# Install Python dependencies with cache mount
|
|
21
|
+
RUN --mount=type=cache,target=/root/.cache/pip \
|
|
22
|
+
pip install --user --no-cache-dir -r requirements.txt
|
|
23
|
+
|
|
24
|
+
# Runtime stage - minimal
|
|
25
|
+
FROM python:3.12-slim AS runtime
|
|
26
|
+
|
|
27
|
+
# Create non-root user
|
|
28
|
+
RUN groupadd -r app && useradd -r -g app app
|
|
29
|
+
|
|
30
|
+
WORKDIR /app
|
|
31
|
+
|
|
32
|
+
# Copy Python packages from builder
|
|
33
|
+
COPY --from=builder /root/.local /root/.local
|
|
34
|
+
|
|
35
|
+
# Copy application code
|
|
36
|
+
COPY --chown=app:app . .
|
|
37
|
+
|
|
38
|
+
# Add local bin to PATH
|
|
39
|
+
ENV PATH=/root/.local/bin:$PATH
|
|
40
|
+
|
|
41
|
+
# Switch to non-root user
|
|
42
|
+
USER app
|
|
43
|
+
|
|
44
|
+
# Expose application port
|
|
45
|
+
EXPOSE 8000
|
|
46
|
+
|
|
47
|
+
# Health check
|
|
48
|
+
HEALTHCHECK --interval=30s --timeout=3s \
|
|
49
|
+
CMD python -c "import requests; requests.get('http://localhost:8000/health')" || exit 1
|
|
50
|
+
|
|
51
|
+
# Use exec form
|
|
52
|
+
ENTRYPOINT ["python"]
|
|
53
|
+
CMD ["-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Dockerfile with Intentional Security Issues
|
|
2
|
+
# FOR TESTING VALIDATION ONLY - DO NOT USE IN PRODUCTION
|
|
3
|
+
|
|
4
|
+
# Issue: Using :latest tag
|
|
5
|
+
FROM python:latest
|
|
6
|
+
|
|
7
|
+
# Issue: Running as root user throughout
|
|
8
|
+
|
|
9
|
+
WORKDIR /app
|
|
10
|
+
|
|
11
|
+
# Issue: Hardcoded secrets
|
|
12
|
+
ENV DATABASE_PASSWORD=super_secret_password
|
|
13
|
+
ENV API_TOKEN=abc123xyz789
|
|
14
|
+
ARG SECRET_KEY=my_secret_key
|
|
15
|
+
|
|
16
|
+
# Issue: Installing unnecessary packages, no version pinning
|
|
17
|
+
RUN apt-get update && apt-get install -y \
|
|
18
|
+
openssh-server \
|
|
19
|
+
telnet \
|
|
20
|
+
ftp \
|
|
21
|
+
vim \
|
|
22
|
+
nano
|
|
23
|
+
|
|
24
|
+
# Issue: No cache cleanup
|
|
25
|
+
# (apt lists remain, increasing image size)
|
|
26
|
+
|
|
27
|
+
# Issue: Using ADD instead of COPY
|
|
28
|
+
ADD . /app
|
|
29
|
+
|
|
30
|
+
# Issue: Installing packages without version pins
|
|
31
|
+
RUN pip install flask requests sqlalchemy
|
|
32
|
+
|
|
33
|
+
# Issue: Exposing SSH port
|
|
34
|
+
EXPOSE 22
|
|
35
|
+
EXPOSE 23
|
|
36
|
+
EXPOSE 5000
|
|
37
|
+
|
|
38
|
+
# Issue: No USER directive - will run as root
|
|
39
|
+
# Issue: No HEALTHCHECK
|
|
40
|
+
|
|
41
|
+
# Issue: Shell form (doesn't handle signals properly)
|
|
42
|
+
CMD python app.py
|