yaml-doctor-cli 1.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.
Files changed (35) hide show
  1. yaml_doctor_cli-1.0.0/LICENSE +21 -0
  2. yaml_doctor_cli-1.0.0/PKG-INFO +345 -0
  3. yaml_doctor_cli-1.0.0/README.md +312 -0
  4. yaml_doctor_cli-1.0.0/pyproject.toml +75 -0
  5. yaml_doctor_cli-1.0.0/tests/__init__.py +0 -0
  6. yaml_doctor_cli-1.0.0/tests/test_cli.py +164 -0
  7. yaml_doctor_cli-1.0.0/tests/test_compose.py +90 -0
  8. yaml_doctor_cli-1.0.0/tests/test_demo.py +53 -0
  9. yaml_doctor_cli-1.0.0/tests/test_detection.py +47 -0
  10. yaml_doctor_cli-1.0.0/tests/test_github_actions.py +116 -0
  11. yaml_doctor_cli-1.0.0/tests/test_gitlab_ci.py +90 -0
  12. yaml_doctor_cli-1.0.0/tests/test_html_report.py +100 -0
  13. yaml_doctor_cli-1.0.0/tests/test_kubernetes.py +192 -0
  14. yaml_doctor_cli-1.0.0/tests/test_models.py +138 -0
  15. yaml_doctor_cli-1.0.0/tests/test_rules.py +51 -0
  16. yaml_doctor_cli-1.0.0/tests/test_scanner.py +144 -0
  17. yaml_doctor_cli-1.0.0/tests/test_utils.py +68 -0
  18. yaml_doctor_cli-1.0.0/tests/test_yaml_lint.py +65 -0
  19. yaml_doctor_cli-1.0.0/yaml_doctor/__init__.py +3 -0
  20. yaml_doctor_cli-1.0.0/yaml_doctor/__main__.py +4 -0
  21. yaml_doctor_cli-1.0.0/yaml_doctor/analyzers/__init__.py +53 -0
  22. yaml_doctor_cli-1.0.0/yaml_doctor/analyzers/compose.py +107 -0
  23. yaml_doctor_cli-1.0.0/yaml_doctor/analyzers/github_actions.py +122 -0
  24. yaml_doctor_cli-1.0.0/yaml_doctor/analyzers/gitlab_ci.py +108 -0
  25. yaml_doctor_cli-1.0.0/yaml_doctor/analyzers/kubernetes.py +151 -0
  26. yaml_doctor_cli-1.0.0/yaml_doctor/analyzers/yaml_lint.py +103 -0
  27. yaml_doctor_cli-1.0.0/yaml_doctor/cli.py +204 -0
  28. yaml_doctor_cli-1.0.0/yaml_doctor/demo.py +121 -0
  29. yaml_doctor_cli-1.0.0/yaml_doctor/models.py +133 -0
  30. yaml_doctor_cli-1.0.0/yaml_doctor/output/__init__.py +1 -0
  31. yaml_doctor_cli-1.0.0/yaml_doctor/output/console.py +196 -0
  32. yaml_doctor_cli-1.0.0/yaml_doctor/output/html_report.py +192 -0
  33. yaml_doctor_cli-1.0.0/yaml_doctor/rules.py +92 -0
  34. yaml_doctor_cli-1.0.0/yaml_doctor/scanner.py +145 -0
  35. yaml_doctor_cli-1.0.0/yaml_doctor/utils.py +44 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Sanjay Sundar Murthy
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,345 @@
1
+ Metadata-Version: 2.4
2
+ Name: yaml-doctor-cli
3
+ Version: 1.0.0
4
+ Summary: Validate & lint K8s manifests, Helm charts, Docker Compose, CI configs โ€” 60+ rules with beautiful reports
5
+ Project-URL: Homepage, https://github.com/SanjaySundarMurthy/yaml-doctor
6
+ Project-URL: Repository, https://github.com/SanjaySundarMurthy/yaml-doctor
7
+ Project-URL: Issues, https://github.com/SanjaySundarMurthy/yaml-doctor/issues
8
+ Author-email: Sanjay S <sanjaysundarmurthy@gmail.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: cli,devops,docker-compose,github-actions,gitlab-ci,helm,kubernetes,lint,validate,yaml
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: System Administrators
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Topic :: Software Development :: Quality Assurance
23
+ Classifier: Topic :: System :: Systems Administration
24
+ Requires-Python: >=3.10
25
+ Requires-Dist: click>=8.0
26
+ Requires-Dist: pyyaml>=6.0
27
+ Requires-Dist: rich>=13.0
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest-cov>=5.0; extra == 'dev'
30
+ Requires-Dist: pytest>=8.0; extra == 'dev'
31
+ Requires-Dist: ruff>=0.4; extra == 'dev'
32
+ Description-Content-Type: text/markdown
33
+
34
+ # ๐Ÿฉบ yaml-doctor
35
+
36
+ **YAML Linter & Security Scanner for DevOps Engineers**
37
+
38
+ Validate and lint Kubernetes manifests, Docker Compose files, GitHub Actions workflows, GitLab CI pipelines, and generic YAML with **60+ built-in rules** covering security, reliability, and best practices.
39
+
40
+ [![PyPI version](https://img.shields.io/pypi/v/yaml-doctor.svg)](https://pypi.org/project/yaml-doctor/)
41
+ [![Python](https://img.shields.io/pypi/pyversions/yaml-doctor.svg)](https://pypi.org/project/yaml-doctor/)
42
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
43
+ [![Tests](https://img.shields.io/badge/tests-188%20passing-brightgreen.svg)]()
44
+
45
+ ---
46
+
47
+ ## โœจ Features
48
+
49
+ - ๐Ÿ” **60+ Lint Rules** โ€” Security, reliability, and best practice checks
50
+ - ๐ŸŽฏ **Auto-Detection** โ€” Automatically identifies Kubernetes, Docker Compose, GitHub Actions, GitLab CI, and Helm files
51
+ - ๐Ÿ“Š **Grading System** โ€” A+ to F grades with detailed scoring
52
+ - ๐ŸŒ **HTML Dashboard** โ€” Beautiful dark-theme HTML reports with severity charts
53
+ - ๐Ÿ“‹ **JSON Export** โ€” Machine-readable reports for CI/CD integration
54
+ - ๐Ÿ”ง **Fix Suggestions** โ€” Actionable remediation for every finding
55
+ - ๐ŸŽฎ **Demo Mode** โ€” Try it instantly with built-in sample files
56
+ - ๐Ÿš€ **Zero Config** โ€” Works out of the box, no configuration needed
57
+
58
+ ## ๐Ÿ“ฆ Installation
59
+
60
+ ```bash
61
+ pip install yaml-doctor
62
+ ```
63
+
64
+ ## ๐Ÿš€ Quick Start
65
+
66
+ ```bash
67
+ # Lint a single file
68
+ yaml-doctor lint deployment.yaml
69
+
70
+ # Scan a directory recursively
71
+ yaml-doctor scan ./k8s/
72
+
73
+ # Run demo with sample files
74
+ yaml-doctor demo
75
+
76
+ # Show all 60 rules
77
+ yaml-doctor rules
78
+
79
+ # Get fix suggestions
80
+ yaml-doctor fix deployment.yaml
81
+
82
+ # Export HTML dashboard
83
+ yaml-doctor scan . --html report.html
84
+
85
+ # Export JSON report
86
+ yaml-doctor lint config.yaml -j report.json
87
+ ```
88
+
89
+ ## ๐ŸŽฏ Supported File Types
90
+
91
+ | Type | Detection | Rules |
92
+ |------|-----------|-------|
93
+ | **Kubernetes** | `apiVersion` + `kind` | 20 rules (K8S001-K8S020) |
94
+ | **Docker Compose** | `services` + `image/build` | 12 rules (DC001-DC012) |
95
+ | **GitHub Actions** | `.github/workflows/` + `on/jobs` | 10 rules (GHA001-GHA010) |
96
+ | **GitLab CI** | `.gitlab-ci.yml` + `stages/script` | 10 rules (GL001-GL010) |
97
+ | **Helm** | `Chart.yaml` / `values.yaml` | K8s rules applied |
98
+ | **Generic YAML** | Any `.yml`/`.yaml` file | 8 rules (YML001-YML008) |
99
+
100
+ ## ๐Ÿ”’ Security Rules
101
+
102
+ ### Kubernetes (20 rules)
103
+
104
+ | Rule | Severity | Description |
105
+ |------|----------|-------------|
106
+ | K8S001 | ๐Ÿ”ด CRITICAL | Container running as root |
107
+ | K8S004 | ๐Ÿ”ด CRITICAL | Privileged container |
108
+ | K8S002 | ๐ŸŸ  HIGH | Missing resource limits |
109
+ | K8S003 | ๐ŸŸ  HIGH | Missing resource requests |
110
+ | K8S005 | ๐ŸŸ  HIGH | Using `:latest` image tag |
111
+ | K8S006 | ๐ŸŸ  HIGH | Missing liveness probe |
112
+ | K8S011 | ๐ŸŸ  HIGH | Host network enabled |
113
+ | K8S012 | ๐ŸŸ  HIGH | Host PID enabled |
114
+ | K8S016 | ๐ŸŸ  HIGH | Secrets in environment variables |
115
+ | K8S007 | ๐ŸŸก MEDIUM | Missing readiness probe |
116
+ | K8S008 | ๐ŸŸก MEDIUM | Read-only filesystem not set |
117
+ | K8S013 | ๐ŸŸก MEDIUM | Single replica deployment |
118
+ | K8S014 | ๐ŸŸก MEDIUM | Privilege escalation allowed |
119
+ | K8S017 | ๐ŸŸก MEDIUM | Missing update strategy |
120
+ | K8S018 | ๐ŸŸก MEDIUM | Capabilities not dropped |
121
+ | K8S020 | ๐ŸŸก MEDIUM | Missing restart policy |
122
+ | K8S009 | ๐Ÿ”ต LOW | Missing recommended labels |
123
+ | K8S015 | ๐Ÿ”ต LOW | Missing PodDisruptionBudget |
124
+ | K8S019 | ๐Ÿ”ต LOW | No anti-affinity rules |
125
+ | K8S010 | โšช INFO | Missing namespace |
126
+
127
+ ### Docker Compose (12 rules)
128
+
129
+ | Rule | Severity | Description |
130
+ |------|----------|-------------|
131
+ | DC002 | ๐Ÿ”ด CRITICAL | Privileged container |
132
+ | DC001 | ๐ŸŸ  HIGH | Using `:latest` tag |
133
+ | DC005 | ๐ŸŸ  HIGH | Secrets in environment |
134
+ | DC009 | ๐ŸŸ  HIGH | Host volume with write access |
135
+ | DC012 | ๐ŸŸก MEDIUM | Host network mode |
136
+ | DC003 | ๐ŸŸก MEDIUM | No restart policy |
137
+ | DC004 | ๐ŸŸก MEDIUM | No healthcheck defined |
138
+ | DC007 | ๐ŸŸก MEDIUM | Exposed to all interfaces |
139
+ | DC011 | ๐ŸŸก MEDIUM | No depends_on |
140
+ | DC006 | ๐Ÿ”ต LOW | No resource limits |
141
+ | DC010 | ๐Ÿ”ต LOW | No logging configuration |
142
+ | DC008 | โšช INFO | Deprecated version key |
143
+
144
+ ### GitHub Actions (10 rules)
145
+
146
+ | Rule | Severity | Description |
147
+ |------|----------|-------------|
148
+ | GHA001 | ๐Ÿ”ด CRITICAL | Mutable action reference (using @main) |
149
+ | GHA002 | ๐ŸŸ  HIGH | Persist credentials enabled |
150
+ | GHA003 | ๐ŸŸ  HIGH | Secrets in run commands |
151
+ | GHA009 | ๐ŸŸ  HIGH | Script injection risk |
152
+ | GHA004 | ๐ŸŸก MEDIUM | Overly broad permissions |
153
+ | GHA005 | ๐ŸŸก MEDIUM | No job timeout |
154
+ | GHA006 | ๐ŸŸก MEDIUM | pull_request_target trigger |
155
+ | GHA007 | ๐Ÿ”ต LOW | No concurrency control |
156
+ | GHA008 | ๐Ÿ”ต LOW | Unversioned runner image |
157
+ | GHA010 | โšช INFO | Missing workflow name |
158
+
159
+ ### GitLab CI (10 rules)
160
+
161
+ | Rule | Severity | Description |
162
+ |------|----------|-------------|
163
+ | GL001 | ๐ŸŸ  HIGH | Secrets in script blocks |
164
+ | GL007 | ๐ŸŸ  HIGH | allow_failure on security jobs |
165
+ | GL002 | ๐ŸŸก MEDIUM | No retry configuration |
166
+ | GL004 | ๐ŸŸก MEDIUM | Using `:latest` image |
167
+ | GL005 | ๐ŸŸก MEDIUM | No timeout set |
168
+ | GL009 | ๐ŸŸก MEDIUM | No rules/conditions |
169
+ | GL003 | ๐Ÿ”ต LOW | No cache defined |
170
+ | GL008 | ๐Ÿ”ต LOW | No artifacts defined |
171
+ | GL010 | ๐Ÿ”ต LOW | Missing job description |
172
+ | GL006 | โšช INFO | No stages defined |
173
+
174
+ ### Generic YAML (8 rules)
175
+
176
+ | Rule | Severity | Description |
177
+ |------|----------|-------------|
178
+ | YML005 | ๐ŸŸ  HIGH | Hardcoded credentials |
179
+ | YML001 | ๐ŸŸก MEDIUM | Inconsistent indentation |
180
+ | YML006 | ๐ŸŸก MEDIUM | Duplicate keys |
181
+ | YML002 | ๐Ÿ”ต LOW | Trailing whitespace |
182
+ | YML003 | ๐Ÿ”ต LOW | Line too long (>200 chars) |
183
+ | YML007 | ๐Ÿ”ต LOW | Empty values |
184
+ | YML004 | โšช INFO | Missing document start marker |
185
+ | YML008 | โšช INFO | File too long (>1000 lines) |
186
+
187
+ ## ๐Ÿ“Š Grading System
188
+
189
+ | Grade | Score | Description |
190
+ |-------|-------|-------------|
191
+ | A+ | 95-100 | Excellent โ€” production ready |
192
+ | A | 85-94 | Great โ€” minor improvements possible |
193
+ | B | 75-84 | Good โ€” some issues to address |
194
+ | C | 65-74 | Fair โ€” significant improvements needed |
195
+ | D | 50-64 | Poor โ€” many issues found |
196
+ | F | 0-49 | Failing โ€” critical issues present |
197
+
198
+ **Score deductions per finding:**
199
+ - ๐Ÿ”ด Critical: -15 points
200
+ - ๐ŸŸ  High: -8 points
201
+ - ๐ŸŸก Medium: -3 points
202
+ - ๐Ÿ”ต Low: -1 point
203
+ - โšช Info: 0 points
204
+
205
+ ## ๐Ÿ–ฅ๏ธ CLI Commands
206
+
207
+ ### `yaml-doctor lint <file>`
208
+
209
+ Lint a single YAML file with auto-detection.
210
+
211
+ ```bash
212
+ yaml-doctor lint deployment.yaml
213
+ yaml-doctor lint docker-compose.yml --html report.html
214
+ yaml-doctor lint .github/workflows/ci.yml -j report.json
215
+ ```
216
+
217
+ ### `yaml-doctor scan <directory>`
218
+
219
+ Scan all YAML files in a directory.
220
+
221
+ ```bash
222
+ yaml-doctor scan ./k8s/
223
+ yaml-doctor scan . --html dashboard.html
224
+ yaml-doctor scan ./configs --no-recursive
225
+ ```
226
+
227
+ ### `yaml-doctor demo`
228
+
229
+ Run a demo with built-in sample files.
230
+
231
+ ```bash
232
+ yaml-doctor demo
233
+ yaml-doctor demo --type kubernetes
234
+ yaml-doctor demo --type compose
235
+ yaml-doctor demo --html demo-report.html
236
+ ```
237
+
238
+ ### `yaml-doctor rules`
239
+
240
+ Display all 60 available lint rules.
241
+
242
+ ```bash
243
+ yaml-doctor rules
244
+ ```
245
+
246
+ ### `yaml-doctor fix <file>`
247
+
248
+ Show fix suggestions for all findings.
249
+
250
+ ```bash
251
+ yaml-doctor fix deployment.yaml
252
+ ```
253
+
254
+ ## ๐Ÿ”Œ CI/CD Integration
255
+
256
+ ### GitHub Actions
257
+
258
+ ```yaml
259
+ - name: YAML Lint
260
+ run: |
261
+ pip install yaml-doctor
262
+ yaml-doctor scan . --html report.html -j report.json
263
+
264
+ - name: Upload Report
265
+ uses: actions/upload-artifact@v4
266
+ with:
267
+ name: yaml-doctor-report
268
+ path: report.html
269
+ ```
270
+
271
+ ### GitLab CI
272
+
273
+ ```yaml
274
+ yaml-lint:
275
+ stage: test
276
+ script:
277
+ - pip install yaml-doctor
278
+ - yaml-doctor scan . --html report.html -j report.json
279
+ artifacts:
280
+ paths:
281
+ - report.html
282
+ - report.json
283
+ ```
284
+
285
+ ### Pre-commit Hook
286
+
287
+ ```yaml
288
+ # .pre-commit-config.yaml
289
+ repos:
290
+ - repo: local
291
+ hooks:
292
+ - id: yaml-doctor
293
+ name: yaml-doctor
294
+ entry: yaml-doctor lint
295
+ language: python
296
+ types: [yaml]
297
+ additional_dependencies: [yaml-doctor]
298
+ ```
299
+
300
+ ## ๐Ÿ“ Project Structure
301
+
302
+ ```
303
+ yaml-doctor/
304
+ โ”œโ”€โ”€ yaml_doctor/
305
+ โ”‚ โ”œโ”€โ”€ __init__.py # Package version
306
+ โ”‚ โ”œโ”€โ”€ __main__.py # python -m support
307
+ โ”‚ โ”œโ”€โ”€ cli.py # Click CLI commands
308
+ โ”‚ โ”œโ”€โ”€ scanner.py # Core scanning engine
309
+ โ”‚ โ”œโ”€โ”€ models.py # Data models & enums
310
+ โ”‚ โ”œโ”€โ”€ rules.py # Rule registry (60 rules)
311
+ โ”‚ โ”œโ”€โ”€ utils.py # Helper utilities
312
+ โ”‚ โ”œโ”€โ”€ demo.py # Demo sample data
313
+ โ”‚ โ”œโ”€โ”€ analyzers/
314
+ โ”‚ โ”‚ โ”œโ”€โ”€ __init__.py # File type detection
315
+ โ”‚ โ”‚ โ”œโ”€โ”€ kubernetes.py # 20 K8s rules
316
+ โ”‚ โ”‚ โ”œโ”€โ”€ compose.py # 12 Docker Compose rules
317
+ โ”‚ โ”‚ โ”œโ”€โ”€ github_actions.py # 10 GitHub Actions rules
318
+ โ”‚ โ”‚ โ”œโ”€โ”€ gitlab_ci.py # 10 GitLab CI rules
319
+ โ”‚ โ”‚ โ””โ”€โ”€ yaml_lint.py # 8 generic YAML rules
320
+ โ”‚ โ””โ”€โ”€ output/
321
+ โ”‚ โ”œโ”€โ”€ console.py # Rich terminal output
322
+ โ”‚ โ””โ”€โ”€ html_report.py # HTML dashboard reports
323
+ โ”œโ”€โ”€ tests/ # 188 tests
324
+ โ”œโ”€โ”€ pyproject.toml
325
+ โ”œโ”€โ”€ LICENSE
326
+ โ””โ”€โ”€ README.md
327
+ ```
328
+
329
+ ## ๐Ÿงช Development
330
+
331
+ ```bash
332
+ git clone https://github.com/SanjaySundarMurthy/yaml-doctor.git
333
+ cd yaml-doctor
334
+ pip install -e ".[dev]"
335
+ pytest
336
+ ruff check .
337
+ ```
338
+
339
+ ## ๐Ÿ“„ License
340
+
341
+ MIT License โ€” see [LICENSE](LICENSE) for details.
342
+
343
+ ## ๐Ÿ‘จโ€๐Ÿ’ป Author
344
+
345
+ **Sanjay S** โ€” [GitHub](https://github.com/SanjaySundarMurthy) ยท [Email](mailto:sanjaysundarmurthy@gmail.com)
@@ -0,0 +1,312 @@
1
+ # ๐Ÿฉบ yaml-doctor
2
+
3
+ **YAML Linter & Security Scanner for DevOps Engineers**
4
+
5
+ Validate and lint Kubernetes manifests, Docker Compose files, GitHub Actions workflows, GitLab CI pipelines, and generic YAML with **60+ built-in rules** covering security, reliability, and best practices.
6
+
7
+ [![PyPI version](https://img.shields.io/pypi/v/yaml-doctor.svg)](https://pypi.org/project/yaml-doctor/)
8
+ [![Python](https://img.shields.io/pypi/pyversions/yaml-doctor.svg)](https://pypi.org/project/yaml-doctor/)
9
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
10
+ [![Tests](https://img.shields.io/badge/tests-188%20passing-brightgreen.svg)]()
11
+
12
+ ---
13
+
14
+ ## โœจ Features
15
+
16
+ - ๐Ÿ” **60+ Lint Rules** โ€” Security, reliability, and best practice checks
17
+ - ๐ŸŽฏ **Auto-Detection** โ€” Automatically identifies Kubernetes, Docker Compose, GitHub Actions, GitLab CI, and Helm files
18
+ - ๐Ÿ“Š **Grading System** โ€” A+ to F grades with detailed scoring
19
+ - ๐ŸŒ **HTML Dashboard** โ€” Beautiful dark-theme HTML reports with severity charts
20
+ - ๐Ÿ“‹ **JSON Export** โ€” Machine-readable reports for CI/CD integration
21
+ - ๐Ÿ”ง **Fix Suggestions** โ€” Actionable remediation for every finding
22
+ - ๐ŸŽฎ **Demo Mode** โ€” Try it instantly with built-in sample files
23
+ - ๐Ÿš€ **Zero Config** โ€” Works out of the box, no configuration needed
24
+
25
+ ## ๐Ÿ“ฆ Installation
26
+
27
+ ```bash
28
+ pip install yaml-doctor
29
+ ```
30
+
31
+ ## ๐Ÿš€ Quick Start
32
+
33
+ ```bash
34
+ # Lint a single file
35
+ yaml-doctor lint deployment.yaml
36
+
37
+ # Scan a directory recursively
38
+ yaml-doctor scan ./k8s/
39
+
40
+ # Run demo with sample files
41
+ yaml-doctor demo
42
+
43
+ # Show all 60 rules
44
+ yaml-doctor rules
45
+
46
+ # Get fix suggestions
47
+ yaml-doctor fix deployment.yaml
48
+
49
+ # Export HTML dashboard
50
+ yaml-doctor scan . --html report.html
51
+
52
+ # Export JSON report
53
+ yaml-doctor lint config.yaml -j report.json
54
+ ```
55
+
56
+ ## ๐ŸŽฏ Supported File Types
57
+
58
+ | Type | Detection | Rules |
59
+ |------|-----------|-------|
60
+ | **Kubernetes** | `apiVersion` + `kind` | 20 rules (K8S001-K8S020) |
61
+ | **Docker Compose** | `services` + `image/build` | 12 rules (DC001-DC012) |
62
+ | **GitHub Actions** | `.github/workflows/` + `on/jobs` | 10 rules (GHA001-GHA010) |
63
+ | **GitLab CI** | `.gitlab-ci.yml` + `stages/script` | 10 rules (GL001-GL010) |
64
+ | **Helm** | `Chart.yaml` / `values.yaml` | K8s rules applied |
65
+ | **Generic YAML** | Any `.yml`/`.yaml` file | 8 rules (YML001-YML008) |
66
+
67
+ ## ๐Ÿ”’ Security Rules
68
+
69
+ ### Kubernetes (20 rules)
70
+
71
+ | Rule | Severity | Description |
72
+ |------|----------|-------------|
73
+ | K8S001 | ๐Ÿ”ด CRITICAL | Container running as root |
74
+ | K8S004 | ๐Ÿ”ด CRITICAL | Privileged container |
75
+ | K8S002 | ๐ŸŸ  HIGH | Missing resource limits |
76
+ | K8S003 | ๐ŸŸ  HIGH | Missing resource requests |
77
+ | K8S005 | ๐ŸŸ  HIGH | Using `:latest` image tag |
78
+ | K8S006 | ๐ŸŸ  HIGH | Missing liveness probe |
79
+ | K8S011 | ๐ŸŸ  HIGH | Host network enabled |
80
+ | K8S012 | ๐ŸŸ  HIGH | Host PID enabled |
81
+ | K8S016 | ๐ŸŸ  HIGH | Secrets in environment variables |
82
+ | K8S007 | ๐ŸŸก MEDIUM | Missing readiness probe |
83
+ | K8S008 | ๐ŸŸก MEDIUM | Read-only filesystem not set |
84
+ | K8S013 | ๐ŸŸก MEDIUM | Single replica deployment |
85
+ | K8S014 | ๐ŸŸก MEDIUM | Privilege escalation allowed |
86
+ | K8S017 | ๐ŸŸก MEDIUM | Missing update strategy |
87
+ | K8S018 | ๐ŸŸก MEDIUM | Capabilities not dropped |
88
+ | K8S020 | ๐ŸŸก MEDIUM | Missing restart policy |
89
+ | K8S009 | ๐Ÿ”ต LOW | Missing recommended labels |
90
+ | K8S015 | ๐Ÿ”ต LOW | Missing PodDisruptionBudget |
91
+ | K8S019 | ๐Ÿ”ต LOW | No anti-affinity rules |
92
+ | K8S010 | โšช INFO | Missing namespace |
93
+
94
+ ### Docker Compose (12 rules)
95
+
96
+ | Rule | Severity | Description |
97
+ |------|----------|-------------|
98
+ | DC002 | ๐Ÿ”ด CRITICAL | Privileged container |
99
+ | DC001 | ๐ŸŸ  HIGH | Using `:latest` tag |
100
+ | DC005 | ๐ŸŸ  HIGH | Secrets in environment |
101
+ | DC009 | ๐ŸŸ  HIGH | Host volume with write access |
102
+ | DC012 | ๐ŸŸก MEDIUM | Host network mode |
103
+ | DC003 | ๐ŸŸก MEDIUM | No restart policy |
104
+ | DC004 | ๐ŸŸก MEDIUM | No healthcheck defined |
105
+ | DC007 | ๐ŸŸก MEDIUM | Exposed to all interfaces |
106
+ | DC011 | ๐ŸŸก MEDIUM | No depends_on |
107
+ | DC006 | ๐Ÿ”ต LOW | No resource limits |
108
+ | DC010 | ๐Ÿ”ต LOW | No logging configuration |
109
+ | DC008 | โšช INFO | Deprecated version key |
110
+
111
+ ### GitHub Actions (10 rules)
112
+
113
+ | Rule | Severity | Description |
114
+ |------|----------|-------------|
115
+ | GHA001 | ๐Ÿ”ด CRITICAL | Mutable action reference (using @main) |
116
+ | GHA002 | ๐ŸŸ  HIGH | Persist credentials enabled |
117
+ | GHA003 | ๐ŸŸ  HIGH | Secrets in run commands |
118
+ | GHA009 | ๐ŸŸ  HIGH | Script injection risk |
119
+ | GHA004 | ๐ŸŸก MEDIUM | Overly broad permissions |
120
+ | GHA005 | ๐ŸŸก MEDIUM | No job timeout |
121
+ | GHA006 | ๐ŸŸก MEDIUM | pull_request_target trigger |
122
+ | GHA007 | ๐Ÿ”ต LOW | No concurrency control |
123
+ | GHA008 | ๐Ÿ”ต LOW | Unversioned runner image |
124
+ | GHA010 | โšช INFO | Missing workflow name |
125
+
126
+ ### GitLab CI (10 rules)
127
+
128
+ | Rule | Severity | Description |
129
+ |------|----------|-------------|
130
+ | GL001 | ๐ŸŸ  HIGH | Secrets in script blocks |
131
+ | GL007 | ๐ŸŸ  HIGH | allow_failure on security jobs |
132
+ | GL002 | ๐ŸŸก MEDIUM | No retry configuration |
133
+ | GL004 | ๐ŸŸก MEDIUM | Using `:latest` image |
134
+ | GL005 | ๐ŸŸก MEDIUM | No timeout set |
135
+ | GL009 | ๐ŸŸก MEDIUM | No rules/conditions |
136
+ | GL003 | ๐Ÿ”ต LOW | No cache defined |
137
+ | GL008 | ๐Ÿ”ต LOW | No artifacts defined |
138
+ | GL010 | ๐Ÿ”ต LOW | Missing job description |
139
+ | GL006 | โšช INFO | No stages defined |
140
+
141
+ ### Generic YAML (8 rules)
142
+
143
+ | Rule | Severity | Description |
144
+ |------|----------|-------------|
145
+ | YML005 | ๐ŸŸ  HIGH | Hardcoded credentials |
146
+ | YML001 | ๐ŸŸก MEDIUM | Inconsistent indentation |
147
+ | YML006 | ๐ŸŸก MEDIUM | Duplicate keys |
148
+ | YML002 | ๐Ÿ”ต LOW | Trailing whitespace |
149
+ | YML003 | ๐Ÿ”ต LOW | Line too long (>200 chars) |
150
+ | YML007 | ๐Ÿ”ต LOW | Empty values |
151
+ | YML004 | โšช INFO | Missing document start marker |
152
+ | YML008 | โšช INFO | File too long (>1000 lines) |
153
+
154
+ ## ๐Ÿ“Š Grading System
155
+
156
+ | Grade | Score | Description |
157
+ |-------|-------|-------------|
158
+ | A+ | 95-100 | Excellent โ€” production ready |
159
+ | A | 85-94 | Great โ€” minor improvements possible |
160
+ | B | 75-84 | Good โ€” some issues to address |
161
+ | C | 65-74 | Fair โ€” significant improvements needed |
162
+ | D | 50-64 | Poor โ€” many issues found |
163
+ | F | 0-49 | Failing โ€” critical issues present |
164
+
165
+ **Score deductions per finding:**
166
+ - ๐Ÿ”ด Critical: -15 points
167
+ - ๐ŸŸ  High: -8 points
168
+ - ๐ŸŸก Medium: -3 points
169
+ - ๐Ÿ”ต Low: -1 point
170
+ - โšช Info: 0 points
171
+
172
+ ## ๐Ÿ–ฅ๏ธ CLI Commands
173
+
174
+ ### `yaml-doctor lint <file>`
175
+
176
+ Lint a single YAML file with auto-detection.
177
+
178
+ ```bash
179
+ yaml-doctor lint deployment.yaml
180
+ yaml-doctor lint docker-compose.yml --html report.html
181
+ yaml-doctor lint .github/workflows/ci.yml -j report.json
182
+ ```
183
+
184
+ ### `yaml-doctor scan <directory>`
185
+
186
+ Scan all YAML files in a directory.
187
+
188
+ ```bash
189
+ yaml-doctor scan ./k8s/
190
+ yaml-doctor scan . --html dashboard.html
191
+ yaml-doctor scan ./configs --no-recursive
192
+ ```
193
+
194
+ ### `yaml-doctor demo`
195
+
196
+ Run a demo with built-in sample files.
197
+
198
+ ```bash
199
+ yaml-doctor demo
200
+ yaml-doctor demo --type kubernetes
201
+ yaml-doctor demo --type compose
202
+ yaml-doctor demo --html demo-report.html
203
+ ```
204
+
205
+ ### `yaml-doctor rules`
206
+
207
+ Display all 60 available lint rules.
208
+
209
+ ```bash
210
+ yaml-doctor rules
211
+ ```
212
+
213
+ ### `yaml-doctor fix <file>`
214
+
215
+ Show fix suggestions for all findings.
216
+
217
+ ```bash
218
+ yaml-doctor fix deployment.yaml
219
+ ```
220
+
221
+ ## ๐Ÿ”Œ CI/CD Integration
222
+
223
+ ### GitHub Actions
224
+
225
+ ```yaml
226
+ - name: YAML Lint
227
+ run: |
228
+ pip install yaml-doctor
229
+ yaml-doctor scan . --html report.html -j report.json
230
+
231
+ - name: Upload Report
232
+ uses: actions/upload-artifact@v4
233
+ with:
234
+ name: yaml-doctor-report
235
+ path: report.html
236
+ ```
237
+
238
+ ### GitLab CI
239
+
240
+ ```yaml
241
+ yaml-lint:
242
+ stage: test
243
+ script:
244
+ - pip install yaml-doctor
245
+ - yaml-doctor scan . --html report.html -j report.json
246
+ artifacts:
247
+ paths:
248
+ - report.html
249
+ - report.json
250
+ ```
251
+
252
+ ### Pre-commit Hook
253
+
254
+ ```yaml
255
+ # .pre-commit-config.yaml
256
+ repos:
257
+ - repo: local
258
+ hooks:
259
+ - id: yaml-doctor
260
+ name: yaml-doctor
261
+ entry: yaml-doctor lint
262
+ language: python
263
+ types: [yaml]
264
+ additional_dependencies: [yaml-doctor]
265
+ ```
266
+
267
+ ## ๐Ÿ“ Project Structure
268
+
269
+ ```
270
+ yaml-doctor/
271
+ โ”œโ”€โ”€ yaml_doctor/
272
+ โ”‚ โ”œโ”€โ”€ __init__.py # Package version
273
+ โ”‚ โ”œโ”€โ”€ __main__.py # python -m support
274
+ โ”‚ โ”œโ”€โ”€ cli.py # Click CLI commands
275
+ โ”‚ โ”œโ”€โ”€ scanner.py # Core scanning engine
276
+ โ”‚ โ”œโ”€โ”€ models.py # Data models & enums
277
+ โ”‚ โ”œโ”€โ”€ rules.py # Rule registry (60 rules)
278
+ โ”‚ โ”œโ”€โ”€ utils.py # Helper utilities
279
+ โ”‚ โ”œโ”€โ”€ demo.py # Demo sample data
280
+ โ”‚ โ”œโ”€โ”€ analyzers/
281
+ โ”‚ โ”‚ โ”œโ”€โ”€ __init__.py # File type detection
282
+ โ”‚ โ”‚ โ”œโ”€โ”€ kubernetes.py # 20 K8s rules
283
+ โ”‚ โ”‚ โ”œโ”€โ”€ compose.py # 12 Docker Compose rules
284
+ โ”‚ โ”‚ โ”œโ”€โ”€ github_actions.py # 10 GitHub Actions rules
285
+ โ”‚ โ”‚ โ”œโ”€โ”€ gitlab_ci.py # 10 GitLab CI rules
286
+ โ”‚ โ”‚ โ””โ”€โ”€ yaml_lint.py # 8 generic YAML rules
287
+ โ”‚ โ””โ”€โ”€ output/
288
+ โ”‚ โ”œโ”€โ”€ console.py # Rich terminal output
289
+ โ”‚ โ””โ”€โ”€ html_report.py # HTML dashboard reports
290
+ โ”œโ”€โ”€ tests/ # 188 tests
291
+ โ”œโ”€โ”€ pyproject.toml
292
+ โ”œโ”€โ”€ LICENSE
293
+ โ””โ”€โ”€ README.md
294
+ ```
295
+
296
+ ## ๐Ÿงช Development
297
+
298
+ ```bash
299
+ git clone https://github.com/SanjaySundarMurthy/yaml-doctor.git
300
+ cd yaml-doctor
301
+ pip install -e ".[dev]"
302
+ pytest
303
+ ruff check .
304
+ ```
305
+
306
+ ## ๐Ÿ“„ License
307
+
308
+ MIT License โ€” see [LICENSE](LICENSE) for details.
309
+
310
+ ## ๐Ÿ‘จโ€๐Ÿ’ป Author
311
+
312
+ **Sanjay S** โ€” [GitHub](https://github.com/SanjaySundarMurthy) ยท [Email](mailto:sanjaysundarmurthy@gmail.com)