Validate & lint K8s manifests, Helm charts, Docker Compose, CI configs โ 60+ rules with beautiful reports
Project description
๐ฉบ yaml-doctor
YAML Linter & Security Scanner for DevOps Engineers
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.
โจ Features
- ๐ 60+ Lint Rules โ Security, reliability, and best practice checks
- ๐ฏ Auto-Detection โ Automatically identifies Kubernetes, Docker Compose, GitHub Actions, GitLab CI, and Helm files
- ๐ Grading System โ A+ to F grades with detailed scoring
- ๐ HTML Dashboard โ Beautiful dark-theme HTML reports with severity charts
- ๐ JSON Export โ Machine-readable reports for CI/CD integration
- ๐ง Fix Suggestions โ Actionable remediation for every finding
- ๐ฎ Demo Mode โ Try it instantly with built-in sample files
- ๐ Zero Config โ Works out of the box, no configuration needed
๐ฆ Installation
pip install yaml-doctor
๐ Quick Start
# Lint a single file
yaml-doctor lint deployment.yaml
# Scan a directory recursively
yaml-doctor scan ./k8s/
# Run demo with sample files
yaml-doctor demo
# Show all 60 rules
yaml-doctor rules
# Get fix suggestions
yaml-doctor fix deployment.yaml
# Export HTML dashboard
yaml-doctor scan . --html report.html
# Export JSON report
yaml-doctor lint config.yaml -j report.json
๐ฏ Supported File Types
| Type | Detection | Rules |
|---|---|---|
| Kubernetes | apiVersion + kind |
20 rules (K8S001-K8S020) |
| Docker Compose | services + image/build |
12 rules (DC001-DC012) |
| GitHub Actions | .github/workflows/ + on/jobs |
10 rules (GHA001-GHA010) |
| GitLab CI | .gitlab-ci.yml + stages/script |
10 rules (GL001-GL010) |
| Helm | Chart.yaml / values.yaml |
K8s rules applied |
| Generic YAML | Any .yml/.yaml file |
8 rules (YML001-YML008) |
๐ Security Rules
Kubernetes (20 rules)
| Rule | Severity | Description |
|---|---|---|
| K8S001 | ๐ด CRITICAL | Container running as root |
| K8S004 | ๐ด CRITICAL | Privileged container |
| K8S002 | ๐ HIGH | Missing resource limits |
| K8S003 | ๐ HIGH | Missing resource requests |
| K8S005 | ๐ HIGH | Using :latest image tag |
| K8S006 | ๐ HIGH | Missing liveness probe |
| K8S011 | ๐ HIGH | Host network enabled |
| K8S012 | ๐ HIGH | Host PID enabled |
| K8S016 | ๐ HIGH | Secrets in environment variables |
| K8S007 | ๐ก MEDIUM | Missing readiness probe |
| K8S008 | ๐ก MEDIUM | Read-only filesystem not set |
| K8S013 | ๐ก MEDIUM | Single replica deployment |
| K8S014 | ๐ก MEDIUM | Privilege escalation allowed |
| K8S017 | ๐ก MEDIUM | Missing update strategy |
| K8S018 | ๐ก MEDIUM | Capabilities not dropped |
| K8S020 | ๐ก MEDIUM | Missing restart policy |
| K8S009 | ๐ต LOW | Missing recommended labels |
| K8S015 | ๐ต LOW | Missing PodDisruptionBudget |
| K8S019 | ๐ต LOW | No anti-affinity rules |
| K8S010 | โช INFO | Missing namespace |
Docker Compose (12 rules)
| Rule | Severity | Description |
|---|---|---|
| DC002 | ๐ด CRITICAL | Privileged container |
| DC001 | ๐ HIGH | Using :latest tag |
| DC005 | ๐ HIGH | Secrets in environment |
| DC009 | ๐ HIGH | Host volume with write access |
| DC012 | ๐ก MEDIUM | Host network mode |
| DC003 | ๐ก MEDIUM | No restart policy |
| DC004 | ๐ก MEDIUM | No healthcheck defined |
| DC007 | ๐ก MEDIUM | Exposed to all interfaces |
| DC011 | ๐ก MEDIUM | No depends_on |
| DC006 | ๐ต LOW | No resource limits |
| DC010 | ๐ต LOW | No logging configuration |
| DC008 | โช INFO | Deprecated version key |
GitHub Actions (10 rules)
| Rule | Severity | Description |
|---|---|---|
| GHA001 | ๐ด CRITICAL | Mutable action reference (using @main) |
| GHA002 | ๐ HIGH | Persist credentials enabled |
| GHA003 | ๐ HIGH | Secrets in run commands |
| GHA009 | ๐ HIGH | Script injection risk |
| GHA004 | ๐ก MEDIUM | Overly broad permissions |
| GHA005 | ๐ก MEDIUM | No job timeout |
| GHA006 | ๐ก MEDIUM | pull_request_target trigger |
| GHA007 | ๐ต LOW | No concurrency control |
| GHA008 | ๐ต LOW | Unversioned runner image |
| GHA010 | โช INFO | Missing workflow name |
GitLab CI (10 rules)
| Rule | Severity | Description |
|---|---|---|
| GL001 | ๐ HIGH | Secrets in script blocks |
| GL007 | ๐ HIGH | allow_failure on security jobs |
| GL002 | ๐ก MEDIUM | No retry configuration |
| GL004 | ๐ก MEDIUM | Using :latest image |
| GL005 | ๐ก MEDIUM | No timeout set |
| GL009 | ๐ก MEDIUM | No rules/conditions |
| GL003 | ๐ต LOW | No cache defined |
| GL008 | ๐ต LOW | No artifacts defined |
| GL010 | ๐ต LOW | Missing job description |
| GL006 | โช INFO | No stages defined |
Generic YAML (8 rules)
| Rule | Severity | Description |
|---|---|---|
| YML005 | ๐ HIGH | Hardcoded credentials |
| YML001 | ๐ก MEDIUM | Inconsistent indentation |
| YML006 | ๐ก MEDIUM | Duplicate keys |
| YML002 | ๐ต LOW | Trailing whitespace |
| YML003 | ๐ต LOW | Line too long (>200 chars) |
| YML007 | ๐ต LOW | Empty values |
| YML004 | โช INFO | Missing document start marker |
| YML008 | โช INFO | File too long (>1000 lines) |
๐ Grading System
| Grade | Score | Description |
|---|---|---|
| A+ | 95-100 | Excellent โ production ready |
| A | 85-94 | Great โ minor improvements possible |
| B | 75-84 | Good โ some issues to address |
| C | 65-74 | Fair โ significant improvements needed |
| D | 50-64 | Poor โ many issues found |
| F | 0-49 | Failing โ critical issues present |
Score deductions per finding:
- ๐ด Critical: -15 points
- ๐ High: -8 points
- ๐ก Medium: -3 points
- ๐ต Low: -1 point
- โช Info: 0 points
๐ฅ๏ธ CLI Commands
yaml-doctor lint <file>
Lint a single YAML file with auto-detection.
yaml-doctor lint deployment.yaml
yaml-doctor lint docker-compose.yml --html report.html
yaml-doctor lint .github/workflows/ci.yml -j report.json
yaml-doctor scan <directory>
Scan all YAML files in a directory.
yaml-doctor scan ./k8s/
yaml-doctor scan . --html dashboard.html
yaml-doctor scan ./configs --no-recursive
yaml-doctor demo
Run a demo with built-in sample files.
yaml-doctor demo
yaml-doctor demo --type kubernetes
yaml-doctor demo --type compose
yaml-doctor demo --html demo-report.html
yaml-doctor rules
Display all 60 available lint rules.
yaml-doctor rules
yaml-doctor fix <file>
Show fix suggestions for all findings.
yaml-doctor fix deployment.yaml
๐ CI/CD Integration
GitHub Actions
- name: YAML Lint
run: |
pip install yaml-doctor
yaml-doctor scan . --html report.html -j report.json
- name: Upload Report
uses: actions/upload-artifact@v4
with:
name: yaml-doctor-report
path: report.html
GitLab CI
yaml-lint:
stage: test
script:
- pip install yaml-doctor
- yaml-doctor scan . --html report.html -j report.json
artifacts:
paths:
- report.html
- report.json
Pre-commit Hook
# .pre-commit-config.yaml
repos:
- repo: local
hooks:
- id: yaml-doctor
name: yaml-doctor
entry: yaml-doctor lint
language: python
types: [yaml]
additional_dependencies: [yaml-doctor]
๐ Project Structure
yaml-doctor/
โโโ yaml_doctor/
โ โโโ __init__.py # Package version
โ โโโ __main__.py # python -m support
โ โโโ cli.py # Click CLI commands
โ โโโ scanner.py # Core scanning engine
โ โโโ models.py # Data models & enums
โ โโโ rules.py # Rule registry (60 rules)
โ โโโ utils.py # Helper utilities
โ โโโ demo.py # Demo sample data
โ โโโ analyzers/
โ โ โโโ __init__.py # File type detection
โ โ โโโ kubernetes.py # 20 K8s rules
โ โ โโโ compose.py # 12 Docker Compose rules
โ โ โโโ github_actions.py # 10 GitHub Actions rules
โ โ โโโ gitlab_ci.py # 10 GitLab CI rules
โ โ โโโ yaml_lint.py # 8 generic YAML rules
โ โโโ output/
โ โโโ console.py # Rich terminal output
โ โโโ html_report.py # HTML dashboard reports
โโโ tests/ # 188 tests
โโโ pyproject.toml
โโโ LICENSE
โโโ README.md
๐งช Development
git clone https://github.com/SanjaySundarMurthy/yaml-doctor.git
cd yaml-doctor
pip install -e ".[dev]"
pytest
ruff check .
๐ License
MIT License โ see LICENSE for details.
๐จโ๐ป Author
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yaml_doctor_cli-1.0.0.tar.gz.
File metadata
- Download URL: yaml_doctor_cli-1.0.0.tar.gz
- Upload date:
- Size: 34.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6810d9692893c89d5ce19c136907539510ac59e0ca13842ebb21036e4b18c3bf
|
|
| MD5 |
8b966682200cc6c9d71bc21d6de019c9
|
|
| BLAKE2b-256 |
2bbfb9b981f41cb4e32c99e07d6db15e0b100dbaf346086497da8b385000b506
|
File details
Details for the file yaml_doctor_cli-1.0.0-py3-none-any.whl.
File metadata
- Download URL: yaml_doctor_cli-1.0.0-py3-none-any.whl
- Upload date:
- Size: 33.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d22c4d915e409a1b2bef7593f7bc8bf01858542b717d9546e6d4c0c7408b976
|
|
| MD5 |
23ddacdf0e76228585708b38a975031d
|
|
| BLAKE2b-256 |
cf46039cad81487025c49b8d6427df689dafebb70fcfba41c3cf0e108f386948
|