deployproof 0.1.2__tar.gz → 0.1.5__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 (40) hide show
  1. {deployproof-0.1.2/src/deployproof.egg-info → deployproof-0.1.5}/PKG-INFO +91 -6
  2. deployproof-0.1.5/README.md +164 -0
  3. {deployproof-0.1.2 → deployproof-0.1.5}/pyproject.toml +2 -2
  4. {deployproof-0.1.2 → deployproof-0.1.5}/src/deployproof/__init__.py +1 -1
  5. {deployproof-0.1.2 → deployproof-0.1.5}/src/deployproof/cli.py +145 -36
  6. deployproof-0.1.5/src/deployproof/control_flow.py +261 -0
  7. {deployproof-0.1.2 → deployproof-0.1.5}/src/deployproof/dependencies.py +218 -55
  8. {deployproof-0.1.2 → deployproof-0.1.5}/src/deployproof/diff.py +53 -0
  9. deployproof-0.1.5/src/deployproof/mocks.py +244 -0
  10. {deployproof-0.1.2 → deployproof-0.1.5}/src/deployproof/mutator.py +80 -0
  11. deployproof-0.1.5/src/deployproof/reporter.py +623 -0
  12. {deployproof-0.1.2 → deployproof-0.1.5/src/deployproof.egg-info}/PKG-INFO +91 -6
  13. {deployproof-0.1.2 → deployproof-0.1.5}/src/deployproof.egg-info/SOURCES.txt +4 -0
  14. deployproof-0.1.5/tests/test_cli.py +197 -0
  15. {deployproof-0.1.2 → deployproof-0.1.5}/tests/test_cli_dependency_scan.py +104 -0
  16. deployproof-0.1.5/tests/test_control_flow.py +205 -0
  17. {deployproof-0.1.2 → deployproof-0.1.5}/tests/test_dependencies_extractor.py +119 -22
  18. deployproof-0.1.5/tests/test_mocks.py +184 -0
  19. deployproof-0.1.5/tests/test_mutator.py +137 -0
  20. deployproof-0.1.2/README.md +0 -79
  21. deployproof-0.1.2/src/deployproof/reporter.py +0 -281
  22. deployproof-0.1.2/tests/test_cli.py +0 -88
  23. deployproof-0.1.2/tests/test_mutator.py +0 -53
  24. {deployproof-0.1.2 → deployproof-0.1.5}/LICENSE +0 -0
  25. {deployproof-0.1.2 → deployproof-0.1.5}/setup.cfg +0 -0
  26. {deployproof-0.1.2 → deployproof-0.1.5}/src/deployproof/secrets.py +0 -0
  27. {deployproof-0.1.2 → deployproof-0.1.5}/src/deployproof/symlinks.py +0 -0
  28. {deployproof-0.1.2 → deployproof-0.1.5}/src/deployproof/wsl.py +0 -0
  29. {deployproof-0.1.2 → deployproof-0.1.5}/src/deployproof.egg-info/dependency_links.txt +0 -0
  30. {deployproof-0.1.2 → deployproof-0.1.5}/src/deployproof.egg-info/entry_points.txt +0 -0
  31. {deployproof-0.1.2 → deployproof-0.1.5}/src/deployproof.egg-info/requires.txt +0 -0
  32. {deployproof-0.1.2 → deployproof-0.1.5}/src/deployproof.egg-info/top_level.txt +0 -0
  33. {deployproof-0.1.2 → deployproof-0.1.5}/tests/test_dependencies_pypi.py +0 -0
  34. {deployproof-0.1.2 → deployproof-0.1.5}/tests/test_diff.py +0 -0
  35. {deployproof-0.1.2 → deployproof-0.1.5}/tests/test_edge_cases_validation.py +0 -0
  36. {deployproof-0.1.2 → deployproof-0.1.5}/tests/test_mutation_suites.py +0 -0
  37. {deployproof-0.1.2 → deployproof-0.1.5}/tests/test_secrets.py +0 -0
  38. {deployproof-0.1.2 → deployproof-0.1.5}/tests/test_stress_regressions.py +0 -0
  39. {deployproof-0.1.2 → deployproof-0.1.5}/tests/test_symlinks.py +0 -0
  40. {deployproof-0.1.2 → deployproof-0.1.5}/tests/test_wsl.py +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deployproof
3
- Version: 0.1.2
4
- Summary: A deterministic pre-push verification tool that catches untested AI code, leaked credentials, sandbox escapes, and hallucinated packages before you ship.
3
+ Version: 0.1.5
4
+ Summary: A deterministic AI-code deployability checker that catches what coverage misses.
5
5
  Author: SVS Praveen
6
6
  License-Expression: MIT
7
7
  Project-URL: Homepage, https://github.com/SVSPraveen/deployproof
@@ -33,7 +33,7 @@ Dynamic: license-file
33
33
 
34
34
  [![PyPI version](https://img.shields.io/pypi/v/deployproof.svg?color=blue)](https://pypi.org/project/deployproof/)
35
35
  [![Python versions](https://img.shields.io/pypi/pyversions/deployproof.svg?color=blue)](https://pypi.org/project/deployproof/)
36
- [![Tests](https://img.shields.io/badge/tests-61%20passed-brightgreen.svg)](https://github.com/SVSPraveen/DeployProof)
36
+ [![Tests](https://img.shields.io/badge/tests-79%20passed-brightgreen.svg)](https://github.com/SVSPraveen/DeployProof)
37
37
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
38
38
 
39
39
  ---
@@ -64,14 +64,99 @@ Run all verification checks against changes in the current session:
64
64
  deployproof check
65
65
  ```
66
66
 
67
- 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.
67
+ Output includes a section for each check — symlink scan, secrets scan, dependency scan, mock detection, control flow analysis, and mutation score — with a pass/fail line at the bottom. Exit code is non-zero on any finding that should block a push. Supports `--json` for machine-readable output and `--strict-mocks` / `--strict-error-handling` to turn informational checks into hard verification gates.
68
+
69
+ ### Machine-Readable Output (`--json`)
70
+
71
+ DeployProof provides a stable structured JSON schema for CI/CD pipelines, IDEs, and automation:
72
+
73
+ ```bash
74
+ deployproof check --json
75
+ ```
76
+
77
+ #### JSON Output Schema
78
+
79
+ ```json
80
+ {
81
+ "version": "0.1.5",
82
+ "status": "passed",
83
+ "summary": {
84
+ "target_files_count": 1,
85
+ "mutation_score": 100.0,
86
+ "threshold": 80.0,
87
+ "secrets_found": 0,
88
+ "symlink_escapes_found": 0,
89
+ "dependency_findings": {
90
+ "high_risk": 0,
91
+ "medium_risk": 0,
92
+ "ok": 1,
93
+ "unknown": 0,
94
+ "unscanned": 0
95
+ },
96
+ "mock_usages_found": 0,
97
+ "control_flow_findings": 0,
98
+ "strict_mocks_active": false,
99
+ "strict_mocks_triggered": false,
100
+ "strict_error_handling_active": false,
101
+ "strict_error_handling_triggered": false
102
+ },
103
+ "scope": {
104
+ "target_files": [
105
+ {
106
+ "file": "app.py",
107
+ "loc": 45,
108
+ "is_large": false
109
+ }
110
+ ]
111
+ },
112
+ "mutation_testing": {
113
+ "score": 100.0,
114
+ "threshold": 80.0,
115
+ "total_mutants": 6,
116
+ "killed_mutants": 6,
117
+ "survived_mutants_count": 0,
118
+ "duration_seconds": 1.2,
119
+ "surviving_mutants": [],
120
+ "skipped_constructs": [],
121
+ "untested_files": []
122
+ },
123
+ "secrets": {
124
+ "clean": true,
125
+ "files_scanned": 1,
126
+ "findings": []
127
+ },
128
+ "symlinks": {
129
+ "clean": true,
130
+ "files_scanned": 1,
131
+ "findings": []
132
+ },
133
+ "dependencies": {
134
+ "clean": true,
135
+ "total_scanned": 1,
136
+ "findings": [],
137
+ "unscanned_sources": []
138
+ },
139
+ "mocks": {
140
+ "clean": true,
141
+ "strict_gate_triggered": false,
142
+ "findings": []
143
+ },
144
+ "control_flow": {
145
+ "clean": true,
146
+ "strict_gate_triggered": false,
147
+ "findings": []
148
+ }
149
+ }
150
+ ```
68
151
 
69
152
  ## What It Checks
70
153
 
71
154
  - **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.
72
155
  - **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.
73
156
  - **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).
74
- - **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.
157
+ - **Dependency and Slopsquatting** — For each new import, dynamic import (`importlib.import_module`, `__import__`), or manifest entry (including recursive `-r` includes) 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.
158
+ - **Mock Usage Detection** — Scans test diffs for newly introduced imports or fixture uses of `unittest.mock`, `mocker`, and `monkeypatch`, flagging them for human review with an optional `--strict-mocks` hard gate.
159
+ - **Control Flow and Error Handling** — AST-based detector for bare `except:` without re-raise, silently swallowed broad exceptions (`except Exception:` that only `pass` or log/print without re-raising or returning error indicators), and dead/unreachable code following unconditional `return`, `raise`, `break`, or `continue`, with an optional `--strict-error-handling` hard gate.
75
160
 
76
161
  ## What This Doesn't Do
77
162
 
@@ -92,7 +177,7 @@ Fixtures cover weak test suites, zero-test orphan modules, planted OpenAI/AWS cr
92
177
 
93
178
  ## Status & Roadmap
94
179
 
95
- - **Current (v0.1.2):** 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).
180
+ - **Current (v0.1.5):** Diff-scoped AST mutation testing, secrets scanner (including unquoted .env values), GhostApproval symlink sandbox-escape detector, PyPI dependency hallucination / slopsquatting scanner (with recursive `-r` requirements scanning and dynamic import detection via `importlib` / `__import__`), mock-introduction detector (`--strict-mocks`), control-flow / swallowed-exception scanner (`--strict-error-handling`), machine-readable `--json` output, and Tier 2 CI verification via GitHub Actions (mutmut).
96
181
  - **Next:** Multi-language mutation support and expanded ecosystem rule packs.
97
182
 
98
183
  ## Contributing
@@ -0,0 +1,164 @@
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
+ [![PyPI version](https://img.shields.io/pypi/v/deployproof.svg?color=blue)](https://pypi.org/project/deployproof/)
6
+ [![Python versions](https://img.shields.io/pypi/pyversions/deployproof.svg?color=blue)](https://pypi.org/project/deployproof/)
7
+ [![Tests](https://img.shields.io/badge/tests-79%20passed-brightgreen.svg)](https://github.com/SVSPraveen/DeployProof)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
9
+
10
+ ---
11
+
12
+ ## Why This Exists
13
+
14
+ 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.
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ pip install deployproof
20
+ ```
21
+
22
+ Requires Python 3.10+.
23
+
24
+ ## Quickstart
25
+
26
+ Initialize in your repository:
27
+
28
+ ```bash
29
+ deployproof init
30
+ ```
31
+
32
+ Run all verification checks against changes in the current session:
33
+
34
+ ```bash
35
+ deployproof check
36
+ ```
37
+
38
+ Output includes a section for each check — symlink scan, secrets scan, dependency scan, mock detection, control flow analysis, and mutation score — with a pass/fail line at the bottom. Exit code is non-zero on any finding that should block a push. Supports `--json` for machine-readable output and `--strict-mocks` / `--strict-error-handling` to turn informational checks into hard verification gates.
39
+
40
+ ### Machine-Readable Output (`--json`)
41
+
42
+ DeployProof provides a stable structured JSON schema for CI/CD pipelines, IDEs, and automation:
43
+
44
+ ```bash
45
+ deployproof check --json
46
+ ```
47
+
48
+ #### JSON Output Schema
49
+
50
+ ```json
51
+ {
52
+ "version": "0.1.5",
53
+ "status": "passed",
54
+ "summary": {
55
+ "target_files_count": 1,
56
+ "mutation_score": 100.0,
57
+ "threshold": 80.0,
58
+ "secrets_found": 0,
59
+ "symlink_escapes_found": 0,
60
+ "dependency_findings": {
61
+ "high_risk": 0,
62
+ "medium_risk": 0,
63
+ "ok": 1,
64
+ "unknown": 0,
65
+ "unscanned": 0
66
+ },
67
+ "mock_usages_found": 0,
68
+ "control_flow_findings": 0,
69
+ "strict_mocks_active": false,
70
+ "strict_mocks_triggered": false,
71
+ "strict_error_handling_active": false,
72
+ "strict_error_handling_triggered": false
73
+ },
74
+ "scope": {
75
+ "target_files": [
76
+ {
77
+ "file": "app.py",
78
+ "loc": 45,
79
+ "is_large": false
80
+ }
81
+ ]
82
+ },
83
+ "mutation_testing": {
84
+ "score": 100.0,
85
+ "threshold": 80.0,
86
+ "total_mutants": 6,
87
+ "killed_mutants": 6,
88
+ "survived_mutants_count": 0,
89
+ "duration_seconds": 1.2,
90
+ "surviving_mutants": [],
91
+ "skipped_constructs": [],
92
+ "untested_files": []
93
+ },
94
+ "secrets": {
95
+ "clean": true,
96
+ "files_scanned": 1,
97
+ "findings": []
98
+ },
99
+ "symlinks": {
100
+ "clean": true,
101
+ "files_scanned": 1,
102
+ "findings": []
103
+ },
104
+ "dependencies": {
105
+ "clean": true,
106
+ "total_scanned": 1,
107
+ "findings": [],
108
+ "unscanned_sources": []
109
+ },
110
+ "mocks": {
111
+ "clean": true,
112
+ "strict_gate_triggered": false,
113
+ "findings": []
114
+ },
115
+ "control_flow": {
116
+ "clean": true,
117
+ "strict_gate_triggered": false,
118
+ "findings": []
119
+ }
120
+ }
121
+ ```
122
+
123
+ ## What It Checks
124
+
125
+ - **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.
126
+ - **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.
127
+ - **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).
128
+ - **Dependency and Slopsquatting** — For each new import, dynamic import (`importlib.import_module`, `__import__`), or manifest entry (including recursive `-r` includes) 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.
129
+ - **Mock Usage Detection** — Scans test diffs for newly introduced imports or fixture uses of `unittest.mock`, `mocker`, and `monkeypatch`, flagging them for human review with an optional `--strict-mocks` hard gate.
130
+ - **Control Flow and Error Handling** — AST-based detector for bare `except:` without re-raise, silently swallowed broad exceptions (`except Exception:` that only `pass` or log/print without re-raising or returning error indicators), and dead/unreachable code following unconditional `return`, `raise`, `break`, or `continue`, with an optional `--strict-error-handling` hard gate.
131
+
132
+ ## What This Doesn't Do
133
+
134
+ - **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.
135
+ - **Python only.** Mutation testing and import extraction currently support Python files only. Other languages are not scanned.
136
+ - **No auto-fix.** DeployProof reports findings; it does not modify your code, rewrite imports, or suggest patches.
137
+ - **No IDE plugin yet.** There is no VS Code extension or JetBrains plugin. The CLI is the interface. IDE integration is on the roadmap.
138
+
139
+ ## See It Catch Real Bugs
140
+
141
+ Clone this repository and run the standalone stress-test suite to see DeployProof evaluate 7 planted edge cases:
142
+
143
+ ```bash
144
+ python stress_fixtures/run_stress_tests.py
145
+ ```
146
+
147
+ Fixtures cover weak test suites, zero-test orphan modules, planted OpenAI/AWS credentials, and GhostApproval sandbox-escape traps.
148
+
149
+ ## Status & Roadmap
150
+
151
+ - **Current (v0.1.5):** Diff-scoped AST mutation testing, secrets scanner (including unquoted .env values), GhostApproval symlink sandbox-escape detector, PyPI dependency hallucination / slopsquatting scanner (with recursive `-r` requirements scanning and dynamic import detection via `importlib` / `__import__`), mock-introduction detector (`--strict-mocks`), control-flow / swallowed-exception scanner (`--strict-error-handling`), machine-readable `--json` output, and Tier 2 CI verification via GitHub Actions (mutmut).
152
+ - **Next:** Multi-language mutation support and expanded ecosystem rule packs.
153
+
154
+ ## Contributing
155
+
156
+ Issues and pull requests are welcome. Open an issue first for significant changes so the approach can be discussed before implementation.
157
+
158
+ ## License
159
+
160
+ MIT. See [LICENSE](LICENSE).
161
+
162
+ ---
163
+
164
+ *Created by [SVS Praveen](https://github.com/SVSPraveen) · [Portfolio](https://svspraveen.vercel.app/) · [LinkedIn](https://www.linkedin.com/in/svs-praveen-s/)*
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "deployproof"
7
- version = "0.1.2"
8
- description = "A deterministic pre-push verification tool that catches untested AI code, leaked credentials, sandbox escapes, and hallucinated packages before you ship."
7
+ version = "0.1.5"
8
+ description = "A deterministic AI-code deployability checker that catches what coverage misses."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
11
11
  license = "MIT"
@@ -1,2 +1,2 @@
1
1
  """DeployProof: Deterministic deployability verification for AI-assisted code."""
2
- __version__ = "0.1.2"
2
+ __version__ = "0.1.5"
@@ -10,6 +10,7 @@ from deployproof.dependencies import (
10
10
  extract_all_new_dependencies,
11
11
  scan_dependencies,
12
12
  )
13
+ from deployproof.control_flow import scan_session_files_for_control_flow
13
14
  from deployproof.diff import (
14
15
  DiffScopeError,
15
16
  InvalidBaseRefError,
@@ -19,8 +20,9 @@ from deployproof.diff import (
19
20
  resolve_changed_python_files,
20
21
  resolve_changed_session_files,
21
22
  )
23
+ from deployproof.mocks import scan_session_files_for_mocks
22
24
  from deployproof.mutator import run_mutation_tests
23
- from deployproof.reporter import LARGE_FILE_LOC_THRESHOLD, format_report
25
+ from deployproof.reporter import LARGE_FILE_LOC_THRESHOLD, format_json_report, format_report
24
26
  from deployproof.secrets import scan_session_files_for_secrets
25
27
  from deployproof.symlinks import scan_session_files_for_symlinks
26
28
  from deployproof.wsl import check_wsl_readiness, run_wsl_mutmut
@@ -85,6 +87,24 @@ def create_parser() -> argparse.ArgumentParser:
85
87
  default=False,
86
88
  help="Delegate mutation testing to mutmut inside WSL (Windows only).",
87
89
  )
90
+ check_parser.add_argument(
91
+ "--strict-mocks",
92
+ action="store_true",
93
+ default=False,
94
+ help="Fail the verification gate if new mock or monkeypatch usage is introduced in test files.",
95
+ )
96
+ check_parser.add_argument(
97
+ "--strict-error-handling",
98
+ action="store_true",
99
+ default=False,
100
+ help="Fail the verification gate if bare excepts, swallowed exceptions, or unreachable code are detected.",
101
+ )
102
+ check_parser.add_argument(
103
+ "--json",
104
+ action="store_true",
105
+ default=False,
106
+ help="Output check results as a structured JSON object.",
107
+ )
88
108
 
89
109
  # Placeholder 'init' command
90
110
  subparsers.add_parser(
@@ -124,9 +144,50 @@ def handle_check(args: argparse.Namespace) -> int:
124
144
  return 1
125
145
 
126
146
  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
147
+ if getattr(args, "json", False):
148
+ import json
149
+
150
+ print(
151
+ json.dumps(
152
+ {
153
+ "version": __version__,
154
+ "status": "passed",
155
+ "message": "No modified files detected in current session.",
156
+ "scope": {"target_files": []},
157
+ "summary": {
158
+ "target_files_count": 0,
159
+ "mutation_score": 100.0,
160
+ "threshold": args.threshold,
161
+ "secrets_found": 0,
162
+ "symlink_escapes_found": 0,
163
+ "dependency_findings": {
164
+ "high_risk": 0,
165
+ "medium_risk": 0,
166
+ "ok": 0,
167
+ "unknown": 0,
168
+ "unscanned": 0,
169
+ },
170
+ "mock_usages_found": 0,
171
+ "control_flow_findings": 0,
172
+ "strict_mocks_active": getattr(args, "strict_mocks", False),
173
+ "strict_mocks_triggered": False,
174
+ "strict_error_handling_active": getattr(args, "strict_error_handling", False),
175
+ "strict_error_handling_triggered": False,
176
+ },
177
+ "control_flow": {
178
+ "clean": True,
179
+ "strict_gate_triggered": False,
180
+ "findings": [],
181
+ },
182
+ },
183
+ indent=2,
184
+ )
185
+ )
186
+ return 0
187
+ else:
188
+ print("DeployProof: No modified files detected in current session.")
189
+ print("Working tree is clean. Use --base <ref> or --files <path...> to evaluate specific files.")
190
+ return 0
130
191
 
131
192
  # 1. Run Symlink & Sandbox Escape Scanner across all session files
132
193
  symlink_result = scan_session_files_for_symlinks(session_files, repo_root=repo_root or cwd)
@@ -138,47 +199,69 @@ def handle_check(args: argparse.Namespace) -> int:
138
199
  extracted_deps = extract_all_new_dependencies(session_files, root=repo_root or cwd, base=args.base)
139
200
  dependency_result = scan_dependencies(extracted_deps)
140
201
 
141
- # 4. Filter target Python files for mutation testing
202
+ # 4. Run Mock Usage Detector across session test files
203
+ mock_result = scan_session_files_for_mocks(
204
+ session_files=session_files,
205
+ root=repo_root or cwd,
206
+ base=args.base,
207
+ )
208
+
209
+ # 5. Run Control Flow & Swallowed Exception Scanner across session files
210
+ control_flow_result = scan_session_files_for_control_flow(
211
+ session_files=session_files,
212
+ root=repo_root or cwd,
213
+ base=args.base,
214
+ )
215
+
216
+ # 6. Filter target Python files for mutation testing
142
217
  if args.files:
143
- target_files = [f for f in session_files if f.is_file() and f.suffix == ".py"]
218
+ non_test_files = [f for f in session_files if f.is_file() and f.suffix == ".py" and not is_test_file(f)]
219
+ target_files = non_test_files if non_test_files else [f for f in session_files if f.is_file() and f.suffix == ".py"]
144
220
  else:
145
221
  target_files = [f for f in session_files if f.is_file() and f.suffix == ".py" and not is_test_file(f)]
146
222
 
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
223
+ # Notify upfront if large files are in scope (only in text mode)
224
+ if not getattr(args, "json", False):
225
+ for f in target_files:
226
+ try:
227
+ loc = len(f.read_text(encoding="utf-8", errors="replace").splitlines())
228
+ if loc >= LARGE_FILE_LOC_THRESHOLD:
229
+ try:
230
+ rel = f.relative_to(repo_root or cwd)
231
+ except ValueError:
232
+ rel = f
233
+ print(
234
+ f"Notice: Large file '{rel}' ({loc} LOC) detected - mutation testing may take several minutes."
235
+ )
236
+ except Exception:
237
+ pass
161
238
 
162
239
  # Optional WSL delegation
163
240
  if getattr(args, "wsl", False):
164
241
  wsl_ready, wsl_msg = check_wsl_readiness()
165
242
  if wsl_ready:
166
- print("DeployProof - Delegating to mutmut in WSL...")
243
+ if not getattr(args, "json", False):
244
+ print("DeployProof - Delegating to mutmut in WSL...")
167
245
  wsl_res = run_wsl_mutmut(repo_root or cwd, target_files)
168
246
  if wsl_res.get("success"):
169
- print(wsl_res.get("stdout", ""))
247
+ if not getattr(args, "json", False):
248
+ print(wsl_res.get("stdout", ""))
170
249
  has_security_issue = bool(
171
250
  secrets_result.findings
172
251
  or symlink_result.escape_findings
173
252
  or dependency_result.high_risk_count > 0
253
+ or (getattr(args, "strict_mocks", False) and mock_result.total_findings > 0)
254
+ or (getattr(args, "strict_error_handling", False) and control_flow_result.total_findings > 0)
174
255
  )
175
256
  return 1 if has_security_issue else 0
176
257
  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...")
258
+ if not getattr(args, "json", False):
259
+ print(f"WSL execution error: {wsl_res.get('error') or wsl_res.get('stderr')}", file=sys.stderr)
260
+ print("Falling back to Tier 1 local pre-check...")
179
261
  else:
180
- print(wsl_msg)
181
- print("-" * 68)
262
+ if not getattr(args, "json", False):
263
+ print(wsl_msg)
264
+ print("-" * 68)
182
265
 
183
266
  result = run_mutation_tests(
184
267
  target_files=target_files,
@@ -187,24 +270,50 @@ def handle_check(args: argparse.Namespace) -> int:
187
270
  extra_pytest_args=args.tests,
188
271
  )
189
272
 
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
- )
273
+ if getattr(args, "json", False):
274
+ report_text = format_json_report(
275
+ result=result,
276
+ target_files=target_files,
277
+ secrets_result=secrets_result,
278
+ symlink_result=symlink_result,
279
+ dependency_result=dependency_result,
280
+ mock_result=mock_result,
281
+ control_flow_result=control_flow_result,
282
+ strict_mocks=getattr(args, "strict_mocks", False),
283
+ strict_error_handling=getattr(args, "strict_error_handling", False),
284
+ repo_root=repo_root or cwd,
285
+ threshold=args.threshold,
286
+ version=__version__,
287
+ )
288
+ else:
289
+ report_text = format_report(
290
+ result=result,
291
+ target_files=target_files,
292
+ secrets_result=secrets_result,
293
+ symlink_result=symlink_result,
294
+ dependency_result=dependency_result,
295
+ mock_result=mock_result,
296
+ control_flow_result=control_flow_result,
297
+ strict_mocks=getattr(args, "strict_mocks", False),
298
+ strict_error_handling=getattr(args, "strict_error_handling", False),
299
+ repo_root=repo_root or cwd,
300
+ threshold=args.threshold,
301
+ )
199
302
  print(report_text)
200
303
 
201
- # Fail if mutation score threshold not met, secrets detected, symlink sandbox escapes found, or hallucinated packages detected
304
+ # Fail if mutation score threshold not met, secrets detected, symlink sandbox escapes found, hallucinated packages detected, or strict flags triggered
305
+ strict_mocks_triggered = bool(getattr(args, "strict_mocks", False) and mock_result.total_findings > 0)
306
+ strict_error_triggered = bool(
307
+ getattr(args, "strict_error_handling", False) and control_flow_result.total_findings > 0
308
+ )
202
309
  if (
203
310
  result.mutation_score < args.threshold
204
311
  or len(result.untested_files) > 0
205
312
  or len(secrets_result.findings) > 0
206
313
  or len(symlink_result.escape_findings) > 0
207
314
  or dependency_result.high_risk_count > 0
315
+ or strict_mocks_triggered
316
+ or strict_error_triggered
208
317
  ):
209
318
  return 1
210
319
  return 0