technitium-dns-mcp 0.27.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 (39) hide show
  1. technitium_dns_mcp-0.27.0/LICENSE +21 -0
  2. technitium_dns_mcp-0.27.0/PKG-INFO +122 -0
  3. technitium_dns_mcp-0.27.0/README.md +94 -0
  4. technitium_dns_mcp-0.27.0/pyproject.toml +61 -0
  5. technitium_dns_mcp-0.27.0/scripts/security_sanitizer.py +246 -0
  6. technitium_dns_mcp-0.27.0/scripts/verify_api_integration.py +279 -0
  7. technitium_dns_mcp-0.27.0/setup.cfg +4 -0
  8. technitium_dns_mcp-0.27.0/technitium_dns_mcp/__init__.py +64 -0
  9. technitium_dns_mcp-0.27.0/technitium_dns_mcp/__main__.py +4 -0
  10. technitium_dns_mcp-0.27.0/technitium_dns_mcp/agent_data/IDENTITY.md +6 -0
  11. technitium_dns_mcp-0.27.0/technitium_dns_mcp/agent_server.py +73 -0
  12. technitium_dns_mcp-0.27.0/technitium_dns_mcp/api/__init__.py +1 -0
  13. technitium_dns_mcp-0.27.0/technitium_dns_mcp/api/api_client_base.py +77 -0
  14. technitium_dns_mcp-0.27.0/technitium_dns_mcp/api/api_client_dashboard.py +101 -0
  15. technitium_dns_mcp-0.27.0/technitium_dns_mcp/api/api_client_user.py +137 -0
  16. technitium_dns_mcp-0.27.0/technitium_dns_mcp/api/api_client_zones.py +694 -0
  17. technitium_dns_mcp-0.27.0/technitium_dns_mcp/api_client.py +11 -0
  18. technitium_dns_mcp-0.27.0/technitium_dns_mcp/auth.py +22 -0
  19. technitium_dns_mcp-0.27.0/technitium_dns_mcp/mcp/__init__.py +1 -0
  20. technitium_dns_mcp-0.27.0/technitium_dns_mcp/mcp/mcp_dashboard.py +56 -0
  21. technitium_dns_mcp-0.27.0/technitium_dns_mcp/mcp/mcp_user.py +76 -0
  22. technitium_dns_mcp-0.27.0/technitium_dns_mcp/mcp/mcp_zones.py +159 -0
  23. technitium_dns_mcp-0.27.0/technitium_dns_mcp/mcp_config.json +12 -0
  24. technitium_dns_mcp-0.27.0/technitium_dns_mcp/mcp_server.py +54 -0
  25. technitium_dns_mcp-0.27.0/technitium_dns_mcp/models.py +9 -0
  26. technitium_dns_mcp-0.27.0/technitium_dns_mcp.egg-info/PKG-INFO +122 -0
  27. technitium_dns_mcp-0.27.0/technitium_dns_mcp.egg-info/SOURCES.txt +37 -0
  28. technitium_dns_mcp-0.27.0/technitium_dns_mcp.egg-info/dependency_links.txt +1 -0
  29. technitium_dns_mcp-0.27.0/technitium_dns_mcp.egg-info/entry_points.txt +3 -0
  30. technitium_dns_mcp-0.27.0/technitium_dns_mcp.egg-info/requires.txt +16 -0
  31. technitium_dns_mcp-0.27.0/technitium_dns_mcp.egg-info/top_level.txt +7 -0
  32. technitium_dns_mcp-0.27.0/tests/conftest.py +21 -0
  33. technitium_dns_mcp-0.27.0/tests/test_agent_integration.py +10 -0
  34. technitium_dns_mcp-0.27.0/tests/test_api_client.py +378 -0
  35. technitium_dns_mcp-0.27.0/tests/test_auth.py +10 -0
  36. technitium_dns_mcp-0.27.0/tests/test_concept_parity.py +7 -0
  37. technitium_dns_mcp-0.27.0/tests/test_init_dynamics.py +8 -0
  38. technitium_dns_mcp-0.27.0/tests/test_mcp_handlers.py +73 -0
  39. technitium_dns_mcp-0.27.0/tests/test_startup.py +9 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Knuckles Team
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,122 @@
1
+ Metadata-Version: 2.4
2
+ Name: technitium-dns-mcp
3
+ Version: 0.27.0
4
+ Summary: Technitium DNS Server MCP Server and Agent for Agentic AI!
5
+ Author-email: Audel Rouhi <knucklessg1@gmail.com>
6
+ License: MIT
7
+ Classifier: Development Status :: 4 - Beta
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Environment :: Console
10
+ Classifier: Operating System :: POSIX :: Linux
11
+ Classifier: Programming Language :: Python :: 3
12
+ Requires-Python: <3.14,>=3.11
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: agent-utilities>=0.41.0
16
+ Provides-Extra: mcp
17
+ Requires-Dist: agent-utilities[mcp]>=0.41.0; extra == "mcp"
18
+ Provides-Extra: agent
19
+ Requires-Dist: agent-utilities[agent,logfire]>=0.41.0; extra == "agent"
20
+ Provides-Extra: all
21
+ Requires-Dist: agent-utilities[agent,logfire,mcp]>=0.41.0; extra == "all"
22
+ Provides-Extra: test
23
+ Requires-Dist: pytest-xdist>=3.6.0; extra == "test"
24
+ Requires-Dist: pytest; extra == "test"
25
+ Requires-Dist: pytest-asyncio; extra == "test"
26
+ Requires-Dist: pytest-cov; extra == "test"
27
+ Dynamic: license-file
28
+
29
+ # Technitium DNS MCP Server & Agent
30
+
31
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
32
+ [![Python Version](https://img.shields.io/badge/python-3.11%20%7C%203.12-blue)](pyproject.toml)
33
+
34
+ An ultra-premium, production-grade Model Context Protocol (MCP) server and graph-based Pydantic AI agent integration for **Technitium DNS Server**. Exposes comprehensive, 100% covered REST API endpoints for user SSO, analytics metrics, authoritative zones, DNSSEC, and dynamic DNS record operations.
35
+
36
+ ---
37
+
38
+ ## šŸš€ Key Features
39
+
40
+ - **100% API Coverage**: Complete mapping of Technitium User/SSO, Dashboard Analytics, Zone Management, DNSSEC, and Record Actions.
41
+ - **FastMCP Protocol Integration**: Dynamically registers stdio and streamable-http endpoints for large-scale AI tool discovery.
42
+ - **Autonomous Agent Layer**: Bundled with a Pydantic AI Agent that operates natively using advanced instruction graphs and local toolchains.
43
+ - **Strict Compliance**: Designed in accordance with standard codebase-wide architectural patterns (`agent-packages`).
44
+
45
+ ---
46
+
47
+ ## šŸ› ļø Installation & Setup
48
+
49
+ Install package in editable mode with all optional dependencies:
50
+
51
+ ```bash
52
+ pip install -e .[all]
53
+ ```
54
+
55
+ ### Environment Variables
56
+
57
+ Configure `.env` using `.env.example` as a template:
58
+
59
+ ```bash
60
+ # Server Endpoint & TLS
61
+ TECHNITIUM_DNS_URL=http://localhost:5380
62
+ TECHNITIUM_DNS_SSL_VERIFY=True
63
+
64
+ # Credentials / API Tokens
65
+ TECHNITIUM_DNS_TOKEN=your-secure-token
66
+ ```
67
+
68
+ ---
69
+
70
+ ## āš™ļø Dynamic Tool Selection & Visibility
71
+
72
+ This MCP server supports dynamic toolset selection and visibility filtering at runtime. This allows you to restrict the set of exposed tools in order to prevent blowing up the LLM's context window.
73
+
74
+ You can configure tool filtering via multiple input channels:
75
+
76
+ - **CLI Arguments:** Pass `--tools` or `--toolsets` (or their disabled counterparts `--disabled-tools` and `--disabled-toolsets`) during startup.
77
+ - **Environment Variables:** Define standard environment variables:
78
+ - `MCP_ENABLED_TOOLS` / `MCP_DISABLED_TOOLS`
79
+ - `MCP_ENABLED_TAGS` / `MCP_DISABLED_TAGS`
80
+ - **HTTP SSE Request Headers:** Pass custom headers during transport initialization:
81
+ - `x-mcp-enabled-tools` / `x-mcp-disabled-tools`
82
+ - `x-mcp-enabled-tags` / `x-mcp-disabled-tags`
83
+ - **HTTP SSE Request Query Parameters:** Append query parameters directly to your transport connection URL:
84
+ - `?tools=tool1,tool2`
85
+ - `?tags=tag1`
86
+
87
+ When query strings or parameters are supplied, an LLM-free **Knowledge Graph resolution layer** (using `DynamicToolOrchestrator`) matches query intents against known tool tags, names, or descriptions, with safe fallback and automated 24-hour background cache refreshing.
88
+
89
+
90
+ ---
91
+
92
+ ## šŸ–„ļø Running the Servers
93
+
94
+ ### Run MCP Server (stdio by default)
95
+
96
+ ```bash
97
+ technitium-dns-mcp
98
+ ```
99
+
100
+ Or start a streamable HTTP server:
101
+
102
+ ```bash
103
+ TRANSPORT=streamable-http HOST=0.0.0.0 PORT=8000 technitium-dns-mcp
104
+ ```
105
+
106
+ ### Run Pydantic AI Agent
107
+
108
+ ```bash
109
+ technitium-dns-agent --mcp-url http://localhost:8000
110
+ ```
111
+
112
+ ---
113
+
114
+ ## 🧪 Running Tests
115
+
116
+ Ensure high reliability across all components with standard test suites:
117
+
118
+ ```bash
119
+ pytest -v tests/
120
+ ```
121
+
122
+ Version: 0.27.0
@@ -0,0 +1,94 @@
1
+ # Technitium DNS MCP Server & Agent
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
4
+ [![Python Version](https://img.shields.io/badge/python-3.11%20%7C%203.12-blue)](pyproject.toml)
5
+
6
+ An ultra-premium, production-grade Model Context Protocol (MCP) server and graph-based Pydantic AI agent integration for **Technitium DNS Server**. Exposes comprehensive, 100% covered REST API endpoints for user SSO, analytics metrics, authoritative zones, DNSSEC, and dynamic DNS record operations.
7
+
8
+ ---
9
+
10
+ ## šŸš€ Key Features
11
+
12
+ - **100% API Coverage**: Complete mapping of Technitium User/SSO, Dashboard Analytics, Zone Management, DNSSEC, and Record Actions.
13
+ - **FastMCP Protocol Integration**: Dynamically registers stdio and streamable-http endpoints for large-scale AI tool discovery.
14
+ - **Autonomous Agent Layer**: Bundled with a Pydantic AI Agent that operates natively using advanced instruction graphs and local toolchains.
15
+ - **Strict Compliance**: Designed in accordance with standard codebase-wide architectural patterns (`agent-packages`).
16
+
17
+ ---
18
+
19
+ ## šŸ› ļø Installation & Setup
20
+
21
+ Install package in editable mode with all optional dependencies:
22
+
23
+ ```bash
24
+ pip install -e .[all]
25
+ ```
26
+
27
+ ### Environment Variables
28
+
29
+ Configure `.env` using `.env.example` as a template:
30
+
31
+ ```bash
32
+ # Server Endpoint & TLS
33
+ TECHNITIUM_DNS_URL=http://localhost:5380
34
+ TECHNITIUM_DNS_SSL_VERIFY=True
35
+
36
+ # Credentials / API Tokens
37
+ TECHNITIUM_DNS_TOKEN=your-secure-token
38
+ ```
39
+
40
+ ---
41
+
42
+ ## āš™ļø Dynamic Tool Selection & Visibility
43
+
44
+ This MCP server supports dynamic toolset selection and visibility filtering at runtime. This allows you to restrict the set of exposed tools in order to prevent blowing up the LLM's context window.
45
+
46
+ You can configure tool filtering via multiple input channels:
47
+
48
+ - **CLI Arguments:** Pass `--tools` or `--toolsets` (or their disabled counterparts `--disabled-tools` and `--disabled-toolsets`) during startup.
49
+ - **Environment Variables:** Define standard environment variables:
50
+ - `MCP_ENABLED_TOOLS` / `MCP_DISABLED_TOOLS`
51
+ - `MCP_ENABLED_TAGS` / `MCP_DISABLED_TAGS`
52
+ - **HTTP SSE Request Headers:** Pass custom headers during transport initialization:
53
+ - `x-mcp-enabled-tools` / `x-mcp-disabled-tools`
54
+ - `x-mcp-enabled-tags` / `x-mcp-disabled-tags`
55
+ - **HTTP SSE Request Query Parameters:** Append query parameters directly to your transport connection URL:
56
+ - `?tools=tool1,tool2`
57
+ - `?tags=tag1`
58
+
59
+ When query strings or parameters are supplied, an LLM-free **Knowledge Graph resolution layer** (using `DynamicToolOrchestrator`) matches query intents against known tool tags, names, or descriptions, with safe fallback and automated 24-hour background cache refreshing.
60
+
61
+
62
+ ---
63
+
64
+ ## šŸ–„ļø Running the Servers
65
+
66
+ ### Run MCP Server (stdio by default)
67
+
68
+ ```bash
69
+ technitium-dns-mcp
70
+ ```
71
+
72
+ Or start a streamable HTTP server:
73
+
74
+ ```bash
75
+ TRANSPORT=streamable-http HOST=0.0.0.0 PORT=8000 technitium-dns-mcp
76
+ ```
77
+
78
+ ### Run Pydantic AI Agent
79
+
80
+ ```bash
81
+ technitium-dns-agent --mcp-url http://localhost:8000
82
+ ```
83
+
84
+ ---
85
+
86
+ ## 🧪 Running Tests
87
+
88
+ Ensure high reliability across all components with standard test suites:
89
+
90
+ ```bash
91
+ pytest -v tests/
92
+ ```
93
+
94
+ Version: 0.27.0
@@ -0,0 +1,61 @@
1
+ [build-system]
2
+ requires = [ "setuptools>=80.9.0", "wheel",]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "technitium-dns-mcp"
7
+ version = "0.27.0"
8
+ description = "Technitium DNS Server MCP Server and Agent for Agentic AI!"
9
+ readme = "README.md"
10
+ classifiers = [
11
+ "Development Status :: 4 - Beta",
12
+ "License :: OSI Approved :: MIT License",
13
+ "Environment :: Console",
14
+ "Operating System :: POSIX :: Linux",
15
+ "Programming Language :: Python :: 3",
16
+ ]
17
+ requires-python = ">=3.11, <3.14"
18
+ dependencies = [
19
+ "agent-utilities>=0.41.0",
20
+ ]
21
+ [[project.authors]]
22
+ name = "Audel Rouhi"
23
+ email = "knucklessg1@gmail.com"
24
+
25
+ [project.license]
26
+ text = "MIT"
27
+
28
+ [project.optional-dependencies]
29
+ mcp = [ "agent-utilities[mcp]>=0.41.0", ]
30
+ agent = [ "agent-utilities[agent,logfire]>=0.41.0", ]
31
+ all = [ "agent-utilities[mcp,agent,logfire]>=0.41.0", ]
32
+ test = [ "pytest-xdist>=3.6.0", "pytest", "pytest-asyncio", "pytest-cov", ]
33
+
34
+ [project.scripts]
35
+ technitium-dns-mcp = "technitium_dns_mcp.mcp_server:mcp_server"
36
+ technitium-dns-agent = "technitium_dns_mcp.agent_server:agent_server"
37
+
38
+ [tool.setuptools]
39
+ include-package-data = true
40
+
41
+ [tool.ruff]
42
+ line-length = 88
43
+ target-version = "py310"
44
+
45
+ [tool.mypy]
46
+ python_version = "3.10"
47
+ ignore_missing_imports = true
48
+ check_untyped_defs = true
49
+
50
+ [dependency-groups]
51
+ dev = [ "pytest-timeout>=2.4.0", ]
52
+
53
+ [tool.setuptools.package-data]
54
+ technitium_dns_mcp = [ "mcp_config.json", "agent_data/**", ]
55
+
56
+ [tool.ruff.lint]
57
+ select = [ "E", "F", "I", "UP", "B", ]
58
+ ignore = [ "E402", "E501", "B008", ]
59
+
60
+ [tool.setuptools.packages.find]
61
+ where = [ ".", ]
@@ -0,0 +1,246 @@
1
+ #!/usr/bin/env python3
2
+ import os
3
+ import re
4
+ import subprocess
5
+ import sys
6
+ from pathlib import Path
7
+
8
+ # Config
9
+ ALLOWED_TXT_NAMES = {"requirements.txt", "requirements-dev.txt"}
10
+ TRANSIENT_PY_PATTERNS = [
11
+ re.compile(r"^test_.*\.py$"),
12
+ re.compile(r"^fix_.*\.py$"),
13
+ re.compile(r"^debug_.*\.py$"),
14
+ re.compile(r"^scratch_.*\.py$"),
15
+ re.compile(r"^temp_.*\.py$"),
16
+ ]
17
+
18
+ SECRET_PATTERNS = [
19
+ ("GitHub PAT", re.compile(r"ghp_[A-Za-z0-9_]{36,255}")),
20
+ ("GitHub Fine-grained PAT", re.compile(r"github_pat_[A-Za-z0-9_]{82,255}")),
21
+ ("GitLab PAT", re.compile(r"glpat-[A-Za-z0-9\-]{20,255}")),
22
+ (
23
+ "Generic Secret Assignment",
24
+ re.compile(
25
+ r"secret[A-Za-z0-9_]*\s*[:=]\s*['\"][A-Za-z0-9_\-\.\~\*]{16,255}['\"]",
26
+ re.IGNORECASE,
27
+ ),
28
+ ),
29
+ (
30
+ "Generic Token Assignment",
31
+ re.compile(
32
+ r"token\s*[:=]\s*['\"][A-Za-z0-9_\-\.\~\*]{16,255}['\"]", re.IGNORECASE
33
+ ),
34
+ ),
35
+ ]
36
+
37
+ EXCLUDED_DIRS = {
38
+ ".git",
39
+ ".venv",
40
+ "venv",
41
+ "node_modules",
42
+ "build",
43
+ "dist",
44
+ "__pycache__",
45
+ ".tox",
46
+ ".specify",
47
+ }
48
+ EXCLUDED_EXTENSIONS = {
49
+ ".png",
50
+ ".jpg",
51
+ ".jpeg",
52
+ ".gif",
53
+ ".webp",
54
+ ".ico",
55
+ ".pyc",
56
+ ".db",
57
+ ".kuzu",
58
+ ".sqlite",
59
+ ".sqlite3",
60
+ ".zip",
61
+ ".tar.gz",
62
+ ".tgz",
63
+ ".bz2",
64
+ ".xz",
65
+ ".pdf",
66
+ ".bin",
67
+ ".exe",
68
+ ".dll",
69
+ ".so",
70
+ ".dylib",
71
+ ".woff",
72
+ ".woff2",
73
+ ".eot",
74
+ ".ttf",
75
+ ".mp4",
76
+ ".mp3",
77
+ ".wav",
78
+ ".lock",
79
+ ".svg",
80
+ }
81
+
82
+ # Placeholder / Mock indicators
83
+ PLACEHOLDER_SUBSTRINGS = [
84
+ "1234567890",
85
+ "abcdef12345",
86
+ "abc123youandme",
87
+ "askdfalskdvjas",
88
+ "your_",
89
+ "YOUR_",
90
+ "your-",
91
+ "dummy",
92
+ "DUMMY",
93
+ "example",
94
+ "EXAMPLE",
95
+ "mock",
96
+ "MOCK",
97
+ "test_token",
98
+ "test_secret",
99
+ "glpat-askdfalskdvjas",
100
+ "github_pat_12345",
101
+ "glpat-abc123youandme",
102
+ "github_pat_...",
103
+ "glpat-*************",
104
+ "ghp_*************",
105
+ "github_pat_*************",
106
+ "token_*************",
107
+ "secret_*************",
108
+ "glpat-abc",
109
+ "ghp_abc",
110
+ "github_pat_abc",
111
+ "${env:",
112
+ ]
113
+
114
+
115
+ def is_placeholder(match_str: str) -> bool:
116
+ match_lower = match_str.lower()
117
+ for placeholder in PLACEHOLDER_SUBSTRINGS:
118
+ if placeholder in match_lower:
119
+ return True
120
+
121
+ # Check if match is mostly asterisks or single repeated char
122
+ cleaned = match_str.replace("'", "").replace('"', "").strip()
123
+ if not cleaned:
124
+ return True
125
+
126
+ # Check if there are sequences of asterisks indicating masked values
127
+ if "*" in cleaned:
128
+ # e.g., glpat-*************
129
+ return True
130
+
131
+ return False
132
+
133
+
134
+ def get_repo_files(repo_path: Path):
135
+ try:
136
+ result = subprocess.run(
137
+ ["git", "ls-files", "--cached", "--others", "--exclude-standard"],
138
+ cwd=str(repo_path),
139
+ capture_output=True,
140
+ text=True,
141
+ check=True,
142
+ )
143
+ files = []
144
+ for line in result.stdout.splitlines():
145
+ if line.strip():
146
+ # Avoid files inside excluded directories
147
+ parts = Path(line.strip()).parts
148
+ if not any(part in EXCLUDED_DIRS for part in parts):
149
+ files.append(repo_path / line.strip())
150
+ return files
151
+ except Exception:
152
+ # Fallback to manual recursive scan
153
+ files = []
154
+ for root, dirs, walk_files in os.walk(str(repo_path)):
155
+ dirs[:] = [
156
+ d for d in dirs if d not in EXCLUDED_DIRS and not d.startswith(".")
157
+ ]
158
+ for file in walk_files:
159
+ files.append(Path(root) / file)
160
+ return files
161
+
162
+
163
+ def scan_repository(repo_path: Path):
164
+ violations = []
165
+ files_to_scan = get_repo_files(repo_path)
166
+
167
+ for file_path in files_to_scan:
168
+ if not file_path.is_file():
169
+ continue
170
+
171
+ # 1. Check root level naming constraints
172
+ if file_path.parent == repo_path:
173
+ # Check txt files
174
+ if file_path.suffix == ".txt":
175
+ if file_path.name.lower() not in ALLOWED_TXT_NAMES:
176
+ violations.append(
177
+ f"Non-standard root-level text file detected: '{file_path.name}'. Only 'requirements.txt' and 'requirements-dev.txt' are allowed."
178
+ )
179
+ # Check transient py files
180
+ elif file_path.suffix == ".py":
181
+ for pattern in TRANSIENT_PY_PATTERNS:
182
+ if pattern.match(file_path.name):
183
+ violations.append(
184
+ f"Transient/temporary script detected in root: '{file_path.name}'. Please move it to a subfolder or delete it."
185
+ )
186
+ break
187
+
188
+ # 2. Check for secrets
189
+ if file_path.suffix.lower() in EXCLUDED_EXTENSIONS:
190
+ continue
191
+
192
+ if file_path.name == "security_sanitizer.py":
193
+ continue
194
+
195
+ try:
196
+ content = file_path.read_text(encoding="utf-8", errors="ignore")
197
+ lines = content.splitlines()
198
+
199
+ for idx, line in enumerate(lines, 1):
200
+ if any(
201
+ bypass in line
202
+ for bypass in [
203
+ "# sanitizer:ignore",
204
+ "# sanitizer-ignore",
205
+ "# nosec",
206
+ ]
207
+ ):
208
+ continue
209
+
210
+ for label, pattern in SECRET_PATTERNS:
211
+ for match in pattern.findall(line):
212
+ match_str = match[0] if isinstance(match, tuple) else match
213
+ if not is_placeholder(match_str):
214
+ rel_path = file_path.relative_to(repo_path)
215
+ violations.append(
216
+ f"Potential unmasked secret ({label}) detected in {rel_path}:{idx}\n"
217
+ f" Line: {line.strip()}"
218
+ )
219
+ except Exception:
220
+ pass
221
+
222
+ return violations
223
+
224
+
225
+ def main():
226
+ repo_path = Path.cwd()
227
+
228
+ print("šŸ”’ Running Security and Garbage Sanitizer...")
229
+ violations = scan_repository(repo_path)
230
+
231
+ if violations:
232
+ print("\nāŒ SECURITY AND GARBAGE VALIDATION FAILED!")
233
+ print("Please correct the following issues before committing:")
234
+ for idx, violation in enumerate(violations, 1):
235
+ print(f"\n[{idx}] {violation}")
236
+ print(
237
+ "\nNote: To bypass secret checks on specific lines, append '# sanitizer:ignore' to the end of the line."
238
+ )
239
+ sys.exit(1)
240
+
241
+ print("āœ… All checks passed! No root garbage or unmasked secrets detected.")
242
+ sys.exit(0)
243
+
244
+
245
+ if __name__ == "__main__":
246
+ main()