kavach-ai 1.2.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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Chandan (rajrajak99)
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,226 @@
1
+ Metadata-Version: 2.4
2
+ Name: kavach-ai
3
+ Version: 1.2.0
4
+ Summary: Autonomous Zero-Noise Code Security Inspector & 1-Click Surgical Patcher
5
+ Home-page: https://github.com/rajrajak99/kavach-ai
6
+ Author: Raja Rajak (@rajrajak99)
7
+ Author-email: "Raja Rajak (@rajrajak99)" <founder@kavach.ai>
8
+ License: MIT
9
+ Project-URL: Homepage, https://kavach-ai.streamlit.app
10
+ Project-URL: Repository, https://github.com/rajrajak99/kavach-ai
11
+ Project-URL: Bug Tracker, https://github.com/rajrajak99/kavach-ai/issues
12
+ Keywords: security,code-review,git,diff,cwe,ast,cli,devsecops,self-healing
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Topic :: Security
18
+ Classifier: Topic :: Software Development :: Quality Assurance
19
+ Requires-Python: >=3.9
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: requests>=2.28.0
23
+ Provides-Extra: ui
24
+ Requires-Dist: streamlit>=1.35.0; extra == "ui"
25
+ Requires-Dist: pandas>=2.0.0; extra == "ui"
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
28
+ Dynamic: author
29
+ Dynamic: home-page
30
+ Dynamic: license-file
31
+ Dynamic: requires-python
32
+
33
+ # ๐Ÿ›ก๏ธ Kavach AI (เค•เคตเคš)
34
+
35
+ > **Autonomous High-Precision Code Armor & 1-Click Surgical Patcher**
36
+
37
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
38
+ [![Python: 3.11+](https://img.shields.io/badge/Python-3.11%2B-blue.svg)](https://python.org)
39
+ [![Security Policy: OWASP 2026](https://img.shields.io/badge/Security-OWASP%202026-green.svg)](https://owasp.org)
40
+ [![Engine: Zero--Noise](https://img.shields.io/badge/Engine-Zero--Noise%20Surgical-orange.svg)]()
41
+ [![GitHub Actions: Ready](https://img.shields.io/badge/CI%2FCD-GitHub%20Action-purple.svg)](action.yml)
42
+
43
+ Kavach AI (เค•เคตเคš) is an autonomous, high-speed static security inspector and surgical code repair engine. Operating like an impenetrable armor across your **GitHub Pull Requests (CI/CD)**, local CLI, VS Code editor, and Web Console, it eliminates critical security hazards (CWE-89 SQLi, CWE-798 Secret Leaks, CWE-120 Buffer Overflows) and generates **1-click ready-to-merge patches** with zero-regression self-healing verification.
44
+
45
+ ---
46
+
47
+ ## โšก Core Philosophy: Zero-Noise Precision
48
+
49
+ Most static code scanners overwhelm developers with hundreds of stylistic warnings (missing docstrings, trailing whitespace). Developers end up ignoring them.
50
+
51
+ AutoPatch operates on a **strict zero-noise policy**:
52
+ 1. **Ignores Noise:** Lockfiles (`package-lock.json`, `poetry.lock`), minified bundles, images, and formatting diffs are discarded automatically.
53
+ 2. **Flags Real Hazards Only:**
54
+ - ๐Ÿ›ก๏ธ **Hardcoded Credentials & Tokens (CWE-798):** AWS keys, GitHub PATs, OpenAI/Stripe secret keys in Python and JavaScript.
55
+ - ๐Ÿ›ก๏ธ **Raw SQL Injections (CWE-89):** Raw string interpolation inside queries.
56
+ - ๐Ÿ›ก๏ธ **Arbitrary OS Command Injection (CWE-78):** Untrusted shell inputs via `os.system` / `child_process.exec`.
57
+ - ๐Ÿ”ด **Fatal Runtime Exceptions (CWE-369, CWE-95):** ZeroDivisionError crashes, dynamic `eval()` execution.
58
+ - โšก **Resource Descriptors Leaks (CWE-775):** Unmanaged `open()` handles missing `with` context managers.
59
+ 3. **Generates Instant Patches:** AutoPatch outputs native GitHub markdown ` ```suggestion ` blocks that team leads can merge in 1 click right inside the GitHub UI.
60
+
61
+ ---
62
+
63
+ ## ๐Ÿค– GitHub Action Setup (Automated PR Reviews)
64
+
65
+ Add AutoPatch to any GitHub repository in **30 seconds** by creating `.github/workflows/autopatch.yml`:
66
+
67
+ ```yaml
68
+ name: AutoPatch Security Review
69
+
70
+ on:
71
+ pull_request:
72
+ branches: [ main, master, dev ]
73
+ push:
74
+ branches: [ main, master ]
75
+
76
+ permissions:
77
+ contents: read
78
+ pull-requests: write
79
+ issues: write
80
+
81
+ jobs:
82
+ autopatch-ci:
83
+ runs-on: ubuntu-latest
84
+ steps:
85
+ - name: Checkout Code
86
+ uses: actions/checkout@v4
87
+ with:
88
+ fetch-depth: 0
89
+
90
+ - name: Set up Python 3.11
91
+ uses: actions/setup-python@v5
92
+ with:
93
+ python-version: '3.11'
94
+
95
+ - name: AutoPatch PR Reviewer
96
+ env:
97
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98
+ run: |
99
+ python ci_bot.py --fail-on CRITICAL
100
+ ```
101
+
102
+ ### What Happens When a PR is Opened:
103
+ 1. **Inspects Changeset in < 0.05s** without external network latency.
104
+ 2. **Posts an Official PR Review Comment** with exact line numbers and 1-click GitHub commit suggestions.
105
+ 3. **Populates the GitHub Step Summary** with executive metrics and CWE classifications.
106
+ 4. **Fails the CI status check** to block merging if Critical vulnerabilities are detected.
107
+
108
+ ---
109
+
110
+ ## ๐Ÿ—๏ธ System Architecture
111
+
112
+ ```
113
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
114
+ โ”‚ Incoming Git Pull Request โ”‚
115
+ โ”‚ (git diff main...feature) โ”‚
116
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
117
+ โ”‚
118
+ โ–ผ
119
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
120
+ โ”‚ DiffParser (Zero-Noise) โ”‚
121
+ โ”‚ - Filters lockfiles/assets โ”‚
122
+ โ”‚ - Extracts modified hunks โ”‚
123
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
124
+ โ”‚
125
+ โ–ผ
126
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
127
+ โ”‚ Surgical Analyzer โ”‚
128
+ โ”‚ - Python & JS/TS Parsers โ”‚
129
+ โ”‚ - CWE-798 Credential Leaks โ”‚
130
+ โ”‚ - CWE-89 SQL Injections โ”‚
131
+ โ”‚ - CWE-78 Command Injections โ”‚
132
+ โ”‚ - CWE-775 Descriptor Leaks โ”‚
133
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
134
+ โ”‚
135
+ โ–ผ
136
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
137
+ โ”‚ 1-Click Patch Engine โ”‚
138
+ โ”‚ - GitHub suggestion blocks โ”‚
139
+ โ”‚ - PR Commenter Bot (CI/CD) โ”‚
140
+ โ”‚ - Standalone .patch export โ”‚
141
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
142
+ ```
143
+
144
+ ---
145
+
146
+ ## ๐Ÿš€ Quickstart & Usage
147
+
148
+ ### 1. Installation
149
+ Clone the repository and install requirements:
150
+ ```bash
151
+ git clone https://github.com/rajrajak99/autopatch-ai.git
152
+ cd autopatch-ai
153
+ pip install -r requirements.txt
154
+ ```
155
+
156
+ ### 2. Standalone Terminal CLI (Scan 10,000+ Files Locally)
157
+ ```bash
158
+ # Scan a directory and generate unified .patch
159
+ python cli.py ./my-project --patch autopatch.patch
160
+
161
+ # Apply patch directly via git
162
+ git apply autopatch.patch
163
+ ```
164
+
165
+ ### 3. Launch Local Review Workstation (Raycast / Linear Dark UI)
166
+ ```bash
167
+ streamlit run app.py
168
+ ```
169
+ Open `http://localhost:8502` in your browser.
170
+
171
+ ### 4. Run Automated Unit Tests
172
+ ```bash
173
+ pytest -o pythonpath=. tests/
174
+ ```
175
+
176
+ ---
177
+
178
+ ## ๐Ÿ“‚ Project Structure
179
+
180
+ ```
181
+ autopatch-ai/
182
+ โ”œโ”€โ”€ action.yml # GitHub Action specification (Composite)
183
+ โ”œโ”€โ”€ ci_bot.py # Automated CI/CD PR Reviewer & Commenter
184
+ โ”œโ”€โ”€ cli.py # Standalone high-speed Terminal CLI scanner
185
+ โ”œโ”€โ”€ app.py # Luxury Raycast/Linear Dark review workstation
186
+ โ”œโ”€โ”€ core/
187
+ โ”‚ โ”œโ”€โ”€ __init__.py
188
+ โ”‚ โ”œโ”€โ”€ diff_parser.py # Unified Git diff & hunk pre-filtering
189
+ โ”‚ โ”œโ”€โ”€ surgical_analyzer.py # Zero-noise CWE & bug detection engine
190
+ โ”‚ โ””โ”€โ”€ patch_validator.py # Syntax and indentation patch validator
191
+ โ”œโ”€โ”€ samples/
192
+ โ”‚ โ”œโ”€โ”€ __init__.py
193
+ โ”‚ โ””โ”€โ”€ vulnerable_samples.py # Multi-language test scenarios (Python + Node.js)
194
+ โ”œโ”€โ”€ tests/
195
+ โ”‚ โ”œโ”€โ”€ __init__.py
196
+ โ”‚ โ””โ”€โ”€ test_autopatch.py # Comprehensive pytest test suite (4/4 passing)
197
+ โ”œโ”€โ”€ .github/
198
+ โ”‚ โ””โ”€โ”€ workflows/
199
+ โ”‚ โ””โ”€โ”€ autopatch.yml # Production CI workflow configuration
200
+ โ”œโ”€โ”€ .streamlit/
201
+ โ”‚ โ””โ”€โ”€ config.toml # Raycast/Linear Obsidian theme configuration
202
+ โ”œโ”€โ”€ requirements.txt # Minimal production dependencies
203
+ โ”œโ”€โ”€ LICENSE # MIT License
204
+ โ””โ”€โ”€ README.md # Technical documentation
205
+ ```
206
+
207
+ ---
208
+
209
+ ## ๐Ÿ›ก๏ธ Supported CWE Vulnerability Matrix
210
+
211
+ | CWE ID | Vulnerability Class | Language | Severity | AutoPatch Remediation |
212
+ |---|---|---|---|---|
213
+ | **CWE-798** | Hardcoded Credentials & Tokens | Python / JS | Critical | Moves secrets to environment variables |
214
+ | **CWE-89** | SQL Injection (Raw formatting) | Python / JS | Critical | Converts to parameterized queries |
215
+ | **CWE-78** | OS Command Injection | Python / JS | High | Converts string interpolation to discrete arrays |
216
+ | **CWE-95** | Arbitrary Code Execution (`eval`) | JavaScript | Critical | Replaces with strict JSON parser |
217
+ | **CWE-775** | Unmanaged Resource Descriptor | Python | Medium | Enforces `with open(...)` context manager |
218
+ | **CWE-369** | Unchecked Zero Division | Python | High | Inserts defensive conditional guard |
219
+
220
+ ---
221
+
222
+ ## ๐Ÿ“„ License
223
+
224
+ Distributed under the MIT License. See [LICENSE](LICENSE) for more information.
225
+
226
+ Developed by **[rajrajak99](https://github.com/rajrajak99)**.
@@ -0,0 +1,194 @@
1
+ # ๐Ÿ›ก๏ธ Kavach AI (เค•เคตเคš)
2
+
3
+ > **Autonomous High-Precision Code Armor & 1-Click Surgical Patcher**
4
+
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
6
+ [![Python: 3.11+](https://img.shields.io/badge/Python-3.11%2B-blue.svg)](https://python.org)
7
+ [![Security Policy: OWASP 2026](https://img.shields.io/badge/Security-OWASP%202026-green.svg)](https://owasp.org)
8
+ [![Engine: Zero--Noise](https://img.shields.io/badge/Engine-Zero--Noise%20Surgical-orange.svg)]()
9
+ [![GitHub Actions: Ready](https://img.shields.io/badge/CI%2FCD-GitHub%20Action-purple.svg)](action.yml)
10
+
11
+ Kavach AI (เค•เคตเคš) is an autonomous, high-speed static security inspector and surgical code repair engine. Operating like an impenetrable armor across your **GitHub Pull Requests (CI/CD)**, local CLI, VS Code editor, and Web Console, it eliminates critical security hazards (CWE-89 SQLi, CWE-798 Secret Leaks, CWE-120 Buffer Overflows) and generates **1-click ready-to-merge patches** with zero-regression self-healing verification.
12
+
13
+ ---
14
+
15
+ ## โšก Core Philosophy: Zero-Noise Precision
16
+
17
+ Most static code scanners overwhelm developers with hundreds of stylistic warnings (missing docstrings, trailing whitespace). Developers end up ignoring them.
18
+
19
+ AutoPatch operates on a **strict zero-noise policy**:
20
+ 1. **Ignores Noise:** Lockfiles (`package-lock.json`, `poetry.lock`), minified bundles, images, and formatting diffs are discarded automatically.
21
+ 2. **Flags Real Hazards Only:**
22
+ - ๐Ÿ›ก๏ธ **Hardcoded Credentials & Tokens (CWE-798):** AWS keys, GitHub PATs, OpenAI/Stripe secret keys in Python and JavaScript.
23
+ - ๐Ÿ›ก๏ธ **Raw SQL Injections (CWE-89):** Raw string interpolation inside queries.
24
+ - ๐Ÿ›ก๏ธ **Arbitrary OS Command Injection (CWE-78):** Untrusted shell inputs via `os.system` / `child_process.exec`.
25
+ - ๐Ÿ”ด **Fatal Runtime Exceptions (CWE-369, CWE-95):** ZeroDivisionError crashes, dynamic `eval()` execution.
26
+ - โšก **Resource Descriptors Leaks (CWE-775):** Unmanaged `open()` handles missing `with` context managers.
27
+ 3. **Generates Instant Patches:** AutoPatch outputs native GitHub markdown ` ```suggestion ` blocks that team leads can merge in 1 click right inside the GitHub UI.
28
+
29
+ ---
30
+
31
+ ## ๐Ÿค– GitHub Action Setup (Automated PR Reviews)
32
+
33
+ Add AutoPatch to any GitHub repository in **30 seconds** by creating `.github/workflows/autopatch.yml`:
34
+
35
+ ```yaml
36
+ name: AutoPatch Security Review
37
+
38
+ on:
39
+ pull_request:
40
+ branches: [ main, master, dev ]
41
+ push:
42
+ branches: [ main, master ]
43
+
44
+ permissions:
45
+ contents: read
46
+ pull-requests: write
47
+ issues: write
48
+
49
+ jobs:
50
+ autopatch-ci:
51
+ runs-on: ubuntu-latest
52
+ steps:
53
+ - name: Checkout Code
54
+ uses: actions/checkout@v4
55
+ with:
56
+ fetch-depth: 0
57
+
58
+ - name: Set up Python 3.11
59
+ uses: actions/setup-python@v5
60
+ with:
61
+ python-version: '3.11'
62
+
63
+ - name: AutoPatch PR Reviewer
64
+ env:
65
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66
+ run: |
67
+ python ci_bot.py --fail-on CRITICAL
68
+ ```
69
+
70
+ ### What Happens When a PR is Opened:
71
+ 1. **Inspects Changeset in < 0.05s** without external network latency.
72
+ 2. **Posts an Official PR Review Comment** with exact line numbers and 1-click GitHub commit suggestions.
73
+ 3. **Populates the GitHub Step Summary** with executive metrics and CWE classifications.
74
+ 4. **Fails the CI status check** to block merging if Critical vulnerabilities are detected.
75
+
76
+ ---
77
+
78
+ ## ๐Ÿ—๏ธ System Architecture
79
+
80
+ ```
81
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
82
+ โ”‚ Incoming Git Pull Request โ”‚
83
+ โ”‚ (git diff main...feature) โ”‚
84
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
85
+ โ”‚
86
+ โ–ผ
87
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
88
+ โ”‚ DiffParser (Zero-Noise) โ”‚
89
+ โ”‚ - Filters lockfiles/assets โ”‚
90
+ โ”‚ - Extracts modified hunks โ”‚
91
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
92
+ โ”‚
93
+ โ–ผ
94
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
95
+ โ”‚ Surgical Analyzer โ”‚
96
+ โ”‚ - Python & JS/TS Parsers โ”‚
97
+ โ”‚ - CWE-798 Credential Leaks โ”‚
98
+ โ”‚ - CWE-89 SQL Injections โ”‚
99
+ โ”‚ - CWE-78 Command Injections โ”‚
100
+ โ”‚ - CWE-775 Descriptor Leaks โ”‚
101
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
102
+ โ”‚
103
+ โ–ผ
104
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
105
+ โ”‚ 1-Click Patch Engine โ”‚
106
+ โ”‚ - GitHub suggestion blocks โ”‚
107
+ โ”‚ - PR Commenter Bot (CI/CD) โ”‚
108
+ โ”‚ - Standalone .patch export โ”‚
109
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
110
+ ```
111
+
112
+ ---
113
+
114
+ ## ๐Ÿš€ Quickstart & Usage
115
+
116
+ ### 1. Installation
117
+ Clone the repository and install requirements:
118
+ ```bash
119
+ git clone https://github.com/rajrajak99/autopatch-ai.git
120
+ cd autopatch-ai
121
+ pip install -r requirements.txt
122
+ ```
123
+
124
+ ### 2. Standalone Terminal CLI (Scan 10,000+ Files Locally)
125
+ ```bash
126
+ # Scan a directory and generate unified .patch
127
+ python cli.py ./my-project --patch autopatch.patch
128
+
129
+ # Apply patch directly via git
130
+ git apply autopatch.patch
131
+ ```
132
+
133
+ ### 3. Launch Local Review Workstation (Raycast / Linear Dark UI)
134
+ ```bash
135
+ streamlit run app.py
136
+ ```
137
+ Open `http://localhost:8502` in your browser.
138
+
139
+ ### 4. Run Automated Unit Tests
140
+ ```bash
141
+ pytest -o pythonpath=. tests/
142
+ ```
143
+
144
+ ---
145
+
146
+ ## ๐Ÿ“‚ Project Structure
147
+
148
+ ```
149
+ autopatch-ai/
150
+ โ”œโ”€โ”€ action.yml # GitHub Action specification (Composite)
151
+ โ”œโ”€โ”€ ci_bot.py # Automated CI/CD PR Reviewer & Commenter
152
+ โ”œโ”€โ”€ cli.py # Standalone high-speed Terminal CLI scanner
153
+ โ”œโ”€โ”€ app.py # Luxury Raycast/Linear Dark review workstation
154
+ โ”œโ”€โ”€ core/
155
+ โ”‚ โ”œโ”€โ”€ __init__.py
156
+ โ”‚ โ”œโ”€โ”€ diff_parser.py # Unified Git diff & hunk pre-filtering
157
+ โ”‚ โ”œโ”€โ”€ surgical_analyzer.py # Zero-noise CWE & bug detection engine
158
+ โ”‚ โ””โ”€โ”€ patch_validator.py # Syntax and indentation patch validator
159
+ โ”œโ”€โ”€ samples/
160
+ โ”‚ โ”œโ”€โ”€ __init__.py
161
+ โ”‚ โ””โ”€โ”€ vulnerable_samples.py # Multi-language test scenarios (Python + Node.js)
162
+ โ”œโ”€โ”€ tests/
163
+ โ”‚ โ”œโ”€โ”€ __init__.py
164
+ โ”‚ โ””โ”€โ”€ test_autopatch.py # Comprehensive pytest test suite (4/4 passing)
165
+ โ”œโ”€โ”€ .github/
166
+ โ”‚ โ””โ”€โ”€ workflows/
167
+ โ”‚ โ””โ”€โ”€ autopatch.yml # Production CI workflow configuration
168
+ โ”œโ”€โ”€ .streamlit/
169
+ โ”‚ โ””โ”€โ”€ config.toml # Raycast/Linear Obsidian theme configuration
170
+ โ”œโ”€โ”€ requirements.txt # Minimal production dependencies
171
+ โ”œโ”€โ”€ LICENSE # MIT License
172
+ โ””โ”€โ”€ README.md # Technical documentation
173
+ ```
174
+
175
+ ---
176
+
177
+ ## ๐Ÿ›ก๏ธ Supported CWE Vulnerability Matrix
178
+
179
+ | CWE ID | Vulnerability Class | Language | Severity | AutoPatch Remediation |
180
+ |---|---|---|---|---|
181
+ | **CWE-798** | Hardcoded Credentials & Tokens | Python / JS | Critical | Moves secrets to environment variables |
182
+ | **CWE-89** | SQL Injection (Raw formatting) | Python / JS | Critical | Converts to parameterized queries |
183
+ | **CWE-78** | OS Command Injection | Python / JS | High | Converts string interpolation to discrete arrays |
184
+ | **CWE-95** | Arbitrary Code Execution (`eval`) | JavaScript | Critical | Replaces with strict JSON parser |
185
+ | **CWE-775** | Unmanaged Resource Descriptor | Python | Medium | Enforces `with open(...)` context manager |
186
+ | **CWE-369** | Unchecked Zero Division | Python | High | Inserts defensive conditional guard |
187
+
188
+ ---
189
+
190
+ ## ๐Ÿ“„ License
191
+
192
+ Distributed under the MIT License. See [LICENSE](LICENSE) for more information.
193
+
194
+ Developed by **[rajrajak99](https://github.com/rajrajak99)**.