ma-agents 2.20.3 → 2.22.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.
Files changed (149) hide show
  1. package/.opencode/skills/.ma-agents.json +241 -0
  2. package/.opencode/skills/MANIFEST.yaml +254 -0
  3. package/.opencode/skills/ai-audit-trail/SKILL.md +23 -0
  4. package/.opencode/skills/auto-bug-detection/SKILL.md +169 -0
  5. package/.opencode/skills/cmake-best-practices/SKILL.md +64 -0
  6. package/.opencode/skills/cmake-best-practices/examples/cmake.md +59 -0
  7. package/.opencode/skills/code-documentation/SKILL.md +57 -0
  8. package/.opencode/skills/code-documentation/examples/cpp.md +29 -0
  9. package/.opencode/skills/code-documentation/examples/csharp.md +28 -0
  10. package/.opencode/skills/code-documentation/examples/javascript_typescript.md +28 -0
  11. package/.opencode/skills/code-documentation/examples/python.md +57 -0
  12. package/.opencode/skills/code-review/SKILL.md +43 -0
  13. package/.opencode/skills/commit-message/SKILL.md +79 -0
  14. package/.opencode/skills/cpp-best-practices/SKILL.md +234 -0
  15. package/.opencode/skills/cpp-best-practices/examples/modern-idioms.md +189 -0
  16. package/.opencode/skills/cpp-best-practices/examples/naming-and-organization.md +102 -0
  17. package/.opencode/skills/cpp-concurrency-safety/SKILL.md +60 -0
  18. package/.opencode/skills/cpp-concurrency-safety/examples/concurrency.md +73 -0
  19. package/.opencode/skills/cpp-const-correctness/SKILL.md +63 -0
  20. package/.opencode/skills/cpp-const-correctness/examples/const_correctness.md +54 -0
  21. package/.opencode/skills/cpp-memory-handling/SKILL.md +42 -0
  22. package/.opencode/skills/cpp-memory-handling/examples/modern-cpp.md +49 -0
  23. package/.opencode/skills/cpp-memory-handling/examples/smart-pointers.md +46 -0
  24. package/.opencode/skills/cpp-modern-composition/SKILL.md +64 -0
  25. package/.opencode/skills/cpp-modern-composition/examples/composition.md +51 -0
  26. package/.opencode/skills/cpp-robust-interfaces/SKILL.md +55 -0
  27. package/.opencode/skills/cpp-robust-interfaces/examples/interfaces.md +56 -0
  28. package/.opencode/skills/create-hardened-docker-skill/SKILL.md +637 -0
  29. package/.opencode/skills/create-hardened-docker-skill/scripts/create-all.sh +489 -0
  30. package/.opencode/skills/csharp-best-practices/SKILL.md +278 -0
  31. package/.opencode/skills/docker-hardening-verification/SKILL.md +28 -0
  32. package/.opencode/skills/docker-hardening-verification/scripts/verify-hardening.sh +39 -0
  33. package/.opencode/skills/docker-image-signing/SKILL.md +28 -0
  34. package/.opencode/skills/docker-image-signing/scripts/sign-image.sh +33 -0
  35. package/.opencode/skills/document-revision-history/SKILL.md +104 -0
  36. package/.opencode/skills/git-workflow-skill/SKILL.md +194 -0
  37. package/.opencode/skills/git-workflow-skill/hooks/commit-msg +61 -0
  38. package/.opencode/skills/git-workflow-skill/hooks/pre-commit +38 -0
  39. package/.opencode/skills/git-workflow-skill/hooks/prepare-commit-msg +56 -0
  40. package/.opencode/skills/git-workflow-skill/scripts/finish-feature.sh +192 -0
  41. package/.opencode/skills/git-workflow-skill/scripts/install-hooks.sh +55 -0
  42. package/.opencode/skills/git-workflow-skill/scripts/start-feature.sh +110 -0
  43. package/.opencode/skills/git-workflow-skill/scripts/validate-workflow.sh +229 -0
  44. package/.opencode/skills/js-ts-dependency-mgmt/SKILL.md +49 -0
  45. package/.opencode/skills/js-ts-dependency-mgmt/examples/dependency_mgmt.md +60 -0
  46. package/.opencode/skills/js-ts-security-skill/SKILL.md +64 -0
  47. package/.opencode/skills/js-ts-security-skill/scripts/verify-security.sh +136 -0
  48. package/.opencode/skills/logging-best-practices/SKILL.md +50 -0
  49. package/.opencode/skills/logging-best-practices/examples/cpp.md +36 -0
  50. package/.opencode/skills/logging-best-practices/examples/csharp.md +49 -0
  51. package/.opencode/skills/logging-best-practices/examples/javascript.md +77 -0
  52. package/.opencode/skills/logging-best-practices/examples/python.md +57 -0
  53. package/.opencode/skills/logging-best-practices/references/logging-standards.md +29 -0
  54. package/.opencode/skills/open-presentation/SKILL.md +35 -0
  55. package/.opencode/skills/opentelemetry-best-practices/SKILL.md +34 -0
  56. package/.opencode/skills/opentelemetry-best-practices/examples/go.md +32 -0
  57. package/.opencode/skills/opentelemetry-best-practices/examples/javascript.md +58 -0
  58. package/.opencode/skills/opentelemetry-best-practices/examples/python.md +37 -0
  59. package/.opencode/skills/opentelemetry-best-practices/references/otel-standards.md +37 -0
  60. package/.opencode/skills/python-best-practices/SKILL.md +385 -0
  61. package/.opencode/skills/python-dependency-mgmt/SKILL.md +42 -0
  62. package/.opencode/skills/python-dependency-mgmt/examples/dependency_mgmt.md +67 -0
  63. package/.opencode/skills/python-security-skill/SKILL.md +56 -0
  64. package/.opencode/skills/python-security-skill/examples/security.md +56 -0
  65. package/.opencode/skills/self-signed-cert/SKILL.md +42 -0
  66. package/.opencode/skills/self-signed-cert/scripts/generate-cert.ps1 +45 -0
  67. package/.opencode/skills/self-signed-cert/scripts/generate-cert.sh +43 -0
  68. package/.opencode/skills/skill-creator/SKILL.md +196 -0
  69. package/.opencode/skills/skill-creator/references/output-patterns.md +82 -0
  70. package/.opencode/skills/skill-creator/references/workflows.md +28 -0
  71. package/.opencode/skills/skill-creator/scripts/init_skill.py +208 -0
  72. package/.opencode/skills/skill-creator/scripts/package_skill.py +99 -0
  73. package/.opencode/skills/skill-creator/scripts/quick_validate.py +113 -0
  74. package/.opencode/skills/story-status-lookup/SKILL.md +78 -0
  75. package/.opencode/skills/test-accompanied-development/SKILL.md +50 -0
  76. package/.opencode/skills/test-generator/SKILL.md +65 -0
  77. package/.opencode/skills/vercel-react-best-practices/SKILL.md +109 -0
  78. package/.opencode/skills/verify-hardened-docker-skill/SKILL.md +442 -0
  79. package/.opencode/skills/verify-hardened-docker-skill/scripts/verify-docker-hardening.sh +439 -0
  80. package/AiAudit.md +5 -0
  81. package/QUICK_START.md +11 -5
  82. package/README.md +52 -1
  83. package/bin/cli.js +31 -4
  84. package/docs/BMAD_AI_Development_Training.pptx +0 -0
  85. package/docs/technical-notes/context-persistence-research.md +434 -0
  86. package/docs/technical-notes/enforcement-hooks-research.md +415 -0
  87. package/lib/agents.js +34 -0
  88. package/lib/bmad-extension/agents/bmm-architect.customize.yaml +5 -0
  89. package/lib/bmad-extension/agents/bmm-bmad-master.customize.yaml +5 -0
  90. package/lib/bmad-extension/agents/bmm-cyber.customize.yaml +30 -0
  91. package/lib/bmad-extension/agents/bmm-dev.customize.yaml +5 -0
  92. package/lib/bmad-extension/agents/bmm-devops.customize.yaml +30 -0
  93. package/lib/bmad-extension/agents/bmm-mil498.customize.yaml +42 -0
  94. package/lib/bmad-extension/agents/bmm-pm.customize.yaml +5 -0
  95. package/lib/bmad-extension/agents/bmm-qa.customize.yaml +5 -0
  96. package/lib/bmad-extension/agents/bmm-sm.customize.yaml +5 -0
  97. package/lib/bmad-extension/agents/bmm-sre.customize.yaml +30 -0
  98. package/lib/bmad-extension/agents/bmm-tech-writer.customize.yaml +5 -0
  99. package/lib/bmad-extension/agents/bmm-ux-designer.customize.yaml +5 -0
  100. package/lib/bmad-extension/module-help.csv +7 -0
  101. package/lib/bmad-extension/module.yaml +3 -0
  102. package/lib/bmad-extension/workflows/add-sprint/workflow.md +112 -0
  103. package/lib/bmad-extension/workflows/add-to-sprint/workflow.md +206 -0
  104. package/lib/bmad-extension/workflows/create-bug-story/workflow.md +186 -0
  105. package/lib/bmad-extension/workflows/modify-sprint/workflow.md +250 -0
  106. package/lib/bmad-extension/workflows/project-context-expansion/workflow.md +229 -0
  107. package/lib/bmad-extension/workflows/sprint-status-view/workflow.md +193 -0
  108. package/lib/bmad.js +168 -36
  109. package/lib/hooks/claude-code/verify-manifest.js +56 -0
  110. package/lib/installer.js +282 -1
  111. package/lib/methodology/BMAD_AI_Development_Training.pptx +0 -0
  112. package/lib/methodology/version.json +7 -0
  113. package/lib/skill-authoring.js +732 -0
  114. package/lib/templates/project-context.template.md +47 -0
  115. package/opencode.json +8 -0
  116. package/package.json +2 -2
  117. package/skills/auto-bug-detection/SKILL.md +165 -0
  118. package/skills/auto-bug-detection/skill.json +8 -0
  119. package/skills/code-review/SKILL.md +40 -0
  120. package/skills/cpp-best-practices/SKILL.md +230 -0
  121. package/skills/cpp-best-practices/examples/modern-idioms.md +189 -0
  122. package/skills/cpp-best-practices/examples/naming-and-organization.md +102 -0
  123. package/skills/cpp-best-practices/skill.json +25 -0
  124. package/skills/csharp-best-practices/SKILL.md +274 -0
  125. package/skills/csharp-best-practices/skill.json +23 -0
  126. package/skills/git-workflow-skill/skill.json +1 -1
  127. package/skills/open-presentation/SKILL.md +31 -0
  128. package/skills/open-presentation/skill.json +11 -0
  129. package/skills/python-best-practices/SKILL.md +381 -0
  130. package/skills/python-best-practices/skill.json +26 -0
  131. package/skills/story-status-lookup/SKILL.md +74 -0
  132. package/skills/story-status-lookup/skill.json +8 -0
  133. package/test/agent-injection-strategy.test.js +13 -7
  134. package/test/bmad-extension.test.js +237 -0
  135. package/test/bmad-output-policy.test.js +119 -0
  136. package/test/build-bmad-args.test.js +361 -0
  137. package/test/create-agent.test.js +232 -0
  138. package/test/enforcement-hooks.test.js +324 -0
  139. package/test/generate-project-context.test.js +337 -0
  140. package/test/integration-verification.test.js +402 -0
  141. package/test/opencode-agent.test.js +150 -0
  142. package/test/opencode-json-error.test.js +260 -0
  143. package/test/opencode-json-injection.test.js +256 -0
  144. package/test/opencode-json-merge.test.js +299 -0
  145. package/test/skill-authoring.test.js +272 -0
  146. package/test/skill-customize-agent.test.js +253 -0
  147. package/test/skill-mandatory.test.js +235 -0
  148. package/test/skill-validation.test.js +378 -0
  149. package/test/yes-flag.test.js +1 -1
@@ -0,0 +1,442 @@
1
+ ---
2
+ name: Verify Hardened Docker
3
+ description: Comprehensive security verification for Docker configurations against CIS, OWASP, and NIST standards
4
+ ---
5
+ # Verify Hardened Docker
6
+
7
+ ## Overview
8
+
9
+ This skill performs comprehensive security verification of Docker configurations to ensure compliance with industry standards:
10
+ - **CIS Docker Benchmark v1.6.0**
11
+ - **OWASP Docker Security Cheat Sheet**
12
+ - **NIST Application Container Security Guide (SP 800-190)**
13
+
14
+ ## Bundled Tools
15
+
16
+ ### Scripts (scripts/)
17
+ | Script | Purpose |
18
+ |--------|---------|
19
+ | `verify-docker-hardening.sh` | Complete security verification suite |
20
+ | `scan-vulnerabilities.sh` | Trivy vulnerability scanning |
21
+ | `scan-secrets.sh` | Secret leakage detection |
22
+ | `check-runtime-security.sh` | Runtime security validation |
23
+
24
+ ---
25
+
26
+ ## What Gets Verified
27
+
28
+ ### Image Security
29
+ - [ ] Specific version tags (not :latest or unversioned)
30
+ - [ ] Minimal base images (Alpine preferred)
31
+ - [ ] Non-root user execution (USER directive)
32
+ - [ ] Read-only file permissions for static content
33
+ - [ ] No leaked secrets in image layers
34
+ - [ ] No hardcoded credentials
35
+ - [ ] Build cache cleanup
36
+ - [ ] Unnecessary packages removed
37
+ - [ ] HEALTHCHECK instruction present
38
+
39
+ ### Dockerfile Hardening
40
+ - [ ] Multi-stage build pattern
41
+ - [ ] Non-root user creation and usage
42
+ - [ ] Correct file ownership (chown)
43
+ - [ ] Read-only permissions (chmod 444 for static files)
44
+ - [ ] No sensitive data in ENV or ARG
45
+ - [ ] Proper WORKDIR usage
46
+ - [ ] Minimal layer count
47
+ - [ ] Build-time secret handling (BuildKit mounts)
48
+
49
+ ### docker-compose.yml Security
50
+ - [ ] Read-only root filesystem (read_only: true)
51
+ - [ ] Tmpfs mounts for writable directories
52
+ - [ ] Capability dropping (cap_drop: ALL)
53
+ - [ ] Minimal capability additions
54
+ - [ ] No-new-privileges enabled
55
+ - [ ] Resource limits (memory, CPU)
56
+ - [ ] Custom network isolation
57
+ - [ ] Health check configuration
58
+ - [ ] Restart policy set
59
+ - [ ] No privileged mode
60
+
61
+ ### Runtime Security
62
+ - [ ] Container runs as non-root user
63
+ - [ ] Root filesystem is read-only
64
+ - [ ] Tmpfs mounts are writable
65
+ - [ ] No privilege escalation possible
66
+ - [ ] Resource limits enforced
67
+ - [ ] Health checks passing
68
+ - [ ] No unnecessary capabilities
69
+ - [ ] Security options active
70
+
71
+ ### Network Security (nginx)
72
+ - [ ] Nginx version hidden (server_tokens off)
73
+ - [ ] TLS 1.2+ only
74
+ - [ ] Strong cipher suites
75
+ - [ ] HSTS header present
76
+ - [ ] CSP headers configured
77
+ - [ ] Security headers (X-Frame-Options, X-Content-Type-Options)
78
+ - [ ] Non-privileged ports (8080/8443) OR CAP_NET_BIND_SERVICE
79
+
80
+ ### Secrets Management
81
+ - [ ] .env in .gitignore
82
+ - [ ] .env.example committed (template only)
83
+ - [ ] No hardcoded secrets in Dockerfile
84
+ - [ ] No secrets in environment variables
85
+ - [ ] BuildKit secret mounts used (if applicable)
86
+ - [ ] Secrets mounted read-only
87
+ - [ ] No secrets in image history
88
+ - [ ] Secret scanning passed
89
+
90
+ ### Vulnerability Scanning
91
+ - [ ] No CRITICAL vulnerabilities
92
+ - [ ] No HIGH vulnerabilities
93
+ - [ ] No leaked secrets detected
94
+ - [ ] Base image is up-to-date
95
+ - [ ] All dependencies scanned
96
+
97
+ ---
98
+
99
+ ## Usage
100
+
101
+ ### Quick Verification
102
+
103
+ Run the complete verification suite:
104
+
105
+ ```bash
106
+ ./scripts/verify-docker-hardening.sh [image-name]
107
+ ```
108
+
109
+ **Example:**
110
+ ```bash
111
+ ./scripts/verify-docker-hardening.sh contacts-app
112
+ ```
113
+
114
+ ### Step-by-Step Verification
115
+
116
+ #### 1. Verify Dockerfile
117
+
118
+ ```bash
119
+ # Check for basic security issues
120
+ grep -E "^FROM.*:latest|^USER root|^ENV.*SECRET|^ARG.*PASSWORD" Dockerfile && echo "⚠️ Security issues found" || echo "✅ Basic checks passed"
121
+
122
+ # Verify specific version tags
123
+ grep -E "^FROM.*:[0-9]+\.[0-9]+\.[0-9]+" Dockerfile && echo "✅ Specific version tags" || echo "❌ Missing specific versions"
124
+
125
+ # Verify non-root user
126
+ grep -E "^USER [^r]" Dockerfile && echo "✅ Non-root user set" || echo "❌ Running as root"
127
+
128
+ # Verify HEALTHCHECK
129
+ grep "^HEALTHCHECK" Dockerfile && echo "✅ Health check present" || echo "❌ Missing HEALTHCHECK"
130
+ ```
131
+
132
+ #### 2. Scan for Vulnerabilities
133
+
134
+ ```bash
135
+ # Install trivy if not already installed
136
+ # macOS: brew install aquasecurity/trivy/trivy
137
+ # Linux: apt-get install trivy
138
+ # Windows: choco install trivy
139
+
140
+ # Scan image for vulnerabilities
141
+ trivy image --severity HIGH,CRITICAL [image-name]
142
+
143
+ # Fail on HIGH or CRITICAL
144
+ trivy image --severity HIGH,CRITICAL --exit-code 1 [image-name]
145
+ ```
146
+
147
+ #### 3. Scan for Leaked Secrets
148
+
149
+ ```bash
150
+ # Scan for secrets in image
151
+ trivy image --scanners secret [image-name]
152
+
153
+ # Check image history for secrets
154
+ docker history [image-name] --no-trunc | grep -iE "secret|password|key|token|api_key"
155
+
156
+ # Verify .env not in image
157
+ docker run --rm [image-name] ls -la / | grep .env || echo "✅ .env not found in image"
158
+
159
+ # Verify no hardcoded secrets
160
+ docker run --rm [image-name] env | grep -iE "client_id|client_secret|api_key" || echo "✅ No hardcoded secrets"
161
+ ```
162
+
163
+ #### 4. Verify docker-compose.yml
164
+
165
+ ```bash
166
+ # Check for security options
167
+ grep "read_only: true" docker-compose.yml && echo "✅ Read-only filesystem"
168
+ grep "no-new-privileges:true" docker-compose.yml && echo "✅ No new privileges"
169
+ grep "cap_drop:" docker-compose.yml && echo "✅ Capabilities dropped"
170
+ grep -A 5 "resources:" docker-compose.yml | grep "memory:" && echo "✅ Memory limits set"
171
+ grep -A 5 "resources:" docker-compose.yml | grep "cpus:" && echo "✅ CPU limits set"
172
+ grep "tmpfs:" docker-compose.yml && echo "✅ Tmpfs mounts configured"
173
+ ```
174
+
175
+ #### 5. Runtime Security Verification
176
+
177
+ Build and run the container first:
178
+ ```bash
179
+ docker-compose up -d
180
+ ```
181
+
182
+ Then verify:
183
+
184
+ ```bash
185
+ # Verify container runs as non-root
186
+ docker exec [container-name] whoami
187
+ # Expected output: nginx (or other non-root user)
188
+
189
+ # Verify read-only filesystem
190
+ docker exec [container-name] touch /test
191
+ # Expected: Permission denied (read-only filesystem)
192
+
193
+ # Verify tmpfs is writable
194
+ docker exec [container-name] touch /tmp/test
195
+ # Expected: Success
196
+
197
+ # Verify user ID is not 0 (root)
198
+ docker exec [container-name] id
199
+ # Expected: uid=101(nginx) or similar (not uid=0)
200
+
201
+ # Verify capabilities
202
+ docker inspect [container-name] | jq '.[0].HostConfig.CapDrop'
203
+ # Expected: ["ALL"] or similar
204
+
205
+ # Verify resource limits
206
+ docker stats [container-name] --no-stream
207
+ # Expected: Memory usage < configured limit
208
+
209
+ # Verify health status
210
+ docker ps --filter "name=[container-name]" --format "{{.Status}}"
211
+ # Expected: "Up ... (healthy)"
212
+ ```
213
+
214
+ #### 6. Network Security (nginx)
215
+
216
+ ```bash
217
+ # Verify nginx version is hidden
218
+ curl -I http://localhost | grep Server
219
+ # Expected: Server: nginx (no version number)
220
+
221
+ # Verify security headers present
222
+ curl -I https://localhost | grep -E "Content-Security-Policy|X-Frame-Options|X-Content-Type-Options|Strict-Transport-Security"
223
+
224
+ # Verify gzip compression
225
+ curl -H "Accept-Encoding: gzip" -I http://localhost | grep "Content-Encoding: gzip"
226
+ ```
227
+
228
+ #### 7. Verify .dockerignore
229
+
230
+ ```bash
231
+ # Check .dockerignore exists
232
+ test -f .dockerignore && echo "✅ .dockerignore exists" || echo "❌ Missing .dockerignore"
233
+
234
+ # Verify critical exclusions
235
+ grep -E "^\.env$|^node_modules/|^\.git/" .dockerignore && echo "✅ Critical exclusions present"
236
+ ```
237
+
238
+ ---
239
+
240
+ ## Automated Verification Script
241
+
242
+ The `verify-docker-hardening.sh` script performs all checks automatically:
243
+
244
+ ```bash
245
+ #!/bin/bash
246
+ set -e
247
+
248
+ IMAGE_NAME="${1:-contacts-app}"
249
+ CONTAINER_NAME="${2:-contacts-app}"
250
+
251
+ echo "🔍 Docker Security Verification for: $IMAGE_NAME"
252
+ echo "================================================"
253
+
254
+ # 1. Dockerfile checks
255
+ echo "📄 Verifying Dockerfile..."
256
+ ./scripts/verify-dockerfile.sh
257
+
258
+ # 2. Vulnerability scanning
259
+ echo "🛡️ Scanning for vulnerabilities..."
260
+ ./scripts/scan-vulnerabilities.sh "$IMAGE_NAME"
261
+
262
+ # 3. Secret scanning
263
+ echo "🔐 Scanning for leaked secrets..."
264
+ ./scripts/scan-secrets.sh "$IMAGE_NAME"
265
+
266
+ # 4. docker-compose.yml checks
267
+ echo "🐳 Verifying docker-compose.yml..."
268
+ ./scripts/verify-compose.sh
269
+
270
+ # 5. Runtime security (if container is running)
271
+ if docker ps --filter "name=$CONTAINER_NAME" --format "{{.Names}}" | grep -q "^$CONTAINER_NAME$"; then
272
+ echo "🚀 Verifying runtime security..."
273
+ ./scripts/check-runtime-security.sh "$CONTAINER_NAME"
274
+ else
275
+ echo "⚠️ Container not running, skipping runtime checks"
276
+ echo " Run 'docker-compose up -d' to enable runtime verification"
277
+ fi
278
+
279
+ echo ""
280
+ echo "✅ Security verification complete!"
281
+ ```
282
+
283
+ ---
284
+
285
+ ## CIS Docker Benchmark Compliance
286
+
287
+ ### Critical CIS Controls
288
+
289
+ | CIS ID | Control | Verification |
290
+ |--------|---------|--------------|
291
+ | 4.1 | Create user for container | `grep "^USER" Dockerfile` |
292
+ | 4.3 | Verify file permissions | `docker exec ... find /usr/share/nginx/html -type f -perm /022` |
293
+ | 4.5 | Enable Content trust | `grep -E "FROM.*:[0-9]" Dockerfile` |
294
+ | 5.7 | Don't map privileged ports | Check ports are > 1024 or CAP_NET_BIND_SERVICE |
295
+ | 5.10 | Set memory limit | `grep "memory:" docker-compose.yml` |
296
+ | 5.11 | Set CPU priority | `grep "cpus:" docker-compose.yml` |
297
+ | 5.12 | Read-only root filesystem | `grep "read_only: true" docker-compose.yml` |
298
+ | 5.25 | No new privileges | `grep "no-new-privileges:true" docker-compose.yml` |
299
+
300
+ ### Verification Command
301
+
302
+ ```bash
303
+ # Run all CIS checks
304
+ grep "^USER [^r]" Dockerfile && echo "✅ CIS 4.1"
305
+ docker exec [container] find /usr/share/nginx/html -type f -perm /022 && echo "❌ CIS 4.3" || echo "✅ CIS 4.3"
306
+ grep -E "FROM.*:[0-9]" Dockerfile && echo "✅ CIS 4.5"
307
+ grep "read_only: true" docker-compose.yml && echo "✅ CIS 5.12"
308
+ grep "no-new-privileges:true" docker-compose.yml && echo "✅ CIS 5.25"
309
+ ```
310
+
311
+ ---
312
+
313
+ ## OWASP Compliance
314
+
315
+ | OWASP Control | Verification |
316
+ |---------------|--------------|
317
+ | Run as non-root | `docker exec ... whoami` → nginx |
318
+ | Minimal base image | `FROM *-alpine` in Dockerfile |
319
+ | Scan vulnerabilities | `trivy image ...` |
320
+ | Limit resources | `docker stats` |
321
+ | Read-only filesystem | `docker exec ... touch /test` → fails |
322
+ | Drop capabilities | `docker inspect ... \| jq '.[0].HostConfig.CapDrop'` |
323
+ | Security options | `grep security_opt docker-compose.yml` |
324
+ | Specific tags | No `:latest` in Dockerfile |
325
+
326
+ ---
327
+
328
+ ## Common Security Issues
329
+
330
+ ### Critical Issues (Fix Immediately)
331
+
332
+ 1. **Running as root**
333
+ - Detection: `docker exec [container] whoami` → root
334
+ - Fix: Add `USER nginx` to Dockerfile
335
+
336
+ 2. **Hardcoded secrets**
337
+ - Detection: `trivy image --scanners secret`
338
+ - Fix: Use BuildKit secrets or Docker Secrets
339
+
340
+ 3. **CRITICAL/HIGH vulnerabilities**
341
+ - Detection: `trivy image --severity CRITICAL,HIGH`
342
+ - Fix: Update base images and dependencies
343
+
344
+ 4. **Writable root filesystem**
345
+ - Detection: `docker exec [container] touch /test` → succeeds
346
+ - Fix: Add `read_only: true` to docker-compose.yml
347
+
348
+ 5. **No resource limits**
349
+ - Detection: No `memory:` or `cpus:` in docker-compose.yml
350
+ - Fix: Add resource limits under `deploy.resources`
351
+
352
+ ### Warning Issues (Should Fix)
353
+
354
+ 1. **Using :latest tag**
355
+ - Detection: `grep ":latest" Dockerfile`
356
+ - Fix: Use specific version tags
357
+
358
+ 2. **Nginx version exposed**
359
+ - Detection: `curl -I http://localhost | grep "Server: nginx/"`
360
+ - Fix: Add `server_tokens off;` to nginx.conf
361
+
362
+ 3. **Missing security headers**
363
+ - Detection: `curl -I https://localhost | grep CSP` → not found
364
+ - Fix: Add security headers to nginx.conf
365
+
366
+ 4. **No health check**
367
+ - Detection: `docker ps` → no (healthy) status
368
+ - Fix: Add HEALTHCHECK to Dockerfile
369
+
370
+ 5. **Large image size**
371
+ - Detection: `docker images | grep [image-name]` → > 100MB
372
+ - Fix: Use multi-stage builds, clean build cache
373
+
374
+ ---
375
+
376
+ ## Troubleshooting
377
+
378
+ ### "No such image" error
379
+
380
+ ```bash
381
+ # Build the image first
382
+ docker build -t [image-name] .
383
+ ```
384
+
385
+ ### "Container not running" warning
386
+
387
+ ```bash
388
+ # Start the container
389
+ docker-compose up -d
390
+
391
+ # Wait for health check
392
+ sleep 10
393
+
394
+ # Re-run verification
395
+ ./scripts/verify-docker-hardening.sh
396
+ ```
397
+
398
+ ### Trivy not installed
399
+
400
+ ```bash
401
+ # macOS
402
+ brew install aquasecurity/trivy/trivy
403
+
404
+ # Linux (Debian/Ubuntu)
405
+ wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add -
406
+ echo "deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/trivy.list
407
+ sudo apt-get update
408
+ sudo apt-get install trivy
409
+
410
+ # Windows
411
+ choco install trivy
412
+ ```
413
+
414
+ ### Permission denied errors
415
+
416
+ ```bash
417
+ # Make scripts executable
418
+ chmod +x scripts/*.sh
419
+ ```
420
+
421
+ ---
422
+
423
+ ## Exit Codes
424
+
425
+ | Code | Meaning |
426
+ |------|---------|
427
+ | 0 | All security checks passed |
428
+ | 1 | CRITICAL vulnerabilities found |
429
+ | 2 | Hardening checks failed |
430
+ | 3 | Secret leakage detected |
431
+ | 4 | Runtime security violations |
432
+ | 5 | Missing required files |
433
+
434
+ ---
435
+
436
+ ## References
437
+
438
+ - [CIS Docker Benchmark v1.6.0](https://www.cisecurity.org/benchmark/docker)
439
+ - [OWASP Docker Security Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Docker_Security_Cheat_Sheet.html)
440
+ - [NIST SP 800-190](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-190.pdf)
441
+ - [Docker Security Best Practices](https://docs.docker.com/develop/security-best-practices/)
442
+ - [Trivy Documentation](https://aquasecurity.github.io/trivy/)