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.
- kavach_ai-1.2.0/LICENSE +21 -0
- kavach_ai-1.2.0/PKG-INFO +226 -0
- kavach_ai-1.2.0/README.md +194 -0
- kavach_ai-1.2.0/ci_bot.py +342 -0
- kavach_ai-1.2.0/cli.py +218 -0
- kavach_ai-1.2.0/core/__init__.py +0 -0
- kavach_ai-1.2.0/core/ai_reasoner.py +205 -0
- kavach_ai-1.2.0/core/diff_parser.py +167 -0
- kavach_ai-1.2.0/core/patch_validator.py +35 -0
- kavach_ai-1.2.0/core/self_healing.py +219 -0
- kavach_ai-1.2.0/core/surgical_analyzer.py +418 -0
- kavach_ai-1.2.0/kavach_ai.egg-info/PKG-INFO +226 -0
- kavach_ai-1.2.0/kavach_ai.egg-info/SOURCES.txt +22 -0
- kavach_ai-1.2.0/kavach_ai.egg-info/dependency_links.txt +1 -0
- kavach_ai-1.2.0/kavach_ai.egg-info/entry_points.txt +5 -0
- kavach_ai-1.2.0/kavach_ai.egg-info/requires.txt +8 -0
- kavach_ai-1.2.0/kavach_ai.egg-info/top_level.txt +4 -0
- kavach_ai-1.2.0/pyproject.toml +48 -0
- kavach_ai-1.2.0/samples/__init__.py +0 -0
- kavach_ai-1.2.0/samples/vulnerable_samples.py +92 -0
- kavach_ai-1.2.0/setup.cfg +4 -0
- kavach_ai-1.2.0/setup.py +38 -0
- kavach_ai-1.2.0/tests/test_autopatch.py +75 -0
- kavach_ai-1.2.0/tests/test_self_healing.py +97 -0
kavach_ai-1.2.0/LICENSE
ADDED
|
@@ -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.
|
kavach_ai-1.2.0/PKG-INFO
ADDED
|
@@ -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)
|
|
38
|
+
[](https://python.org)
|
|
39
|
+
[](https://owasp.org)
|
|
40
|
+
[]()
|
|
41
|
+
[](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)
|
|
6
|
+
[](https://python.org)
|
|
7
|
+
[](https://owasp.org)
|
|
8
|
+
[]()
|
|
9
|
+
[](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)**.
|