deployproof 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 (32) hide show
  1. deployproof-0.1.0/LICENSE +21 -0
  2. deployproof-0.1.0/PKG-INFO +111 -0
  3. deployproof-0.1.0/README.md +82 -0
  4. deployproof-0.1.0/pyproject.toml +50 -0
  5. deployproof-0.1.0/setup.cfg +4 -0
  6. deployproof-0.1.0/src/deployproof/__init__.py +3 -0
  7. deployproof-0.1.0/src/deployproof/cli.py +288 -0
  8. deployproof-0.1.0/src/deployproof/dependencies.py +874 -0
  9. deployproof-0.1.0/src/deployproof/diff.py +234 -0
  10. deployproof-0.1.0/src/deployproof/mutator.py +475 -0
  11. deployproof-0.1.0/src/deployproof/reporter.py +281 -0
  12. deployproof-0.1.0/src/deployproof/secrets.py +221 -0
  13. deployproof-0.1.0/src/deployproof/symlinks.py +156 -0
  14. deployproof-0.1.0/src/deployproof/wsl.py +147 -0
  15. deployproof-0.1.0/src/deployproof.egg-info/PKG-INFO +111 -0
  16. deployproof-0.1.0/src/deployproof.egg-info/SOURCES.txt +30 -0
  17. deployproof-0.1.0/src/deployproof.egg-info/dependency_links.txt +1 -0
  18. deployproof-0.1.0/src/deployproof.egg-info/entry_points.txt +2 -0
  19. deployproof-0.1.0/src/deployproof.egg-info/requires.txt +5 -0
  20. deployproof-0.1.0/src/deployproof.egg-info/top_level.txt +1 -0
  21. deployproof-0.1.0/tests/test_cli.py +88 -0
  22. deployproof-0.1.0/tests/test_cli_dependency_scan.py +206 -0
  23. deployproof-0.1.0/tests/test_dependencies_extractor.py +203 -0
  24. deployproof-0.1.0/tests/test_dependencies_pypi.py +105 -0
  25. deployproof-0.1.0/tests/test_diff.py +104 -0
  26. deployproof-0.1.0/tests/test_edge_cases_validation.py +137 -0
  27. deployproof-0.1.0/tests/test_mutation_suites.py +96 -0
  28. deployproof-0.1.0/tests/test_mutator.py +53 -0
  29. deployproof-0.1.0/tests/test_secrets.py +143 -0
  30. deployproof-0.1.0/tests/test_stress_regressions.py +135 -0
  31. deployproof-0.1.0/tests/test_symlinks.py +210 -0
  32. deployproof-0.1.0/tests/test_wsl.py +84 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 SVSPraveen
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,111 @@
1
+ Metadata-Version: 2.4
2
+ Name: deployproof
3
+ Version: 0.1.0
4
+ Summary: A deterministic pre-push verification tool that catches untested AI code, leaked credentials, sandbox escapes, and hallucinated packages before you ship.
5
+ Author: SVS Praveen
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/SVSPraveen/deployproof
8
+ Project-URL: Documentation, https://github.com/SVSPraveen/deployproof#readme
9
+ Project-URL: Repository, https://github.com/SVSPraveen/deployproof.git
10
+ Project-URL: Bug Tracker, https://github.com/SVSPraveen/deployproof/issues
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Security
19
+ Classifier: Topic :: Software Development :: Quality Assurance
20
+ Classifier: Topic :: Software Development :: Testing
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
26
+ Requires-Dist: build>=1.0.0; extra == "dev"
27
+ Requires-Dist: twine>=4.0.0; extra == "dev"
28
+ Dynamic: license-file
29
+
30
+ # DeployProof
31
+
32
+ > A pre-push verification tool for AI-assisted codebases: mutation testing, credential scanning, sandbox-escape detection, and dependency hallucination checks.
33
+
34
+ <!-- Once the package is published to PyPI, replace the two static badges below with:
35
+ [![PyPI version](https://img.shields.io/pypi/v/deployproof)](https://pypi.org/project/deployproof/)
36
+ [![Python](https://img.shields.io/pypi/pyversions/deployproof)](https://pypi.org/project/deployproof/) -->
37
+ [![PyPI](https://img.shields.io/badge/PyPI-not_yet_published-lightgrey)](https://pypi.org/project/deployproof/)
38
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
39
+ [![Python](https://img.shields.io/badge/python-3.10%2B-blue)](https://pypi.org/project/deployproof/)
40
+ [![CI](https://github.com/SVSPraveen/deployproof/actions/workflows/ci.yml/badge.svg)](https://github.com/SVSPraveen/deployproof/actions/workflows/ci.yml)
41
+
42
+ ---
43
+
44
+ ## Why This Exists
45
+
46
+ AI-assisted development introduces failure modes that standard tools miss: test suites with high line coverage but near-zero mutation scores, hardcoded credentials generated in passing, symlinks that deceive approval prompts into escaping the repository sandbox, and package names hallucinated by LLMs that don't exist on PyPI. DeployProof catches these at the pre-push stage, before they reach CI or production.
47
+
48
+ ## Install
49
+
50
+ ```bash
51
+ pip install deployproof
52
+ ```
53
+
54
+ Requires Python 3.10+.
55
+
56
+ ## Quickstart
57
+
58
+ Initialize in your repository:
59
+
60
+ ```bash
61
+ deployproof init
62
+ ```
63
+
64
+ Run all verification checks against changes in the current session:
65
+
66
+ ```bash
67
+ deployproof check
68
+ ```
69
+
70
+ Output includes a section for each check — symlink scan, secrets scan, dependency scan, and mutation score — with a pass/fail line at the bottom. Exit code is non-zero on any finding that should block a push.
71
+
72
+ ## What It Checks
73
+
74
+ - **Mutation Score** — Mutates AST operators (`>=`, `==`, `and`, `or`, `*`, numeric constants, comparisons) in modified files and runs your test suite against each mutant. Reports surviving mutants and a percentage score. Does not use line coverage.
75
+ - **Secrets and Credentials** — Scans modified files for hardcoded API keys (OpenAI, Anthropic, AWS, GitHub, Stripe, private keys) and tracked `.env` files using pattern matching and entropy analysis.
76
+ - **Symlink and Sandbox Escape** — Resolves symbolic links and flags any whose target escapes the repository root (CWE-61 / CWE-451). Catches the class of path-traversal trick used in the GhostApproval disclosure (Wiz Research, July 2026).
77
+ - **Dependency and Slopsquatting** — For each new import or manifest entry introduced in the diff, queries the PyPI JSON API and checks registration age. Packages that don't exist (HTTP 404) are flagged HIGH RISK; packages registered within the last 30 days are flagged MEDIUM RISK. Network errors are reported as UNKNOWN — never silently treated as safe.
78
+
79
+ ## What This Doesn't Do
80
+
81
+ - **Not a full-repo audit.** Checks are scoped to files changed in the current session (git diff). Files you haven't touched are not re-evaluated.
82
+ - **Python only.** Mutation testing and import extraction currently support Python files only. Other languages are not scanned.
83
+ - **No auto-fix.** DeployProof reports findings; it does not modify your code, rewrite imports, or suggest patches.
84
+ - **No IDE plugin yet.** There is no VS Code extension or JetBrains plugin. The CLI is the interface. IDE integration is on the roadmap.
85
+
86
+ ## See It Catch Real Bugs
87
+
88
+ Clone this repository and run the standalone stress-test suite to see DeployProof evaluate 7 planted edge cases:
89
+
90
+ ```bash
91
+ python stress_fixtures/run_stress_tests.py
92
+ ```
93
+
94
+ Fixtures cover weak test suites, zero-test orphan modules, planted OpenAI/AWS credentials, and GhostApproval sandbox-escape traps.
95
+
96
+ ## Status & Roadmap
97
+
98
+ - **Current (v0.1.0):** Diff-scoped AST mutation testing, secrets scanner, GhostApproval symlink sandbox-escape detector, PyPI dependency hallucination / slopsquatting scanner, and Tier 2 CI verification via GitHub Actions (mutmut).
99
+ - **Next:** Multi-language mutation support and expanded ecosystem rule packs.
100
+
101
+ ## Contributing
102
+
103
+ Issues and pull requests are welcome. Open an issue first for significant changes so the approach can be discussed before implementation.
104
+
105
+ ## License
106
+
107
+ MIT. See [LICENSE](LICENSE).
108
+
109
+ ---
110
+
111
+ *Created by [SVS Praveen](https://github.com/SVSPraveen) · [Portfolio](https://svspraveen.vercel.app/) · [LinkedIn](https://www.linkedin.com/in/svs-praveen-s/)*
@@ -0,0 +1,82 @@
1
+ # DeployProof
2
+
3
+ > A pre-push verification tool for AI-assisted codebases: mutation testing, credential scanning, sandbox-escape detection, and dependency hallucination checks.
4
+
5
+ <!-- Once the package is published to PyPI, replace the two static badges below with:
6
+ [![PyPI version](https://img.shields.io/pypi/v/deployproof)](https://pypi.org/project/deployproof/)
7
+ [![Python](https://img.shields.io/pypi/pyversions/deployproof)](https://pypi.org/project/deployproof/) -->
8
+ [![PyPI](https://img.shields.io/badge/PyPI-not_yet_published-lightgrey)](https://pypi.org/project/deployproof/)
9
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
10
+ [![Python](https://img.shields.io/badge/python-3.10%2B-blue)](https://pypi.org/project/deployproof/)
11
+ [![CI](https://github.com/SVSPraveen/deployproof/actions/workflows/ci.yml/badge.svg)](https://github.com/SVSPraveen/deployproof/actions/workflows/ci.yml)
12
+
13
+ ---
14
+
15
+ ## Why This Exists
16
+
17
+ AI-assisted development introduces failure modes that standard tools miss: test suites with high line coverage but near-zero mutation scores, hardcoded credentials generated in passing, symlinks that deceive approval prompts into escaping the repository sandbox, and package names hallucinated by LLMs that don't exist on PyPI. DeployProof catches these at the pre-push stage, before they reach CI or production.
18
+
19
+ ## Install
20
+
21
+ ```bash
22
+ pip install deployproof
23
+ ```
24
+
25
+ Requires Python 3.10+.
26
+
27
+ ## Quickstart
28
+
29
+ Initialize in your repository:
30
+
31
+ ```bash
32
+ deployproof init
33
+ ```
34
+
35
+ Run all verification checks against changes in the current session:
36
+
37
+ ```bash
38
+ deployproof check
39
+ ```
40
+
41
+ Output includes a section for each check — symlink scan, secrets scan, dependency scan, and mutation score — with a pass/fail line at the bottom. Exit code is non-zero on any finding that should block a push.
42
+
43
+ ## What It Checks
44
+
45
+ - **Mutation Score** — Mutates AST operators (`>=`, `==`, `and`, `or`, `*`, numeric constants, comparisons) in modified files and runs your test suite against each mutant. Reports surviving mutants and a percentage score. Does not use line coverage.
46
+ - **Secrets and Credentials** — Scans modified files for hardcoded API keys (OpenAI, Anthropic, AWS, GitHub, Stripe, private keys) and tracked `.env` files using pattern matching and entropy analysis.
47
+ - **Symlink and Sandbox Escape** — Resolves symbolic links and flags any whose target escapes the repository root (CWE-61 / CWE-451). Catches the class of path-traversal trick used in the GhostApproval disclosure (Wiz Research, July 2026).
48
+ - **Dependency and Slopsquatting** — For each new import or manifest entry introduced in the diff, queries the PyPI JSON API and checks registration age. Packages that don't exist (HTTP 404) are flagged HIGH RISK; packages registered within the last 30 days are flagged MEDIUM RISK. Network errors are reported as UNKNOWN — never silently treated as safe.
49
+
50
+ ## What This Doesn't Do
51
+
52
+ - **Not a full-repo audit.** Checks are scoped to files changed in the current session (git diff). Files you haven't touched are not re-evaluated.
53
+ - **Python only.** Mutation testing and import extraction currently support Python files only. Other languages are not scanned.
54
+ - **No auto-fix.** DeployProof reports findings; it does not modify your code, rewrite imports, or suggest patches.
55
+ - **No IDE plugin yet.** There is no VS Code extension or JetBrains plugin. The CLI is the interface. IDE integration is on the roadmap.
56
+
57
+ ## See It Catch Real Bugs
58
+
59
+ Clone this repository and run the standalone stress-test suite to see DeployProof evaluate 7 planted edge cases:
60
+
61
+ ```bash
62
+ python stress_fixtures/run_stress_tests.py
63
+ ```
64
+
65
+ Fixtures cover weak test suites, zero-test orphan modules, planted OpenAI/AWS credentials, and GhostApproval sandbox-escape traps.
66
+
67
+ ## Status & Roadmap
68
+
69
+ - **Current (v0.1.0):** Diff-scoped AST mutation testing, secrets scanner, GhostApproval symlink sandbox-escape detector, PyPI dependency hallucination / slopsquatting scanner, and Tier 2 CI verification via GitHub Actions (mutmut).
70
+ - **Next:** Multi-language mutation support and expanded ecosystem rule packs.
71
+
72
+ ## Contributing
73
+
74
+ Issues and pull requests are welcome. Open an issue first for significant changes so the approach can be discussed before implementation.
75
+
76
+ ## License
77
+
78
+ MIT. See [LICENSE](LICENSE).
79
+
80
+ ---
81
+
82
+ *Created by [SVS Praveen](https://github.com/SVSPraveen) · [Portfolio](https://svspraveen.vercel.app/) · [LinkedIn](https://www.linkedin.com/in/svs-praveen-s/)*
@@ -0,0 +1,50 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "deployproof"
7
+ version = "0.1.0"
8
+ description = "A deterministic pre-push verification tool that catches untested AI code, leaked credentials, sandbox escapes, and hallucinated packages before you ship."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ authors = [
13
+ { name = "SVS Praveen" }
14
+ ]
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Intended Audience :: Developers",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
23
+ "Topic :: Security",
24
+ "Topic :: Software Development :: Quality Assurance",
25
+ "Topic :: Software Development :: Testing",
26
+ ]
27
+ dependencies = []
28
+
29
+ [project.optional-dependencies]
30
+ dev = [
31
+ "pytest>=7.0.0",
32
+ "build>=1.0.0",
33
+ "twine>=4.0.0",
34
+ ]
35
+
36
+ [project.urls]
37
+ Homepage = "https://github.com/SVSPraveen/deployproof"
38
+ Documentation = "https://github.com/SVSPraveen/deployproof#readme"
39
+ Repository = "https://github.com/SVSPraveen/deployproof.git"
40
+ "Bug Tracker" = "https://github.com/SVSPraveen/deployproof/issues"
41
+
42
+ [project.scripts]
43
+ deployproof = "deployproof.cli:main"
44
+
45
+ [tool.setuptools.packages.find]
46
+ where = ["src"]
47
+
48
+ [tool.pytest.ini_options]
49
+ testpaths = ["tests"]
50
+ pythonpath = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ """DeployProof - A deterministic AI-code deployability checker."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,288 @@
1
+ """Command-line interface for DeployProof."""
2
+
3
+ import argparse
4
+ import sys
5
+ from pathlib import Path
6
+ from typing import List, Optional
7
+
8
+ from deployproof import __version__
9
+ from deployproof.dependencies import (
10
+ extract_all_new_dependencies,
11
+ scan_dependencies,
12
+ )
13
+ from deployproof.diff import (
14
+ DiffScopeError,
15
+ InvalidBaseRefError,
16
+ NotAGitRepositoryError,
17
+ get_git_root,
18
+ is_test_file,
19
+ resolve_changed_python_files,
20
+ resolve_changed_session_files,
21
+ )
22
+ from deployproof.mutator import run_mutation_tests
23
+ from deployproof.reporter import LARGE_FILE_LOC_THRESHOLD, format_report
24
+ from deployproof.secrets import scan_session_files_for_secrets
25
+ from deployproof.symlinks import scan_session_files_for_symlinks
26
+ from deployproof.wsl import check_wsl_readiness, run_wsl_mutmut
27
+
28
+
29
+ def create_parser() -> argparse.ArgumentParser:
30
+ """Create and configure the command-line argument parser."""
31
+ parser = argparse.ArgumentParser(
32
+ prog="deployproof",
33
+ description="DeployProof: A deterministic AI-code deployability checker.",
34
+ )
35
+ parser.add_argument(
36
+ "-v",
37
+ "--version",
38
+ action="version",
39
+ version=f"%(prog)s {__version__}",
40
+ help="Show program's version number and exit.",
41
+ )
42
+
43
+ subparsers = parser.add_subparsers(dest="command", help="Available commands")
44
+
45
+ # 'check' command for V1 scope
46
+ check_parser = subparsers.add_parser(
47
+ "check",
48
+ help="Run deployability verification checks against session changes.",
49
+ )
50
+ check_parser.add_argument(
51
+ "--base",
52
+ type=str,
53
+ default=None,
54
+ help="Base git ref (branch/commit/tag) to diff against.",
55
+ )
56
+ check_parser.add_argument(
57
+ "--files",
58
+ nargs="+",
59
+ type=str,
60
+ default=None,
61
+ help="Explicit files to evaluate (bypasses git diff).",
62
+ )
63
+ check_parser.add_argument(
64
+ "--tests",
65
+ nargs="+",
66
+ type=str,
67
+ default=None,
68
+ help="Specific test file(s) or directories to execute.",
69
+ )
70
+ check_parser.add_argument(
71
+ "--threshold",
72
+ type=float,
73
+ default=80.0,
74
+ help="Minimum mutation score percentage to pass (default: 80.0).",
75
+ )
76
+ check_parser.add_argument(
77
+ "--timeout",
78
+ type=float,
79
+ default=10.0,
80
+ help="Test runner timeout in seconds per mutant (default: 10.0).",
81
+ )
82
+ check_parser.add_argument(
83
+ "--wsl",
84
+ action="store_true",
85
+ default=False,
86
+ help="Delegate mutation testing to mutmut inside WSL (Windows only).",
87
+ )
88
+
89
+ # Placeholder 'init' command
90
+ subparsers.add_parser(
91
+ "init",
92
+ help="Initialize DeployProof configuration in the current repository.",
93
+ )
94
+
95
+ return parser
96
+
97
+
98
+ def handle_check(args: argparse.Namespace) -> int:
99
+ """Handle the 'check' subcommand."""
100
+ cwd = Path.cwd().resolve()
101
+ repo_root: Optional[Path] = None
102
+
103
+ try:
104
+ if args.files:
105
+ session_files = [Path(f).resolve() for f in args.files]
106
+ if session_files:
107
+ try:
108
+ repo_root = get_git_root(session_files[0].parent)
109
+ except DiffScopeError:
110
+ repo_root = session_files[0].parent
111
+ else:
112
+ repo_root = cwd
113
+ else:
114
+ repo_root = get_git_root(cwd)
115
+ session_files = resolve_changed_session_files(cwd=cwd, base=args.base)
116
+ except NotAGitRepositoryError:
117
+ print("Error: Not a git repository. Initialize git or specify files with --files.", file=sys.stderr)
118
+ return 1
119
+ except InvalidBaseRefError as e:
120
+ print(f"Error: {e}", file=sys.stderr)
121
+ return 1
122
+ except DiffScopeError as e:
123
+ print(f"Error: {e}", file=sys.stderr)
124
+ return 1
125
+
126
+ if not session_files:
127
+ print("DeployProof: No modified files detected in current session.")
128
+ print("Working tree is clean. Use --base <ref> or --files <path...> to evaluate specific files.")
129
+ return 0
130
+
131
+ # 1. Run Symlink & Sandbox Escape Scanner across all session files
132
+ symlink_result = scan_session_files_for_symlinks(session_files, repo_root=repo_root or cwd)
133
+
134
+ # 2. Run Secrets & Credentials Scanner across all session files
135
+ secrets_result = scan_session_files_for_secrets(session_files)
136
+
137
+ # 3. Run Slopsquatting & Dependency Hallucination Scanner across session files
138
+ extracted_deps = extract_all_new_dependencies(session_files, root=repo_root or cwd, base=args.base)
139
+ dependency_result = scan_dependencies(extracted_deps)
140
+
141
+ # 4. Filter target Python files for mutation testing
142
+ if args.files:
143
+ target_files = [f for f in session_files if f.is_file() and f.suffix == ".py"]
144
+ else:
145
+ target_files = [f for f in session_files if f.is_file() and f.suffix == ".py" and not is_test_file(f)]
146
+
147
+ # Notify upfront if large files are in scope
148
+ for f in target_files:
149
+ try:
150
+ loc = len(f.read_text(encoding="utf-8", errors="replace").splitlines())
151
+ if loc >= LARGE_FILE_LOC_THRESHOLD:
152
+ try:
153
+ rel = f.relative_to(repo_root or cwd)
154
+ except ValueError:
155
+ rel = f
156
+ print(
157
+ f"Notice: Large file '{rel}' ({loc} LOC) detected - mutation testing may take several minutes."
158
+ )
159
+ except Exception:
160
+ pass
161
+
162
+ # Optional WSL delegation
163
+ if getattr(args, "wsl", False):
164
+ wsl_ready, wsl_msg = check_wsl_readiness()
165
+ if wsl_ready:
166
+ print("DeployProof - Delegating to mutmut in WSL...")
167
+ wsl_res = run_wsl_mutmut(repo_root or cwd, target_files)
168
+ if wsl_res.get("success"):
169
+ print(wsl_res.get("stdout", ""))
170
+ has_security_issue = bool(
171
+ secrets_result.findings
172
+ or symlink_result.escape_findings
173
+ or dependency_result.high_risk_count > 0
174
+ )
175
+ return 1 if has_security_issue else 0
176
+ else:
177
+ print(f"WSL execution error: {wsl_res.get('error') or wsl_res.get('stderr')}", file=sys.stderr)
178
+ print("Falling back to Tier 1 local pre-check...")
179
+ else:
180
+ print(wsl_msg)
181
+ print("-" * 68)
182
+
183
+ result = run_mutation_tests(
184
+ target_files=target_files,
185
+ repo_root=repo_root or cwd,
186
+ test_runner_timeout=args.timeout,
187
+ extra_pytest_args=args.tests,
188
+ )
189
+
190
+ report_text = format_report(
191
+ result=result,
192
+ target_files=target_files,
193
+ secrets_result=secrets_result,
194
+ symlink_result=symlink_result,
195
+ dependency_result=dependency_result,
196
+ repo_root=repo_root or cwd,
197
+ threshold=args.threshold,
198
+ )
199
+ print(report_text)
200
+
201
+ # Fail if mutation score threshold not met, secrets detected, symlink sandbox escapes found, or hallucinated packages detected
202
+ if (
203
+ result.mutation_score < args.threshold
204
+ or len(result.untested_files) > 0
205
+ or len(secrets_result.findings) > 0
206
+ or len(symlink_result.escape_findings) > 0
207
+ or dependency_result.high_risk_count > 0
208
+ ):
209
+ return 1
210
+ return 0
211
+
212
+
213
+ def handle_init(args: argparse.Namespace) -> int:
214
+ """Handle the 'init' subcommand to initialize configuration and git hooks."""
215
+ cwd = Path.cwd().resolve()
216
+ try:
217
+ repo_root = get_git_root(cwd)
218
+ except DiffScopeError:
219
+ repo_root = cwd
220
+
221
+ print(f"DeployProof: Initializing in {repo_root}...")
222
+
223
+ # 1. Create or verify configuration file (.deployproof.json)
224
+ config_path = repo_root / ".deployproof.json"
225
+ if not config_path.exists():
226
+ import json
227
+ default_config = {
228
+ "version": __version__,
229
+ "threshold": 80.0,
230
+ "timeout": 10.0,
231
+ "secrets_scanning": True,
232
+ "symlink_scanning": True,
233
+ "dependency_scanning": True,
234
+ }
235
+ config_path.write_text(json.dumps(default_config, indent=2) + "\n", encoding="utf-8")
236
+ print(f" [+] Created configuration file: {config_path.name}")
237
+ else:
238
+ print(f" [.] Configuration file already exists: {config_path.name}")
239
+
240
+ # 2. Install / verify git pre-push hook if inside git repo
241
+ hooks_dir = repo_root / ".git" / "hooks"
242
+ if hooks_dir.is_dir():
243
+ pre_push_hook = hooks_dir / "pre-push"
244
+ hook_script = "#!/usr/bin/env sh\n# DeployProof deterministic pre-push verification gate\ndeployproof check\n"
245
+ pre_push_hook.write_text(hook_script, encoding="utf-8")
246
+ try:
247
+ import stat
248
+ pre_push_hook.chmod(pre_push_hook.stat().st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
249
+ except Exception:
250
+ pass
251
+ print(" [+] Installed git pre-push hook: .git/hooks/pre-push")
252
+ else:
253
+ print(" [i] Note: .git/hooks directory not found. Initialize git to enable automatic pre-push gating.")
254
+
255
+ print("\nDeployProof initialization complete. Run 'deployproof check' to verify your session changes.")
256
+ return 0
257
+
258
+
259
+ def main(argv: Optional[List[str]] = None) -> int:
260
+ """Entry point for the DeployProof CLI."""
261
+ if hasattr(sys.stdout, "reconfigure"):
262
+ try:
263
+ sys.stdout.reconfigure(errors="replace")
264
+ except Exception:
265
+ pass
266
+ if hasattr(sys.stderr, "reconfigure"):
267
+ try:
268
+ sys.stderr.reconfigure(errors="replace")
269
+ except Exception:
270
+ pass
271
+
272
+ parser = create_parser()
273
+ args = parser.parse_args(argv)
274
+
275
+ if not args.command:
276
+ parser.print_help()
277
+ return 0
278
+
279
+ if args.command == "check":
280
+ return handle_check(args)
281
+ elif args.command == "init":
282
+ return handle_init(args)
283
+
284
+ return 0
285
+
286
+
287
+ if __name__ == "__main__":
288
+ sys.exit(main())