- Create beginner/, intermediate/, advanced/ folders in PROJECTS/ - Move all existing projects to appropriate difficulty folders - Update all README.md links to reflect new structure - Update contributor links - Fix pyrightconfig.json trailing comma Projects organized: Beginner (6): simple-port-scanner, keylogger, caesar-cipher, dns-lookup, metadata-scrubber-tool, simple-vulnerability-scanner Intermediate (2): api-security-scanner, docker-security-audit Advanced (4): api-rate-limiter, encrypted-p2p-chat, bug-bounty-platform, Aenebris |
||
|---|---|---|
| .. | ||
| compose | ||
| containers | ||
| dockerfiles | ||
| README.md | ||
| TEST-SUMMARY.md | ||
README.md
Test Fixtures for Docker Security Audit
This directory contains test fixtures for integration testing of the docksec tool.
Directory Structure
testdata/
├── dockerfiles/ # Dockerfile test cases
├── compose/ # Docker Compose test cases
└── containers/ # Container inspect JSON samples
Dockerfiles
Bad Examples (Should Trigger Findings)
bad-secrets.Dockerfile
Expected Findings:
CRITICAL: AWS credentials hardcoded (AWS_SECRET_ACCESS_KEY)CRITICAL: GitHub token in environmentCRITICAL: Stripe secret keyCRITICAL: OpenAI API keyCRITICAL: Database URL with passwordHIGH: API_KEY, PASSWORD, JWT_SECRET in env varsCRITICAL: Private key content
Test Purpose: Verify secret detection in ENV directives and RUN commands
bad-root-user.Dockerfile
Expected Findings:
MEDIUM: No USER directive (runs as root)HIGH: Installing sudo in containerMEDIUM: No HEALTHCHECK definedINFO: Using apt-get without cleanup in some layers
Test Purpose: Verify user privilege checks
bad-privileged.Dockerfile
Expected Findings:
CRITICAL: UsinglatesttagHIGH: Installing Docker CLI (pattern for docker.sock mounting)MEDIUM: World-writable permissions (chmod 777)MEDIUM: No USER directive
Test Purpose: Verify base image and permission checks
bad-add-command.Dockerfile
Expected Findings:
MEDIUM: Using ADD instead of COPYMEDIUM: No USER directiveHIGH: npm install as rootMEDIUM: No --production flag for npmMEDIUM: Multiple exposed ports including debug ports (9229, 9230)MEDIUM: No HEALTHCHECK
Test Purpose: Verify Dockerfile best practices
Good Examples (Should Pass)
good-minimal.Dockerfile
Expected: No critical/high findings
Features:
- Specific version tag (alpine:3.19)
- Non-root user (appuser, UID 1000)
- Proper file ownership
- HEALTHCHECK present
- Minimal attack surface
good-security.Dockerfile
Expected: No findings (perfect security)
Features:
- Specific version tag with digest
- Non-root user
- Production dependencies only
- npm cache cleaned
- Immutable filesystem (chmod -R 555)
- HEALTHCHECK
- Tini init process
- Proper signal handling
Docker Compose Files
Bad Examples
bad-docker-socket.yml
Expected Findings:
CRITICAL: privileged: trueCRITICAL: Docker socket mountedCRITICAL: /etc/passwd mountedCRITICAL: /root/.ssh mountedCRITICAL: CAP_SYS_ADMIN capabilityCRITICAL: CAP_NET_ADMIN capabilityCRITICAL: CAP_SYS_PTRACE capabilityMEDIUM: network_mode: hostCRITICAL: AWS credentials in environment
Test Purpose: Most dangerous configuration possible
bad-privileged.yml
Expected Findings:
CRITICAL: privileged: trueHIGH: pid: hostHIGH: ipc: hostCRITICAL: Root filesystem mounted (/)CRITICAL: /proc mountedCRITICAL: /sys mountedMEDIUM: No resource limitsMEDIUM: No restart policy
Test Purpose: Host namespace access patterns
bad-caps.yml
Expected Findings:
CRITICAL: CAP_SYS_MODULECRITICAL: CAP_SYS_RAWIOCRITICAL: CAP_SYS_PTRACECRITICAL: CAP_SYS_ADMINHIGH: CAP_DAC_OVERRIDECRITICAL: CAP_MAC_ADMINHIGH: CAP_NET_ADMINCRITICAL: CAP_BPFHIGH: /lib/modules mountedCRITICAL: /dev mounted
Test Purpose: Dangerous Linux capabilities
bad-mounts.yml
Expected Findings:
CRITICAL: Docker socket mountedCRITICAL: Containerd socket mountedCRITICAL: /etc, /etc/passwd, /etc/shadow mountedCRITICAL: /root and subdirectories mountedCRITICAL: Kubernetes directories mountedCRITICAL: /dev, /proc, /sys mountedHIGH: /boot, /lib/modules mountedCRITICAL: /var/lib/docker mountedHIGH: /var/log mounted
Test Purpose: Sensitive filesystem mounts
bad-secrets.yml
Expected Findings:
- Multiple
CRITICALfindings for hardcoded secrets:- AWS credentials
- Database URLs with passwords
- API keys (Stripe, GitHub, OpenAI, Google, Azure)
- JWT/Session secrets
- Private keys
- Database passwords
Test Purpose: Environment variable secret detection
bad-no-limits.yml
Expected Findings:
MEDIUM: No memory limitsMEDIUM: No CPU limitsMEDIUM: No PID limitsMEDIUM: No restart policyMEDIUM: No health checkMEDIUM: No USER directiveMEDIUM: Not read-only filesystemMEDIUM: No security optionsMEDIUM: No capabilities dropped
Test Purpose: Resource limits and hardening options
Good Example
good-production.yml
Expected: No critical/high findings
Features:
- Specific image tags with versions
- Non-root users (1000:1000, node:node)
- Read-only root filesystem
- Tmpfs for writable directories
- Security options (no-new-privileges, apparmor)
- Capabilities dropped (ALL) then minimal added
- Resource limits (CPU, memory)
- Health checks
- Restart policies
- Network isolation
- Secrets management (not env vars)
- Safe volume mounts (read-only configs)
Container Inspect JSONs
privileged-container.json
Expected Findings:
CRITICAL: Privileged modeHIGH: PID host modeHIGH: IPC host modeMEDIUM: Network host modeCRITICAL: Docker socket mountedCRITICAL: Multiple dangerous capabilitiesCRITICAL: Sensitive host paths mountedCRITICAL: Secrets in environmentMEDIUM: No resource limitsMEDIUM: No restart policyMEDIUM: Running as root (empty User)MEDIUM: No health check
Test Purpose: Container runtime configuration checks
secure-container.json
Expected: No critical/high findings
Features:
- Non-privileged
- Non-root user (1000:1000)
- Isolated namespaces (no host mode)
- Capabilities dropped (ALL) + minimal added
- Security options enabled
- Read-only root filesystem
- Tmpfs for writable directories
- Resource limits configured
- Restart policy set
- Health check configured
- Safe volume mounts
Test Purpose: Secure container configuration
Usage in Tests
// Example: Test Dockerfile analyzer
func TestDockerfileAnalyzer(t *testing.T) {
analyzer := analyzer.NewDockerfileAnalyzer()
// Test bad case
findings, err := analyzer.Analyze("testdata/dockerfiles/bad-secrets.Dockerfile")
require.NoError(t, err)
assert.True(t, findings.HasSeverityAtOrAbove(finding.SeverityCritical))
assert.Contains(t, findings, "hardcoded-secrets")
// Test good case
findings, err = analyzer.Analyze("testdata/dockerfiles/good-security.Dockerfile")
require.NoError(t, err)
assert.False(t, findings.HasSeverityAtOrAbove(finding.SeverityHigh))
}
Test Matrix
| File | Secrets | Privileged | Caps | Mounts | User | Limits | Health |
|---|---|---|---|---|---|---|---|
| bad-secrets.Dockerfile | ✓ | - | - | - | ✗ | - | ✗ |
| bad-root-user.Dockerfile | - | - | - | - | ✗ | - | ✗ |
| bad-privileged.Dockerfile | - | pattern | - | - | ✗ | - | - |
| bad-add-command.Dockerfile | - | - | - | - | ✗ | - | ✗ |
| bad-docker-socket.yml | ✓ | ✓ | ✓ | ✓ | ✗ | ✗ | ✗ |
| bad-privileged.yml | - | ✓ | - | ✓ | ✗ | ✗ | ✗ |
| bad-caps.yml | - | - | ✓ | ✓ | ✗ | - | - |
| bad-mounts.yml | - | - | - | ✓ | ✗ | - | - |
| bad-secrets.yml | ✓ | - | - | - | - | - | - |
| bad-no-limits.yml | - | - | - | - | ✗ | ✗ | ✗ |
| good-minimal.Dockerfile | ✗ | ✗ | ✗ | ✗ | ✓ | - | ✓ |
| good-security.Dockerfile | ✗ | ✗ | ✗ | ✗ | ✓ | ✓ | ✓ |
| good-production.yml | ✗ | ✗ | ✓ | ✓ | ✓ | ✓ | ✓ |
Legend:
- ✓ = Has this security feature/issue
- ✗ = Does not have this issue / Has protection
- - = Not applicable