controlgate 0.1.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 (41) hide show
  1. controlgate-0.1.0/PKG-INFO +184 -0
  2. controlgate-0.1.0/README.md +153 -0
  3. controlgate-0.1.0/pyproject.toml +84 -0
  4. controlgate-0.1.0/setup.cfg +4 -0
  5. controlgate-0.1.0/src/controlgate/__init__.py +3 -0
  6. controlgate-0.1.0/src/controlgate/__main__.py +297 -0
  7. controlgate-0.1.0/src/controlgate/catalog.py +115 -0
  8. controlgate-0.1.0/src/controlgate/catalog_downloader.py +103 -0
  9. controlgate-0.1.0/src/controlgate/config.py +152 -0
  10. controlgate-0.1.0/src/controlgate/data/nist80053r5_full_catalog_enriched.json +20236 -0
  11. controlgate-0.1.0/src/controlgate/diff_parser.py +107 -0
  12. controlgate-0.1.0/src/controlgate/engine.py +119 -0
  13. controlgate-0.1.0/src/controlgate/gates/__init__.py +33 -0
  14. controlgate-0.1.0/src/controlgate/gates/audit_gate.py +145 -0
  15. controlgate-0.1.0/src/controlgate/gates/base.py +61 -0
  16. controlgate-0.1.0/src/controlgate/gates/change_gate.py +125 -0
  17. controlgate-0.1.0/src/controlgate/gates/crypto_gate.py +178 -0
  18. controlgate-0.1.0/src/controlgate/gates/iac_gate.py +184 -0
  19. controlgate-0.1.0/src/controlgate/gates/iam_gate.py +117 -0
  20. controlgate-0.1.0/src/controlgate/gates/input_gate.py +158 -0
  21. controlgate-0.1.0/src/controlgate/gates/sbom_gate.py +133 -0
  22. controlgate-0.1.0/src/controlgate/gates/secrets_gate.py +205 -0
  23. controlgate-0.1.0/src/controlgate/models.py +155 -0
  24. controlgate-0.1.0/src/controlgate/reporters/__init__.py +7 -0
  25. controlgate-0.1.0/src/controlgate/reporters/json_reporter.py +35 -0
  26. controlgate-0.1.0/src/controlgate/reporters/markdown_reporter.py +104 -0
  27. controlgate-0.1.0/src/controlgate/reporters/sarif_reporter.py +108 -0
  28. controlgate-0.1.0/src/controlgate.egg-info/PKG-INFO +184 -0
  29. controlgate-0.1.0/src/controlgate.egg-info/SOURCES.txt +39 -0
  30. controlgate-0.1.0/src/controlgate.egg-info/dependency_links.txt +1 -0
  31. controlgate-0.1.0/src/controlgate.egg-info/entry_points.txt +2 -0
  32. controlgate-0.1.0/src/controlgate.egg-info/requires.txt +10 -0
  33. controlgate-0.1.0/src/controlgate.egg-info/top_level.txt +1 -0
  34. controlgate-0.1.0/tests/test_catalog.py +88 -0
  35. controlgate-0.1.0/tests/test_catalog_downloader.py +102 -0
  36. controlgate-0.1.0/tests/test_cli.py +355 -0
  37. controlgate-0.1.0/tests/test_coverage_gaps.py +437 -0
  38. controlgate-0.1.0/tests/test_diff_parser.py +117 -0
  39. controlgate-0.1.0/tests/test_engine.py +102 -0
  40. controlgate-0.1.0/tests/test_final_coverage.py +360 -0
  41. controlgate-0.1.0/tests/test_reporters.py +232 -0
@@ -0,0 +1,184 @@
1
+ Metadata-Version: 2.4
2
+ Name: controlgate
3
+ Version: 0.1.0
4
+ Summary: NIST RMF Cloud Security Hardening — Pre-Commit & Pre-Merge Compliance Gate
5
+ License: MIT
6
+ Project-URL: Homepage, https://github.com/sadayamuthu/controlgate
7
+ Project-URL: Repository, https://github.com/sadayamuthu/controlgate
8
+ Project-URL: Issues, https://github.com/sadayamuthu/controlgate/issues
9
+ Project-URL: Documentation, https://github.com/sadayamuthu/controlgate#readme
10
+ Keywords: nist,security,compliance,pre-commit,cloud,rmf,800-53
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Security
19
+ Classifier: Topic :: Software Development :: Quality Assurance
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ Requires-Dist: pyyaml>=6.0
23
+ Provides-Extra: dev
24
+ Requires-Dist: pytest>=7.0; extra == "dev"
25
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
26
+ Requires-Dist: ruff>=0.4.0; extra == "dev"
27
+ Requires-Dist: mypy>=1.10; extra == "dev"
28
+ Requires-Dist: build>=1.0; extra == "dev"
29
+ Requires-Dist: twine>=5.0; extra == "dev"
30
+ Requires-Dist: pre-commit>=3.7.0; extra == "dev"
31
+
32
+ # 🛡️ ControlGate
33
+
34
+ [![CI](https://github.com/sadayamuthu/controlgate/actions/workflows/ci.yml/badge.svg)](https://github.com/sadayamuthu/controlgate/actions/workflows/ci.yml)
35
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
36
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
37
+
38
+ **NIST RMF Cloud Security Hardening — Pre-Commit & Pre-Merge Compliance Gate**
39
+
40
+ ControlGate is an AI-powered agent skill that scans your code changes against the **NIST SP 800-53 Rev. 5** security framework before every commit and merge. It maps findings directly to specific NIST control IDs, providing traceable compliance evidence and actionable remediation guidance.
41
+
42
+ ## Quick Start
43
+
44
+ ```bash
45
+ # Install
46
+ pip install controlgate
47
+
48
+ # Scan staged changes
49
+ controlgate scan --mode pre-commit --format markdown
50
+
51
+ # Scan PR diff against main
52
+ controlgate scan --mode pr --target-branch main --format json markdown
53
+ ```
54
+
55
+ ## How It Works
56
+
57
+ ```
58
+ Developer writes code
59
+
60
+ git commit / Pull Request
61
+
62
+ ControlGate intercepts the diff
63
+
64
+ 8 Security Gates scan against 370 non-negotiable NIST controls
65
+
66
+ Verdict: BLOCK 🚫 / WARN ⚠️ / PASS ✅
67
+ ```
68
+
69
+ ## The Eight Security Gates
70
+
71
+ | # | Gate | NIST Families | What It Catches |
72
+ |---|------|---------------|-----------------|
73
+ | 1 | 🔑 Secrets | IA-5, SC-12, SC-28 | Hardcoded creds, API keys, private keys |
74
+ | 2 | 🔒 Crypto | SC-8, SC-13, SC-17 | Weak algorithms, missing TLS, `ssl_verify=False` |
75
+ | 3 | 🛡️ IAM | AC-3, AC-5, AC-6 | Wildcard IAM, missing auth, overprivileged roles |
76
+ | 4 | 📦 Supply Chain | SR-3, SR-11, SA-10 | Unpinned deps, missing lockfiles, build tampering |
77
+ | 5 | 🏗️ IaC | CM-2, CM-6, SC-7 | Public buckets, `0.0.0.0/0` rules, root containers |
78
+ | 6 | ✅ Input | SI-10, SI-11 | SQL injection, `eval()`, exposed stack traces |
79
+ | 7 | 📋 Audit | AU-2, AU-3, AU-12 | Missing security logging, PII in logs |
80
+ | 8 | 🔄 Change | CM-3, CM-4, CM-5 | Unauthorized config changes, missing CODEOWNERS |
81
+
82
+ ## Installation
83
+
84
+ ### From Source
85
+
86
+ ```bash
87
+ git clone https://github.com/YOUR_ORG/controlgate.git
88
+ cd controlgate
89
+ python3 -m venv .venv && source .venv/bin/activate
90
+ make install-dev
91
+ ```
92
+
93
+ ### As a Pre-Commit Hook
94
+
95
+ ```yaml
96
+ # .pre-commit-config.yaml
97
+ repos:
98
+ - repo: local
99
+ hooks:
100
+ - id: controlgate
101
+ name: ControlGate Security Scan
102
+ entry: python -m controlgate scan --mode pre-commit --format markdown
103
+ language: python
104
+ always_run: true
105
+ ```
106
+
107
+ ### As a GitHub Action
108
+
109
+ Copy [`hooks/github_action.yml`](hooks/github_action.yml) to `.github/workflows/controlgate.yml` in your repo.
110
+
111
+ ## Configuration
112
+
113
+ Create a `.controlgate.yml` in your project root:
114
+
115
+ ```yaml
116
+ baseline: moderate # low | moderate | high
117
+ catalog: baseline/nist80053r5_full_catalog_enriched.json
118
+
119
+ gates:
120
+ secrets: { enabled: true, action: block }
121
+ crypto: { enabled: true, action: block }
122
+ iam: { enabled: true, action: warn }
123
+ sbom: { enabled: true, action: warn }
124
+ iac: { enabled: true, action: block }
125
+ input: { enabled: true, action: block }
126
+ audit: { enabled: true, action: warn }
127
+ change: { enabled: true, action: warn }
128
+
129
+ thresholds:
130
+ block_on: [CRITICAL, HIGH]
131
+ warn_on: [MEDIUM]
132
+ ignore: [LOW]
133
+
134
+ exclusions:
135
+ paths: ["tests/**", "docs/**", "*.md"]
136
+ ```
137
+
138
+ ## CLI Usage
139
+
140
+ ```bash
141
+ # Scan staged changes (pre-commit mode)
142
+ controlgate scan --mode pre-commit --format markdown
143
+
144
+ # Scan PR diff
145
+ controlgate scan --mode pr --target-branch main --format json markdown sarif
146
+
147
+ # Scan a saved diff file
148
+ controlgate scan --diff-file path/to/diff --format json
149
+
150
+ # Output reports to directory
151
+ controlgate scan --output-dir .controlgate/reports --format json markdown sarif
152
+ ```
153
+
154
+ ## Output Formats
155
+
156
+ | Format | Use Case |
157
+ |--------|----------|
158
+ | `markdown` | PR comments, terminal output |
159
+ | `json` | Programmatic consumption, dashboards |
160
+ | `sarif` | GitHub Code Scanning integration |
161
+
162
+ ## Development
163
+
164
+ ```bash
165
+ make install-dev # Install with dev dependencies
166
+ make test # Run tests
167
+ make test-cov # Run tests with coverage
168
+ make lint # Lint with ruff
169
+ make format # Auto-format code
170
+ make typecheck # Type check with mypy
171
+ make check # Run all checks (lint + typecheck + test)
172
+ make build # Build distribution packages
173
+ ```
174
+
175
+ ## Data Source
176
+
177
+ Powered by the [NIST Cloud Security Baseline (NCSB)](https://github.com/sadayamuthu/nist-cloud-security-baseline) enriched catalog:
178
+ - **1,189** controls across 20 families
179
+ - **370** non-negotiable at Moderate baseline
180
+ - **247** code-relevant controls mapped to automated scanning rules
181
+
182
+ ## License
183
+
184
+ MIT
@@ -0,0 +1,153 @@
1
+ # 🛡️ ControlGate
2
+
3
+ [![CI](https://github.com/sadayamuthu/controlgate/actions/workflows/ci.yml/badge.svg)](https://github.com/sadayamuthu/controlgate/actions/workflows/ci.yml)
4
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
6
+
7
+ **NIST RMF Cloud Security Hardening — Pre-Commit & Pre-Merge Compliance Gate**
8
+
9
+ ControlGate is an AI-powered agent skill that scans your code changes against the **NIST SP 800-53 Rev. 5** security framework before every commit and merge. It maps findings directly to specific NIST control IDs, providing traceable compliance evidence and actionable remediation guidance.
10
+
11
+ ## Quick Start
12
+
13
+ ```bash
14
+ # Install
15
+ pip install controlgate
16
+
17
+ # Scan staged changes
18
+ controlgate scan --mode pre-commit --format markdown
19
+
20
+ # Scan PR diff against main
21
+ controlgate scan --mode pr --target-branch main --format json markdown
22
+ ```
23
+
24
+ ## How It Works
25
+
26
+ ```
27
+ Developer writes code
28
+
29
+ git commit / Pull Request
30
+
31
+ ControlGate intercepts the diff
32
+
33
+ 8 Security Gates scan against 370 non-negotiable NIST controls
34
+
35
+ Verdict: BLOCK 🚫 / WARN ⚠️ / PASS ✅
36
+ ```
37
+
38
+ ## The Eight Security Gates
39
+
40
+ | # | Gate | NIST Families | What It Catches |
41
+ |---|------|---------------|-----------------|
42
+ | 1 | 🔑 Secrets | IA-5, SC-12, SC-28 | Hardcoded creds, API keys, private keys |
43
+ | 2 | 🔒 Crypto | SC-8, SC-13, SC-17 | Weak algorithms, missing TLS, `ssl_verify=False` |
44
+ | 3 | 🛡️ IAM | AC-3, AC-5, AC-6 | Wildcard IAM, missing auth, overprivileged roles |
45
+ | 4 | 📦 Supply Chain | SR-3, SR-11, SA-10 | Unpinned deps, missing lockfiles, build tampering |
46
+ | 5 | 🏗️ IaC | CM-2, CM-6, SC-7 | Public buckets, `0.0.0.0/0` rules, root containers |
47
+ | 6 | ✅ Input | SI-10, SI-11 | SQL injection, `eval()`, exposed stack traces |
48
+ | 7 | 📋 Audit | AU-2, AU-3, AU-12 | Missing security logging, PII in logs |
49
+ | 8 | 🔄 Change | CM-3, CM-4, CM-5 | Unauthorized config changes, missing CODEOWNERS |
50
+
51
+ ## Installation
52
+
53
+ ### From Source
54
+
55
+ ```bash
56
+ git clone https://github.com/YOUR_ORG/controlgate.git
57
+ cd controlgate
58
+ python3 -m venv .venv && source .venv/bin/activate
59
+ make install-dev
60
+ ```
61
+
62
+ ### As a Pre-Commit Hook
63
+
64
+ ```yaml
65
+ # .pre-commit-config.yaml
66
+ repos:
67
+ - repo: local
68
+ hooks:
69
+ - id: controlgate
70
+ name: ControlGate Security Scan
71
+ entry: python -m controlgate scan --mode pre-commit --format markdown
72
+ language: python
73
+ always_run: true
74
+ ```
75
+
76
+ ### As a GitHub Action
77
+
78
+ Copy [`hooks/github_action.yml`](hooks/github_action.yml) to `.github/workflows/controlgate.yml` in your repo.
79
+
80
+ ## Configuration
81
+
82
+ Create a `.controlgate.yml` in your project root:
83
+
84
+ ```yaml
85
+ baseline: moderate # low | moderate | high
86
+ catalog: baseline/nist80053r5_full_catalog_enriched.json
87
+
88
+ gates:
89
+ secrets: { enabled: true, action: block }
90
+ crypto: { enabled: true, action: block }
91
+ iam: { enabled: true, action: warn }
92
+ sbom: { enabled: true, action: warn }
93
+ iac: { enabled: true, action: block }
94
+ input: { enabled: true, action: block }
95
+ audit: { enabled: true, action: warn }
96
+ change: { enabled: true, action: warn }
97
+
98
+ thresholds:
99
+ block_on: [CRITICAL, HIGH]
100
+ warn_on: [MEDIUM]
101
+ ignore: [LOW]
102
+
103
+ exclusions:
104
+ paths: ["tests/**", "docs/**", "*.md"]
105
+ ```
106
+
107
+ ## CLI Usage
108
+
109
+ ```bash
110
+ # Scan staged changes (pre-commit mode)
111
+ controlgate scan --mode pre-commit --format markdown
112
+
113
+ # Scan PR diff
114
+ controlgate scan --mode pr --target-branch main --format json markdown sarif
115
+
116
+ # Scan a saved diff file
117
+ controlgate scan --diff-file path/to/diff --format json
118
+
119
+ # Output reports to directory
120
+ controlgate scan --output-dir .controlgate/reports --format json markdown sarif
121
+ ```
122
+
123
+ ## Output Formats
124
+
125
+ | Format | Use Case |
126
+ |--------|----------|
127
+ | `markdown` | PR comments, terminal output |
128
+ | `json` | Programmatic consumption, dashboards |
129
+ | `sarif` | GitHub Code Scanning integration |
130
+
131
+ ## Development
132
+
133
+ ```bash
134
+ make install-dev # Install with dev dependencies
135
+ make test # Run tests
136
+ make test-cov # Run tests with coverage
137
+ make lint # Lint with ruff
138
+ make format # Auto-format code
139
+ make typecheck # Type check with mypy
140
+ make check # Run all checks (lint + typecheck + test)
141
+ make build # Build distribution packages
142
+ ```
143
+
144
+ ## Data Source
145
+
146
+ Powered by the [NIST Cloud Security Baseline (NCSB)](https://github.com/sadayamuthu/nist-cloud-security-baseline) enriched catalog:
147
+ - **1,189** controls across 20 families
148
+ - **370** non-negotiable at Moderate baseline
149
+ - **247** code-relevant controls mapped to automated scanning rules
150
+
151
+ ## License
152
+
153
+ MIT
@@ -0,0 +1,84 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "controlgate"
7
+ version = "0.1.0"
8
+ description = "NIST RMF Cloud Security Hardening — Pre-Commit & Pre-Merge Compliance Gate"
9
+ readme = "README.md"
10
+ license = {text = "MIT"}
11
+ requires-python = ">=3.10"
12
+ keywords = ["nist", "security", "compliance", "pre-commit", "cloud", "rmf", "800-53"]
13
+ classifiers = [
14
+ "Development Status :: 4 - Beta",
15
+ "Intended Audience :: Developers",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.10",
19
+ "Programming Language :: Python :: 3.11",
20
+ "Programming Language :: Python :: 3.12",
21
+ "Topic :: Security",
22
+ "Topic :: Software Development :: Quality Assurance",
23
+ ]
24
+ dependencies = [
25
+ "pyyaml>=6.0",
26
+ ]
27
+
28
+ [project.urls]
29
+ Homepage = "https://github.com/sadayamuthu/controlgate"
30
+ Repository = "https://github.com/sadayamuthu/controlgate"
31
+ Issues = "https://github.com/sadayamuthu/controlgate/issues"
32
+ Documentation = "https://github.com/sadayamuthu/controlgate#readme"
33
+
34
+ [project.optional-dependencies]
35
+ dev = [
36
+ "pytest>=7.0",
37
+ "pytest-cov>=4.0",
38
+ "ruff>=0.4.0",
39
+ "mypy>=1.10",
40
+ "build>=1.0",
41
+ "twine>=5.0",
42
+ "pre-commit>=3.7.0",
43
+ ]
44
+
45
+ [project.scripts]
46
+ controlgate = "controlgate.__main__:main"
47
+
48
+ [tool.setuptools.packages.find]
49
+ where = ["src"]
50
+
51
+ [tool.setuptools.package-data]
52
+ controlgate = ["data/*.json"]
53
+
54
+ [tool.pytest.ini_options]
55
+ testpaths = ["tests"]
56
+
57
+ [tool.coverage.run]
58
+ source = ["controlgate"]
59
+
60
+ [tool.coverage.report]
61
+ fail_under = 100
62
+ show_missing = true
63
+ exclude_lines = [
64
+ "pragma: no cover",
65
+ "if __name__",
66
+ ]
67
+
68
+ [tool.ruff]
69
+ target-version = "py310"
70
+ line-length = 100
71
+
72
+ [tool.ruff.lint]
73
+ select = ["E", "F", "W", "I", "N", "UP", "B", "SIM"]
74
+ ignore = ["E501"]
75
+
76
+ [tool.ruff.lint.isort]
77
+ known-first-party = ["controlgate"]
78
+
79
+ [tool.mypy]
80
+ python_version = "3.10"
81
+ warn_return_any = true
82
+ warn_unused_configs = true
83
+ disallow_untyped_defs = false
84
+ check_untyped_defs = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ """ControlGate — NIST RMF Cloud Security Hardening Compliance Gate."""
2
+
3
+ __version__ = "0.1.0"