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