container-audit 0.0.0__tar.gz
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.
- container_audit-0.0.0/LICENSE +21 -0
- container_audit-0.0.0/PKG-INFO +5 -0
- container_audit-0.0.0/README.md +202 -0
- container_audit-0.0.0/container_audit/__init__.py +4 -0
- container_audit-0.0.0/container_audit/checks/__init__.py +1 -0
- container_audit-0.0.0/container_audit/checks/docker.py +461 -0
- container_audit-0.0.0/container_audit/checks/kubernetes.py +402 -0
- container_audit-0.0.0/container_audit/checks/network.py +91 -0
- container_audit-0.0.0/container_audit/checks/secrets.py +109 -0
- container_audit-0.0.0/container_audit/cli.py +103 -0
- container_audit-0.0.0/container_audit/models.py +122 -0
- container_audit-0.0.0/container_audit/reporters/__init__.py +7 -0
- container_audit-0.0.0/container_audit/reporters/console.py +112 -0
- container_audit-0.0.0/container_audit/reporters/html_out.py +122 -0
- container_audit-0.0.0/container_audit/reporters/json_out.py +31 -0
- container_audit-0.0.0/container_audit/scanner.py +136 -0
- container_audit-0.0.0/container_audit/utils.py +37 -0
- container_audit-0.0.0/container_audit.egg-info/PKG-INFO +5 -0
- container_audit-0.0.0/container_audit.egg-info/SOURCES.txt +24 -0
- container_audit-0.0.0/container_audit.egg-info/dependency_links.txt +1 -0
- container_audit-0.0.0/container_audit.egg-info/top_level.txt +1 -0
- container_audit-0.0.0/pyproject.toml +0 -0
- container_audit-0.0.0/setup.cfg +4 -0
- container_audit-0.0.0/tests/test_docker.py +96 -0
- container_audit-0.0.0/tests/test_k8s.py +121 -0
- container_audit-0.0.0/tests/test_scanner.py +35 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 HYMichellexdd
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://img.shields.io/badge/🔒-Container%20Audit-blueviolet?style=for-the-badge" alt="Container Audit"/>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">Container Audit</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>Lightweight container security auditor for Docker and Kubernetes</strong>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://github.com/HYMichellelxdd/container-audit/actions/workflows/ci.yml"><img src="https://github.com/HYMichellelxdd/container-audit/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
13
|
+
<a href="https://github.com/HYMichellelxdd/container-audit/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-MIT-green.svg" alt="License: MIT"></a>
|
|
14
|
+
<a href="https://pypi.org/project/container-audit/"><img src="https://img.shields.io/pypi/v/container-audit.svg" alt="PyPI"></a>
|
|
15
|
+
<a href="https://pypi.org/project/container-audit/"><img src="https://img.shields.io/pypi/pyversions/container-audit.svg" alt="Python"></a>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## ✨ Features
|
|
21
|
+
|
|
22
|
+
**Container Audit** is a fast, lightweight security scanner that helps developers and DevSecOps teams identify misconfigurations in Docker and Kubernetes environments.
|
|
23
|
+
|
|
24
|
+
- 🐳 **Docker Security** — 16 checks covering privileged mode, capabilities, secrets, socket permissions, and more
|
|
25
|
+
- ☸️ **Kubernetes Compliance** — Pod Security, RBAC, NetworkPolicy, security context best practices
|
|
26
|
+
- 🎚️ **Severity Filtering** — Filter findings by severity level
|
|
27
|
+
- ⚡ **Fail-on Threshold** — Configurable exit code based on severity for CI/CD
|
|
28
|
+
- 📊 **Multiple Reports** — Terminal (Rich), JSON, and HTML output
|
|
29
|
+
- ⚡ **Security Score** — 0-100 score based on severity-weighted findings
|
|
30
|
+
|
|
31
|
+
## 🚀 Quick Start
|
|
32
|
+
|
|
33
|
+
### Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install container-audit
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Basic Usage
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Scan a Docker container
|
|
43
|
+
container-audit docker my-container
|
|
44
|
+
|
|
45
|
+
# Scan a docker-compose file
|
|
46
|
+
container-audit compose docker-compose.yml
|
|
47
|
+
|
|
48
|
+
# Scan Kubernetes manifests
|
|
49
|
+
container-audit k8s ./k8s-manifests/
|
|
50
|
+
|
|
51
|
+
# Only show high and critical findings
|
|
52
|
+
container-audit docker my-container --severity high
|
|
53
|
+
|
|
54
|
+
# Exit with error only on critical findings (for CI)
|
|
55
|
+
container-audit docker my-container --fail-on critical
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Output Formats
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# JSON output (for CI/CD pipelines)
|
|
62
|
+
container-audit docker my-container -f json -o report.json
|
|
63
|
+
|
|
64
|
+
# HTML report (dark theme)
|
|
65
|
+
container-audit docker my-container -f html -o report.html
|
|
66
|
+
|
|
67
|
+
# Verbose terminal output
|
|
68
|
+
container-audit docker my-container -v
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## 📋 Security Checks
|
|
72
|
+
|
|
73
|
+
### Docker (16 checks)
|
|
74
|
+
|
|
75
|
+
| Check | Severity | Description |
|
|
76
|
+
|-------|----------|-------------|
|
|
77
|
+
| `DOCKER-001` | 🔴 CRITICAL | Privileged container detection |
|
|
78
|
+
| `DOCKER-002` | 🔴 CRITICAL | Docker socket mount detection |
|
|
79
|
+
| `DOCKER-003` | 🟡 MEDIUM | Running as root user |
|
|
80
|
+
| `DOCKER-004` | 🔴 HIGH | Dangerous capabilities (SYS_ADMIN, NET_ADMIN) |
|
|
81
|
+
| `DOCKER-005` | 🟡 MEDIUM | Ports exposed on 0.0.0.0 |
|
|
82
|
+
| `DOCKER-006` | 🔴 HIGH | Secrets in environment variables |
|
|
83
|
+
| `DOCKER-007` | 🔵 LOW | Writable root filesystem |
|
|
84
|
+
| `DOCKER-008` | 🟡 MEDIUM | Missing resource limits |
|
|
85
|
+
| `DOCKER-009` | 🔵 LOW | No healthcheck configured |
|
|
86
|
+
| `DOCKER-010` | 🔵 LOW | AppArmor profile status |
|
|
87
|
+
| `DOCKER-011` | 🔵 LOW | Seccomp profile status |
|
|
88
|
+
| `DOCKER-012` | 🔴 HIGH | Host PID namespace |
|
|
89
|
+
| `DOCKER-013` | 🟡 MEDIUM | Host IPC namespace |
|
|
90
|
+
| `DOCKER-014` | 🔴 HIGH | Host network mode |
|
|
91
|
+
| `DOCKER-015` | 🔴 HIGH | Docker socket permissions |
|
|
92
|
+
|
|
93
|
+
### Kubernetes
|
|
94
|
+
|
|
95
|
+
| Check | Severity | Description |
|
|
96
|
+
|-------|----------|-------------|
|
|
97
|
+
| `K8S-PRIV-*` | 🔴 CRITICAL | Privileged containers |
|
|
98
|
+
| `K8S-ROOT-*` | 🟡 MEDIUM | Running as root |
|
|
99
|
+
| `K8S-CAPS-*` | 🔴 HIGH | Dangerous capabilities |
|
|
100
|
+
| `K8S-PE-*` | 🟡 MEDIUM | Privilege escalation not disabled |
|
|
101
|
+
| `K8S-SECCOMP-*` | 🔵 LOW | No seccomp profile |
|
|
102
|
+
| `K8S-CAPDROP-*` | 🟡 MEDIUM | Capabilities not dropped |
|
|
103
|
+
| `K8S-SA-TOKEN` | 🟡 MEDIUM | ServiceAccount token auto-mounted |
|
|
104
|
+
| `K8S-HNET` | 🔴 HIGH | Host network enabled |
|
|
105
|
+
| `K8S-HOSTPATH` | 🔴 HIGH | HostPath volumes |
|
|
106
|
+
| `K8S-RBAC-*` | 🔴 HIGH | Overprivileged RBAC |
|
|
107
|
+
|
|
108
|
+
### Docker Compose
|
|
109
|
+
|
|
110
|
+
| Check | Severity | Description |
|
|
111
|
+
|-------|----------|-------------|
|
|
112
|
+
| `COMPOSE-*-001` | 🔴 CRITICAL | Privileged mode |
|
|
113
|
+
| `COMPOSE-*-002` | 🔴 CRITICAL | Docker socket mounted |
|
|
114
|
+
| `COMPOSE-*-003` | 🟡 MEDIUM | Running as root |
|
|
115
|
+
| `COMPOSE-*-004` | 🔴 HIGH | Dangerous capabilities |
|
|
116
|
+
| `COMPOSE-*-HEALTH` | 🔵 LOW | Healthcheck check |
|
|
117
|
+
| `COMPOSE-*-RESTART` | 🔵 LOW | Restart policy |
|
|
118
|
+
| `COMPOSE-*-ROFS` | 🔵 LOW | Read-only filesystem |
|
|
119
|
+
|
|
120
|
+
## 📊 Report Example
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
╭──────────── Security Report ────────────╮
|
|
124
|
+
│ Container Audit Report │
|
|
125
|
+
│ Target: my-container │
|
|
126
|
+
│ Scan Type: docker │
|
|
127
|
+
│ Score: 35/100 │
|
|
128
|
+
╰─────────────────────────────────────────╯
|
|
129
|
+
|
|
130
|
+
Findings:
|
|
131
|
+
✗ CRITICAL Privileged container
|
|
132
|
+
→ Remove --privileged flag.
|
|
133
|
+
✗ CRITICAL Docker socket mounted
|
|
134
|
+
→ Avoid mounting Docker socket.
|
|
135
|
+
✗ HIGH Dangerous capabilities added
|
|
136
|
+
→ Remove unnecessary capabilities.
|
|
137
|
+
✓ HIGH Host PID namespace
|
|
138
|
+
✗ MEDIUM Running as root
|
|
139
|
+
→ Set USER directive in Dockerfile.
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## 🔧 CI/CD Integration
|
|
143
|
+
|
|
144
|
+
### GitHub Actions
|
|
145
|
+
|
|
146
|
+
```yaml
|
|
147
|
+
- name: Container Security Scan
|
|
148
|
+
run: |
|
|
149
|
+
pip install container-audit
|
|
150
|
+
container-audit docker ${{ env.IMAGE }} --fail-on critical
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Exit Codes
|
|
154
|
+
|
|
155
|
+
| Code | Meaning |
|
|
156
|
+
|------|---------|
|
|
157
|
+
| `0` | No findings above threshold |
|
|
158
|
+
| `1` | Findings at or above `--fail-on` threshold |
|
|
159
|
+
|
|
160
|
+
## 📁 Project Structure
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
container-audit/
|
|
164
|
+
├── container_audit/
|
|
165
|
+
│ ├── __init__.py
|
|
166
|
+
│ ├── cli.py # CLI entry point
|
|
167
|
+
│ ├── scanner.py # Core scanning engine
|
|
168
|
+
│ ├── models.py # Data models
|
|
169
|
+
│ ├── checks/
|
|
170
|
+
│ │ ├── docker.py # Docker security checks
|
|
171
|
+
│ │ ├── kubernetes.py # K8s manifest checks
|
|
172
|
+
│ │ └── network.py # Network exposure checks
|
|
173
|
+
│ └── reporters/
|
|
174
|
+
│ ├── console.py # Rich terminal output
|
|
175
|
+
│ ├── json_out.py # JSON report
|
|
176
|
+
│ └── html_out.py # HTML report
|
|
177
|
+
├── tests/
|
|
178
|
+
├── .github/workflows/ci.yml
|
|
179
|
+
├── pyproject.toml
|
|
180
|
+
├── LICENSE
|
|
181
|
+
└── README.md
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## 🤝 Contributing
|
|
185
|
+
|
|
186
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
187
|
+
|
|
188
|
+
## 📄 License
|
|
189
|
+
|
|
190
|
+
MIT License - see [LICENSE](LICENSE)
|
|
191
|
+
|
|
192
|
+
## 🔗 Links
|
|
193
|
+
|
|
194
|
+
- [GitHub Repository](https://github.com/HYMichellelxdd/container-audit)
|
|
195
|
+
- [PyPI Package](https://pypi.org/project/container-audit/)
|
|
196
|
+
- [Issue Tracker](https://github.com/HYMichellelxdd/container-audit/issues)
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
<p align="center">
|
|
201
|
+
Made with ❤️ by <a href="https://github.com/HYMichellelxdd">HYMichellexdd</a>
|
|
202
|
+
</p>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Security check modules."""
|