dexsec 0.7.1__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 (49) hide show
  1. dexsec-0.7.1/LICENSE +29 -0
  2. dexsec-0.7.1/PKG-INFO +301 -0
  3. dexsec-0.7.1/README.md +254 -0
  4. dexsec-0.7.1/dexsec/__init__.py +25 -0
  5. dexsec-0.7.1/dexsec/__main__.py +4 -0
  6. dexsec-0.7.1/dexsec/ai/__init__.py +0 -0
  7. dexsec-0.7.1/dexsec/ai/advisor.py +344 -0
  8. dexsec-0.7.1/dexsec/ai/apply.py +165 -0
  9. dexsec-0.7.1/dexsec/ai/chaining.py +250 -0
  10. dexsec-0.7.1/dexsec/ai/html_report.py +225 -0
  11. dexsec-0.7.1/dexsec/ai/patcher.py +519 -0
  12. dexsec-0.7.1/dexsec/ai/pdf.py +204 -0
  13. dexsec-0.7.1/dexsec/ai/reporter.py +260 -0
  14. dexsec-0.7.1/dexsec/ai/sarif.py +150 -0
  15. dexsec-0.7.1/dexsec/cli.py +739 -0
  16. dexsec-0.7.1/dexsec/config.py +159 -0
  17. dexsec-0.7.1/dexsec/core/__init__.py +0 -0
  18. dexsec-0.7.1/dexsec/core/baseline.py +111 -0
  19. dexsec-0.7.1/dexsec/core/correlator.py +217 -0
  20. dexsec-0.7.1/dexsec/core/notify.py +90 -0
  21. dexsec-0.7.1/dexsec/core/output.py +81 -0
  22. dexsec-0.7.1/dexsec/core/upgrade.py +145 -0
  23. dexsec-0.7.1/dexsec/core/watcher.py +101 -0
  24. dexsec-0.7.1/dexsec/dast/__init__.py +0 -0
  25. dexsec-0.7.1/dexsec/dast/oast.py +108 -0
  26. dexsec-0.7.1/dexsec/dast/openapi.py +297 -0
  27. dexsec-0.7.1/dexsec/dast/probes.py +262 -0
  28. dexsec-0.7.1/dexsec/dast/verifier.py +1054 -0
  29. dexsec-0.7.1/dexsec/hooks.py +101 -0
  30. dexsec-0.7.1/dexsec/manual/COVERAGE.md +124 -0
  31. dexsec-0.7.1/dexsec/manual/PANDUAN.md +424 -0
  32. dexsec-0.7.1/dexsec/models.py +171 -0
  33. dexsec-0.7.1/dexsec/sast/__init__.py +0 -0
  34. dexsec-0.7.1/dexsec/sast/access.py +151 -0
  35. dexsec-0.7.1/dexsec/sast/ast_taint.py +464 -0
  36. dexsec-0.7.1/dexsec/sast/config_scan.py +198 -0
  37. dexsec-0.7.1/dexsec/sast/languages.py +457 -0
  38. dexsec-0.7.1/dexsec/sast/php_calls.py +168 -0
  39. dexsec-0.7.1/dexsec/sast/rules.py +507 -0
  40. dexsec-0.7.1/dexsec/sast/scanner.py +565 -0
  41. dexsec-0.7.1/dexsec.egg-info/PKG-INFO +301 -0
  42. dexsec-0.7.1/dexsec.egg-info/SOURCES.txt +47 -0
  43. dexsec-0.7.1/dexsec.egg-info/dependency_links.txt +1 -0
  44. dexsec-0.7.1/dexsec.egg-info/entry_points.txt +2 -0
  45. dexsec-0.7.1/dexsec.egg-info/requires.txt +20 -0
  46. dexsec-0.7.1/dexsec.egg-info/top_level.txt +1 -0
  47. dexsec-0.7.1/pyproject.toml +74 -0
  48. dexsec-0.7.1/setup.cfg +4 -0
  49. dexsec-0.7.1/tests/test_features.py +472 -0
dexsec-0.7.1/LICENSE ADDED
@@ -0,0 +1,29 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DEX-SEC contributors
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.
22
+
23
+ ---
24
+
25
+ DISCLAIMER
26
+
27
+ DEX-SEC performs security testing. Only run it against systems you own or
28
+ are explicitly authorised to test. All probes shipped with DEX-SEC are
29
+ read-only by design, but you remain responsible for how you use the tool.
dexsec-0.7.1/PKG-INFO ADDED
@@ -0,0 +1,301 @@
1
+ Metadata-Version: 2.4
2
+ Name: dexsec
3
+ Version: 0.7.1
4
+ Summary: DEX-SEC — Inside-Out Hybrid Application Security Testing CLI (SAST + safe DAST + auto-remediation)
5
+ Author: DEX-SEC contributors
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/D3XT3R404/dex-sec
8
+ Project-URL: Documentation, https://github.com/D3XT3R404/dex-sec#readme
9
+ Project-URL: Changelog, https://github.com/D3XT3R404/dex-sec/blob/main/CHANGELOG.md
10
+ Project-URL: Issues, https://github.com/D3XT3R404/dex-sec/issues
11
+ Keywords: security,sast,dast,appsec,pentest,vulnerability-scanner,code-audit,owasp,sarif,php,javascript,typescript,java,go,csharp,ruby
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Information Technology
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Topic :: Security
24
+ Classifier: Topic :: Software Development :: Quality Assurance
25
+ Classifier: Topic :: Software Development :: Testing
26
+ Requires-Python: >=3.10
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: rich>=13.0.0
30
+ Requires-Dist: requests>=2.31.0
31
+ Requires-Dist: pydantic>=2.0.0
32
+ Requires-Dist: typer>=0.9.0
33
+ Requires-Dist: python-dotenv>=1.0.0
34
+ Provides-Extra: llm
35
+ Requires-Dist: openai>=1.0.0; extra == "llm"
36
+ Requires-Dist: anthropic>=0.30.0; extra == "llm"
37
+ Requires-Dist: google-generativeai>=0.5.0; extra == "llm"
38
+ Provides-Extra: yaml
39
+ Requires-Dist: pyyaml>=6.0; extra == "yaml"
40
+ Provides-Extra: dev
41
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
42
+ Requires-Dist: build>=1.0.0; extra == "dev"
43
+ Requires-Dist: twine>=5.0.0; extra == "dev"
44
+ Requires-Dist: pyinstaller>=6.0.0; extra == "dev"
45
+ Requires-Dist: pyyaml>=6.0; extra == "dev"
46
+ Dynamic: license-file
47
+
48
+ # DEX-SEC
49
+
50
+ **Inside-Out Hybrid Application Security Testing CLI** — membaca kode dari dalam, memverifikasi exploitability dari luar, lalu menghasilkan patch perbaikan otomatis.
51
+
52
+ ```
53
+ KODE (dalam) ──► ROUTE MAP + TAINTED SINKS ──► TARGETED SAFE PROBE (luar)
54
+ │
55
+ CONFIRMED / POTENTIAL / NOT REPRODUCIBLE
56
+ │
57
+ ┌───────────────────────────┼───────────────────────────┐
58
+ ▼ ▼ ▼
59
+ AI PATCH (git diff) ATTACK CHAIN ANALYSIS NEXT STEP ADVISOR
60
+ │ │ │
61
+ └────────────► REPORT (terminal + MD + JSON) ◄──────┘
62
+ ```
63
+
64
+ [![Python](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/)
65
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
66
+ [![Version](https://img.shields.io/badge/version-0.3.0-orange.svg)](CHANGELOG.md)
67
+
68
+ ## Kenapa berbeda dari scanner biasa
69
+
70
+ | Tool biasa | DEX-SEC |
71
+ | --- | --- |
72
+ | SAST hanya baca kode, banyak false positive | Kode + bukti eksploitasi eksternal = status `CONFIRMED_VULNERABLE` |
73
+ | DAST buta, tidak tahu struktur aplikasi | Hanya menguji endpoint yang memang mencurigai dari kode |
74
+ | Laporan PDF abstrak | Diff patch siap pakai + PoC `curl` yang aman |
75
+ | Butuh API key untuk hasil berguna | Patching heuristik offline sebagai fallback |
76
+ | Hanya bisa scan satu mode | Static **dan** black-box (OpenAPI fuzzing) dalam satu tool |
77
+
78
+ ## Bahasa yang didukung
79
+
80
+ | Bahasa | Deteksi kode | Deteksi route | Catatan |
81
+ | --- | --- | --- | --- |
82
+ | **Python** | ✅ AST (alur data nyata, interprocedural) | FastAPI, Flask, Django, custom router | paling akurat |
83
+ | **PHP** | ✅ `$_GET/$_POST/$_REQUEST/$_FILES`, mysqli/PDO, `system`, `include`, `unserialize`, `echo` | ✅ setiap file `.php` = endpoint (dengan parameter query) | + call graph: sink di library dilaporkan di halaman pemanggilnya |
84
+ | **JavaScript / TypeScript** | ✅ template literal, `const/let/var`, `child_process`, `fs`, `axios` | Express, Next.js, Fastify | |
85
+ | **Java / Kotlin** | ✅ `getParameter`, JDBC, `Runtime.exec`, `ObjectInputStream` | Spring, JAX-RS | |
86
+ | **Go** | ✅ `r.URL.Query().Get`, `db.Query(fmt.Sprintf)`, `exec.Command` | `http.HandleFunc` | |
87
+ | **C#** | ✅ `Request.Query`, `SqlCommand`, `Process.Start`, `File.ReadAllText` | ASP.NET `[HttpGet]` | |
88
+ | **Ruby** | ✅ `params[:x]`, `where("...")`, `system`, `raw(...)` | Rails | |
89
+
90
+ Tambah bahasa baru? Cukup tambahkan satu blok `LanguageSpec` di
91
+ `dexsec/sast/languages.py` — mesin analysenya tidak perlu diubah.
92
+
93
+ ## Bentuk tool
94
+
95
+ CLI, bukan GUI/web app. Sekali di-install (`pip install -e .`) perintahnya `dexsec` tersedia di terminal mana pun.
96
+ Detail lengkap: **[INSTALL.md](INSTALL.md)**.
97
+
98
+ ## TUTORIAL: 5 menit pakai DEX-SEC
99
+
100
+ ### Langkah 1 — Install (sekali saja)
101
+ ```powershell
102
+ cd C:\Users\ASUS\dex-sec
103
+ python -m pip install --upgrade setuptools wheel
104
+ python -m pip install -e .
105
+ dexsec version # harus keluar: DEX-SEC 0.3.0
106
+ ```
107
+ Alternatif tanpa Python di mesin target: pakai `dist\dexsec.exe` (file tunggal, 14 MB).
108
+ > Kalau `dexsec` "tidak dikenali", buka terminal baru (PATH baru berlaku di terminal baru),
109
+ > atau pakai `python -m dexsec ...` (fungsinya identik).
110
+
111
+ Cek kondisi instalasi kapan saja:
112
+ ```powershell
113
+ dexsec doctor # versi, dependency, PATH
114
+ dexsec doctor --target http://localhost:3000 # + target bisa dijangkau?
115
+ ```
116
+
117
+ ### Langkah 2 — Jalankan target uji (opsional, buat lihat hasilnya)
118
+ ```powershell
119
+ python demo\vulnerable_app.py # aplikasi sengaja rentan, http://127.0.0.1:8765
120
+ ```
121
+
122
+ ### Langkah 3 — Audit
123
+ ```powershell
124
+ # A. Static only (tanpa server jalan) — aman untuk repo mana pun
125
+ dexsec scan --path .
126
+
127
+ # B. Static + verifikasi eksploitasi ke target hidup
128
+ dexsec scan --path . --target http://127.0.0.1:8765
129
+
130
+ # C. Lengkap: laporan + file patch
131
+ dexsec scan --path . --target http://127.0.0.1:8765 --report report.md --json report.json
132
+
133
+ # D. Black-box fuzzing dari OpenAPI spec
134
+ dexsec fuzz --spec demo\openapi.yaml --target http://127.0.0.1:8765
135
+
136
+ # E. Daftar route API yang terdeteksi di kode
137
+ dexsec routes --path .
138
+ ```
139
+
140
+ ### Langkah 4 — Baca hasilnya
141
+ 1. **Tabel hasil** → status tiap temuan: `CONFIRMED_VULNERABLE` (bukti eksploitasi ada),
142
+ `POTENTIAL` (menarik, belum terbukti), `NOT_REPRODUCIBLE` (sudah aman).
143
+ 2. **Panel detail** → dampak, cara perbaikan, bukti eksploitasi, dan PoC `curl` siap pakai.
144
+ 3. **Attack Chains** → beberapa temuan digabung jadi skenario eksploitasi nyata.
145
+ 4. **Next Steps** → rencana tindak lanjut + perintah aman yang bisa dijalankan.
146
+ 5. **Patch otomatis** → `dexsec-fixes.patch`, cek dulu: `git apply --check dexsec-fixes.patch`.
147
+
148
+ ### Langkah 5 — Terapkan patch (opsional)
149
+ ```powershell
150
+ git apply --check dexsec-fixes.patch # pastikan aman dulu
151
+ git apply dexsec-fixes.patch
152
+ # atau langsung: dexsec scan --path . --target ... --apply-patches
153
+ ```
154
+
155
+ ### Blocker commit otomatis
156
+ ```powershell
157
+ dexsec hook --install # pasang pre-commit hook (blokir HIGH/CRITICAL)
158
+ ```
159
+
160
+ ### Cara pakai di harian / CI
161
+ ```powershell
162
+ # sebelum commit
163
+ dexsec scan --path . --target http://localhost:3000 --apply-patches
164
+ git diff
165
+ ```
166
+ ```yaml
167
+ # GitHub Actions (siap pakai di .github/workflows/dexsec.yml)
168
+ - run: pip install ./
169
+ - run: dexsec scan --path . --target ${{ secrets.STAGING_URL }} --json dexsec.json
170
+ ```
171
+
172
+ ### Kalau butuh patch yang lebih"contextual" (opsional)
173
+ ```powershell
174
+ $env:DEXSEC_AI_KEY = "sk-..." # OpenAI / Anthropic / Gemini
175
+ dexsec scan --path . --target http://127.0.0.1:8765 --ai-provider openai --ai-model gpt-4o-mini
176
+ ```
177
+ Tanpa API key pun tool tetap jalan (patch pakai heuristik offline).
178
+
179
+ ### Perintah cheat sheet
180
+ | Perintah | Fungsi |
181
+ | --- | --- |
182
+ | `dexsec scan --path <dir> --target <url>` | Audit lengkap 7 fase |
183
+ | `dexsec scan --path <dir> --skip-dast` | Analisis statis saja |
184
+ | `dexsec scan --format json\|sarif\|md\|html` | Output machine-readable ke stdout (untuk CI/editor) |
185
+ | `dexsec fix --path <dir> [--dry-run]` | **Terapkan patch otomatis** (+ commit git opsional) |
186
+ | `dexsec watch --path <dir> --target <url>` | Scan ulang otomatis saat file berubah |
187
+ | `dexsec fuzz --spec <openapi> --target <url>` | Black-box API fuzzing (aman) |
188
+ | `dexsec routes --path <dir>` | Daftar route HTTP di kode |
189
+ | `dexsec config` / `dexsec init` | Lihat / buat file konfigurasi (`dexsec.toml`) |
190
+ | `dexsec manual` | Baca panduan lengkap **offline** (ikut ter-install) |
191
+ | `dexsec hook --install` | Pasang pre-commit hook |
192
+ | `dexsec doctor [--target <url>]` | Cek instalasi & target |
193
+ | `dexsec upgrade` | Cek versi terbaru & perbarui (untuk binary) |
194
+ | `dexsec version` | Info versi |
195
+
196
+ ## Konfigurasi (opsional)
197
+
198
+ Buat file konfigurasi supaya tidak mengulang opsi di setiap perintah:
199
+
200
+ ```powershell
201
+ dexsec init # membuat dexsec.toml di project ini
202
+ dexsec init --scope user # atau di ~/.config/dexsec/config.toml
203
+ ```
204
+
205
+ ```toml
206
+ exclude = ["vendor", "storage"] # folder tambahan yang dilewati
207
+ min_severity = "MEDIUM" # sembunyikan temuan di bawah ini
208
+ target = "http://127.0.0.1:3000" # target default
209
+
210
+ [notify]
211
+ url = "https://hooks.slack.com/services/..."
212
+ level = "CRITICAL"
213
+
214
+ [ai]
215
+ provider = "openai"
216
+ model = "gpt-4o-mini"
217
+ key_env = "DEXSEC_AI_KEY"
218
+ ```
219
+ Semua nilai bisa ditimpa per perintah (`--target`, `--min-severity`, dst).
220
+
221
+ ## 7 Fase Pipeline
222
+
223
+ 1. **Inside Inspection** — route discovery (FastAPI/Flask/Django/Express/Laravel/Spring/Go + custom router Python) + deteksi sink bertaint (**AST-based untuk Python**, regex untuk bahasa lain) + taint lintas file + analisis access control (IDOR/BOLA) + scan file konfigurasi (`.env`, Dockerfile, nginx) + cookie/session checks.
224
+ 2. **Outside Safe Verification** — probe read-only: timing (blind SQLi), error-signature, boolean differential, canary echo, file marker, open redirect, SSTI, NoSQL operator, JWT `alg:none`, IDOR object diff, **OAST lokal (SSRF/XXE)**, mass-assignment marker, security headers, CORS, GraphQL introspection.
225
+ 3. **Correlation** — menggabungkan status kode & bukti eksternal → `CONFIRMED_VULNERABLE` / `POTENTIAL` / `NOT_REPRODUCIBLE` + severity akhir.
226
+ 4. **AI Remediation** — LLM menghasilkan unified diff; jika tanpa API key, heuristik offline membuatkan patch. Semua patch divalidasi sebelum ditawarkan.
227
+ 5. **Attack Chain Analysis** — menggabungkan beberapa temuan menjadi skenario eksploitasi nyata (SSRF→metadata→kredensial, IDOR→write, JWT none→impersonasi, dst).
228
+ 6. **Next Step Advisor** — rencana tindak lanjut per temuan: apa yang harus dicek berikutnya, apa risikonya, dan perintah aman yang bisa dijalankan. Mode heuristik offline (default) atau mode LLM.
229
+ 7. **Report** — ringkasan Rich di terminal + **Markdown, JSON, HTML interaktif, Executive Summary PDF, dan SARIF** (untuk GitHub Code Scanning & IDE).
230
+
231
+ ## Panduan lengkap
232
+
233
+ 📘 **[docs/PANDUAN-OPERASIONAL.md](docs/PANDUAN-OPERASIONAL.md)** — panduan step-by-step untuk pemula: install → latihan dengan aplikasi contoh → memakai di project sendiri → workflow harian & CI.
234
+ 🎓 **[sandbox/vuln_web/README.md](sandbox/vuln_web/README.md)** — aplikasi web latihan yang sengaja rentan (SQL Injection) untuk mencoba DEX-SEC sendiri.
235
+ 📊 **[docs/COVERAGE.md](docs/COVERAGE.md)** — matriks seluruh kelas kerentanan.
236
+ 🧩 **[docs/schema/audit-report.schema.json](docs/schema/audit-report.schema.json)** — skema JSON laporan (untuk integrasi tool lain).
237
+
238
+ ## Coverage kerentanan
239
+
240
+ Lihat **[docs/COVERAGE.md](docs/COVERAGE.md)** untuk matriks lengkap (21 kelas sudah deteksi + verifikasi, 4 statis saja, 13 terjadwal, sisanya milik tool lain).
241
+
242
+ ## Keamanan
243
+
244
+ Semua probe **non-destruktif**: tidak ada `DROP`/`DELETE`/`rm`; hanya mengukur delay, membaca error, dan mencocokkan canary/penanda file.
245
+
246
+ ## Gimana tool ini memindai & di mana hasilnya
247
+
248
+ **Pemindaian = rekursif penuh.**Diberi satu folder, DEX-SEC membaca **seluruh
249
+ pohon folder** (root + semua subfolder, tanpa batas kedalaman), lalu melewati
250
+ folder yang memang tidak relevan: `.git`, `node_modules`, `__pycache__`,
251
+ `venv/.venv`, `dist/build`, `vendor`, `site-packages`, dan sejenisnya.
252
+
253
+ ```
254
+ dexsec scan --path C:\path\ke\project
255
+ └─ dibaca: project\file.py
256
+ project\sub\file.py
257
+ project\sub\module\file.php ← subfolder ikut
258
+ project\sub\deep\nested\file.js ← nested ikut
259
+ ```
260
+
261
+ **Hasil scan tidak pernah ditulis ke folder yang discan.** Semua laporan
262
+ diletakkan di folder khusus:
263
+
264
+ ```
265
+ C:\Users\ASUS\dex-sec\hasil-scan\<nama-project>\<timestamp>-<host>\
266
+ ├── laporan.md ringkasan Markdown
267
+ ├── laporan.json data lengkap (untuk CI / tool lain)
268
+ ├── laporan.html laporan interaktif (search & sort)
269
+ ├── ringkasan.pdf ringkasan eksekutif
270
+ ├── laporan.sarif format SARIF (GitHub Code Scanning / IDE)
271
+ └── dexsec-fixes.patch usulan perbaikan
272
+ ```
273
+ Ganti lokasi dengan `--out-dir <folder>` atau env `DEXSEC_OUTPUT_ROOT`.
274
+
275
+ ## Self-test
276
+
277
+ ```powershell
278
+ python tests\selftest.py
279
+ ```
280
+ Mendemonstrasikan round-trip: celah confirmed → patch otomatis → `git apply` → scan ulang → celah tersebut hilang.
281
+
282
+ ## Struktur
283
+
284
+ ```
285
+ dexsec/ paket Python (sast/ dast/ core/ ai/ cli.py models.py hooks.py)
286
+ demo/ aplikasi uji yang sengaja rentan + contoh config/CD + openapi.yaml
287
+ docs/ COVERAGE.md
288
+ npm/ wrapper NPM
289
+ .github/ GitHub Action
290
+ dist/ dexsec.exe (file tunggal, hasil PyInstaller)
291
+ tests/ selftest.py, test_features.py, list_findings.py
292
+ INSTALL.md panduan instalasi & penggunaan
293
+ CHANGELOG.md riwayat rilis
294
+ ROADMAP.md antrian kerja CURRENT_STATE.md log sinkronisasi
295
+ AI_HANDOFF.md protokol kolaborasi multi-AI ARCHITECTURE.md desain
296
+ ```
297
+
298
+ ## Lisensi
299
+
300
+ MIT — lihat [LICENSE](LICENSE). Jalankan hanya pada sistem yang kamu miliki atau
301
+ yang kamu punya izin untuk mengujinya.
dexsec-0.7.1/README.md ADDED
@@ -0,0 +1,254 @@
1
+ # DEX-SEC
2
+
3
+ **Inside-Out Hybrid Application Security Testing CLI** — membaca kode dari dalam, memverifikasi exploitability dari luar, lalu menghasilkan patch perbaikan otomatis.
4
+
5
+ ```
6
+ KODE (dalam) ──► ROUTE MAP + TAINTED SINKS ──► TARGETED SAFE PROBE (luar)
7
+ │
8
+ CONFIRMED / POTENTIAL / NOT REPRODUCIBLE
9
+ │
10
+ ┌───────────────────────────┼───────────────────────────┐
11
+ ▼ ▼ ▼
12
+ AI PATCH (git diff) ATTACK CHAIN ANALYSIS NEXT STEP ADVISOR
13
+ │ │ │
14
+ └────────────► REPORT (terminal + MD + JSON) ◄──────┘
15
+ ```
16
+
17
+ [![Python](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/)
18
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
19
+ [![Version](https://img.shields.io/badge/version-0.3.0-orange.svg)](CHANGELOG.md)
20
+
21
+ ## Kenapa berbeda dari scanner biasa
22
+
23
+ | Tool biasa | DEX-SEC |
24
+ | --- | --- |
25
+ | SAST hanya baca kode, banyak false positive | Kode + bukti eksploitasi eksternal = status `CONFIRMED_VULNERABLE` |
26
+ | DAST buta, tidak tahu struktur aplikasi | Hanya menguji endpoint yang memang mencurigai dari kode |
27
+ | Laporan PDF abstrak | Diff patch siap pakai + PoC `curl` yang aman |
28
+ | Butuh API key untuk hasil berguna | Patching heuristik offline sebagai fallback |
29
+ | Hanya bisa scan satu mode | Static **dan** black-box (OpenAPI fuzzing) dalam satu tool |
30
+
31
+ ## Bahasa yang didukung
32
+
33
+ | Bahasa | Deteksi kode | Deteksi route | Catatan |
34
+ | --- | --- | --- | --- |
35
+ | **Python** | ✅ AST (alur data nyata, interprocedural) | FastAPI, Flask, Django, custom router | paling akurat |
36
+ | **PHP** | ✅ `$_GET/$_POST/$_REQUEST/$_FILES`, mysqli/PDO, `system`, `include`, `unserialize`, `echo` | ✅ setiap file `.php` = endpoint (dengan parameter query) | + call graph: sink di library dilaporkan di halaman pemanggilnya |
37
+ | **JavaScript / TypeScript** | ✅ template literal, `const/let/var`, `child_process`, `fs`, `axios` | Express, Next.js, Fastify | |
38
+ | **Java / Kotlin** | ✅ `getParameter`, JDBC, `Runtime.exec`, `ObjectInputStream` | Spring, JAX-RS | |
39
+ | **Go** | ✅ `r.URL.Query().Get`, `db.Query(fmt.Sprintf)`, `exec.Command` | `http.HandleFunc` | |
40
+ | **C#** | ✅ `Request.Query`, `SqlCommand`, `Process.Start`, `File.ReadAllText` | ASP.NET `[HttpGet]` | |
41
+ | **Ruby** | ✅ `params[:x]`, `where("...")`, `system`, `raw(...)` | Rails | |
42
+
43
+ Tambah bahasa baru? Cukup tambahkan satu blok `LanguageSpec` di
44
+ `dexsec/sast/languages.py` — mesin analysenya tidak perlu diubah.
45
+
46
+ ## Bentuk tool
47
+
48
+ CLI, bukan GUI/web app. Sekali di-install (`pip install -e .`) perintahnya `dexsec` tersedia di terminal mana pun.
49
+ Detail lengkap: **[INSTALL.md](INSTALL.md)**.
50
+
51
+ ## TUTORIAL: 5 menit pakai DEX-SEC
52
+
53
+ ### Langkah 1 — Install (sekali saja)
54
+ ```powershell
55
+ cd C:\Users\ASUS\dex-sec
56
+ python -m pip install --upgrade setuptools wheel
57
+ python -m pip install -e .
58
+ dexsec version # harus keluar: DEX-SEC 0.3.0
59
+ ```
60
+ Alternatif tanpa Python di mesin target: pakai `dist\dexsec.exe` (file tunggal, 14 MB).
61
+ > Kalau `dexsec` "tidak dikenali", buka terminal baru (PATH baru berlaku di terminal baru),
62
+ > atau pakai `python -m dexsec ...` (fungsinya identik).
63
+
64
+ Cek kondisi instalasi kapan saja:
65
+ ```powershell
66
+ dexsec doctor # versi, dependency, PATH
67
+ dexsec doctor --target http://localhost:3000 # + target bisa dijangkau?
68
+ ```
69
+
70
+ ### Langkah 2 — Jalankan target uji (opsional, buat lihat hasilnya)
71
+ ```powershell
72
+ python demo\vulnerable_app.py # aplikasi sengaja rentan, http://127.0.0.1:8765
73
+ ```
74
+
75
+ ### Langkah 3 — Audit
76
+ ```powershell
77
+ # A. Static only (tanpa server jalan) — aman untuk repo mana pun
78
+ dexsec scan --path .
79
+
80
+ # B. Static + verifikasi eksploitasi ke target hidup
81
+ dexsec scan --path . --target http://127.0.0.1:8765
82
+
83
+ # C. Lengkap: laporan + file patch
84
+ dexsec scan --path . --target http://127.0.0.1:8765 --report report.md --json report.json
85
+
86
+ # D. Black-box fuzzing dari OpenAPI spec
87
+ dexsec fuzz --spec demo\openapi.yaml --target http://127.0.0.1:8765
88
+
89
+ # E. Daftar route API yang terdeteksi di kode
90
+ dexsec routes --path .
91
+ ```
92
+
93
+ ### Langkah 4 — Baca hasilnya
94
+ 1. **Tabel hasil** → status tiap temuan: `CONFIRMED_VULNERABLE` (bukti eksploitasi ada),
95
+ `POTENTIAL` (menarik, belum terbukti), `NOT_REPRODUCIBLE` (sudah aman).
96
+ 2. **Panel detail** → dampak, cara perbaikan, bukti eksploitasi, dan PoC `curl` siap pakai.
97
+ 3. **Attack Chains** → beberapa temuan digabung jadi skenario eksploitasi nyata.
98
+ 4. **Next Steps** → rencana tindak lanjut + perintah aman yang bisa dijalankan.
99
+ 5. **Patch otomatis** → `dexsec-fixes.patch`, cek dulu: `git apply --check dexsec-fixes.patch`.
100
+
101
+ ### Langkah 5 — Terapkan patch (opsional)
102
+ ```powershell
103
+ git apply --check dexsec-fixes.patch # pastikan aman dulu
104
+ git apply dexsec-fixes.patch
105
+ # atau langsung: dexsec scan --path . --target ... --apply-patches
106
+ ```
107
+
108
+ ### Blocker commit otomatis
109
+ ```powershell
110
+ dexsec hook --install # pasang pre-commit hook (blokir HIGH/CRITICAL)
111
+ ```
112
+
113
+ ### Cara pakai di harian / CI
114
+ ```powershell
115
+ # sebelum commit
116
+ dexsec scan --path . --target http://localhost:3000 --apply-patches
117
+ git diff
118
+ ```
119
+ ```yaml
120
+ # GitHub Actions (siap pakai di .github/workflows/dexsec.yml)
121
+ - run: pip install ./
122
+ - run: dexsec scan --path . --target ${{ secrets.STAGING_URL }} --json dexsec.json
123
+ ```
124
+
125
+ ### Kalau butuh patch yang lebih"contextual" (opsional)
126
+ ```powershell
127
+ $env:DEXSEC_AI_KEY = "sk-..." # OpenAI / Anthropic / Gemini
128
+ dexsec scan --path . --target http://127.0.0.1:8765 --ai-provider openai --ai-model gpt-4o-mini
129
+ ```
130
+ Tanpa API key pun tool tetap jalan (patch pakai heuristik offline).
131
+
132
+ ### Perintah cheat sheet
133
+ | Perintah | Fungsi |
134
+ | --- | --- |
135
+ | `dexsec scan --path <dir> --target <url>` | Audit lengkap 7 fase |
136
+ | `dexsec scan --path <dir> --skip-dast` | Analisis statis saja |
137
+ | `dexsec scan --format json\|sarif\|md\|html` | Output machine-readable ke stdout (untuk CI/editor) |
138
+ | `dexsec fix --path <dir> [--dry-run]` | **Terapkan patch otomatis** (+ commit git opsional) |
139
+ | `dexsec watch --path <dir> --target <url>` | Scan ulang otomatis saat file berubah |
140
+ | `dexsec fuzz --spec <openapi> --target <url>` | Black-box API fuzzing (aman) |
141
+ | `dexsec routes --path <dir>` | Daftar route HTTP di kode |
142
+ | `dexsec config` / `dexsec init` | Lihat / buat file konfigurasi (`dexsec.toml`) |
143
+ | `dexsec manual` | Baca panduan lengkap **offline** (ikut ter-install) |
144
+ | `dexsec hook --install` | Pasang pre-commit hook |
145
+ | `dexsec doctor [--target <url>]` | Cek instalasi & target |
146
+ | `dexsec upgrade` | Cek versi terbaru & perbarui (untuk binary) |
147
+ | `dexsec version` | Info versi |
148
+
149
+ ## Konfigurasi (opsional)
150
+
151
+ Buat file konfigurasi supaya tidak mengulang opsi di setiap perintah:
152
+
153
+ ```powershell
154
+ dexsec init # membuat dexsec.toml di project ini
155
+ dexsec init --scope user # atau di ~/.config/dexsec/config.toml
156
+ ```
157
+
158
+ ```toml
159
+ exclude = ["vendor", "storage"] # folder tambahan yang dilewati
160
+ min_severity = "MEDIUM" # sembunyikan temuan di bawah ini
161
+ target = "http://127.0.0.1:3000" # target default
162
+
163
+ [notify]
164
+ url = "https://hooks.slack.com/services/..."
165
+ level = "CRITICAL"
166
+
167
+ [ai]
168
+ provider = "openai"
169
+ model = "gpt-4o-mini"
170
+ key_env = "DEXSEC_AI_KEY"
171
+ ```
172
+ Semua nilai bisa ditimpa per perintah (`--target`, `--min-severity`, dst).
173
+
174
+ ## 7 Fase Pipeline
175
+
176
+ 1. **Inside Inspection** — route discovery (FastAPI/Flask/Django/Express/Laravel/Spring/Go + custom router Python) + deteksi sink bertaint (**AST-based untuk Python**, regex untuk bahasa lain) + taint lintas file + analisis access control (IDOR/BOLA) + scan file konfigurasi (`.env`, Dockerfile, nginx) + cookie/session checks.
177
+ 2. **Outside Safe Verification** — probe read-only: timing (blind SQLi), error-signature, boolean differential, canary echo, file marker, open redirect, SSTI, NoSQL operator, JWT `alg:none`, IDOR object diff, **OAST lokal (SSRF/XXE)**, mass-assignment marker, security headers, CORS, GraphQL introspection.
178
+ 3. **Correlation** — menggabungkan status kode & bukti eksternal → `CONFIRMED_VULNERABLE` / `POTENTIAL` / `NOT_REPRODUCIBLE` + severity akhir.
179
+ 4. **AI Remediation** — LLM menghasilkan unified diff; jika tanpa API key, heuristik offline membuatkan patch. Semua patch divalidasi sebelum ditawarkan.
180
+ 5. **Attack Chain Analysis** — menggabungkan beberapa temuan menjadi skenario eksploitasi nyata (SSRF→metadata→kredensial, IDOR→write, JWT none→impersonasi, dst).
181
+ 6. **Next Step Advisor** — rencana tindak lanjut per temuan: apa yang harus dicek berikutnya, apa risikonya, dan perintah aman yang bisa dijalankan. Mode heuristik offline (default) atau mode LLM.
182
+ 7. **Report** — ringkasan Rich di terminal + **Markdown, JSON, HTML interaktif, Executive Summary PDF, dan SARIF** (untuk GitHub Code Scanning & IDE).
183
+
184
+ ## Panduan lengkap
185
+
186
+ 📘 **[docs/PANDUAN-OPERASIONAL.md](docs/PANDUAN-OPERASIONAL.md)** — panduan step-by-step untuk pemula: install → latihan dengan aplikasi contoh → memakai di project sendiri → workflow harian & CI.
187
+ 🎓 **[sandbox/vuln_web/README.md](sandbox/vuln_web/README.md)** — aplikasi web latihan yang sengaja rentan (SQL Injection) untuk mencoba DEX-SEC sendiri.
188
+ 📊 **[docs/COVERAGE.md](docs/COVERAGE.md)** — matriks seluruh kelas kerentanan.
189
+ 🧩 **[docs/schema/audit-report.schema.json](docs/schema/audit-report.schema.json)** — skema JSON laporan (untuk integrasi tool lain).
190
+
191
+ ## Coverage kerentanan
192
+
193
+ Lihat **[docs/COVERAGE.md](docs/COVERAGE.md)** untuk matriks lengkap (21 kelas sudah deteksi + verifikasi, 4 statis saja, 13 terjadwal, sisanya milik tool lain).
194
+
195
+ ## Keamanan
196
+
197
+ Semua probe **non-destruktif**: tidak ada `DROP`/`DELETE`/`rm`; hanya mengukur delay, membaca error, dan mencocokkan canary/penanda file.
198
+
199
+ ## Gimana tool ini memindai & di mana hasilnya
200
+
201
+ **Pemindaian = rekursif penuh.**Diberi satu folder, DEX-SEC membaca **seluruh
202
+ pohon folder** (root + semua subfolder, tanpa batas kedalaman), lalu melewati
203
+ folder yang memang tidak relevan: `.git`, `node_modules`, `__pycache__`,
204
+ `venv/.venv`, `dist/build`, `vendor`, `site-packages`, dan sejenisnya.
205
+
206
+ ```
207
+ dexsec scan --path C:\path\ke\project
208
+ └─ dibaca: project\file.py
209
+ project\sub\file.py
210
+ project\sub\module\file.php ← subfolder ikut
211
+ project\sub\deep\nested\file.js ← nested ikut
212
+ ```
213
+
214
+ **Hasil scan tidak pernah ditulis ke folder yang discan.** Semua laporan
215
+ diletakkan di folder khusus:
216
+
217
+ ```
218
+ C:\Users\ASUS\dex-sec\hasil-scan\<nama-project>\<timestamp>-<host>\
219
+ ├── laporan.md ringkasan Markdown
220
+ ├── laporan.json data lengkap (untuk CI / tool lain)
221
+ ├── laporan.html laporan interaktif (search & sort)
222
+ ├── ringkasan.pdf ringkasan eksekutif
223
+ ├── laporan.sarif format SARIF (GitHub Code Scanning / IDE)
224
+ └── dexsec-fixes.patch usulan perbaikan
225
+ ```
226
+ Ganti lokasi dengan `--out-dir <folder>` atau env `DEXSEC_OUTPUT_ROOT`.
227
+
228
+ ## Self-test
229
+
230
+ ```powershell
231
+ python tests\selftest.py
232
+ ```
233
+ Mendemonstrasikan round-trip: celah confirmed → patch otomatis → `git apply` → scan ulang → celah tersebut hilang.
234
+
235
+ ## Struktur
236
+
237
+ ```
238
+ dexsec/ paket Python (sast/ dast/ core/ ai/ cli.py models.py hooks.py)
239
+ demo/ aplikasi uji yang sengaja rentan + contoh config/CD + openapi.yaml
240
+ docs/ COVERAGE.md
241
+ npm/ wrapper NPM
242
+ .github/ GitHub Action
243
+ dist/ dexsec.exe (file tunggal, hasil PyInstaller)
244
+ tests/ selftest.py, test_features.py, list_findings.py
245
+ INSTALL.md panduan instalasi & penggunaan
246
+ CHANGELOG.md riwayat rilis
247
+ ROADMAP.md antrian kerja CURRENT_STATE.md log sinkronisasi
248
+ AI_HANDOFF.md protokol kolaborasi multi-AI ARCHITECTURE.md desain
249
+ ```
250
+
251
+ ## Lisensi
252
+
253
+ MIT — lihat [LICENSE](LICENSE). Jalankan hanya pada sistem yang kamu miliki atau
254
+ yang kamu punya izin untuk mengujinya.
@@ -0,0 +1,25 @@
1
+ """DEX-SEC — Inside-Out Hybrid Application Security Testing CLI.
2
+
3
+ Fase:
4
+ 1. Inside Inspection -> route discovery + taint analysis (SAST)
5
+ 2. Outside Verification-> safe, non-destructive probes against a live target
6
+ 3. Correlation -> confirmed / potential / not reproducible
7
+ 4. AI Remediation -> unified diff (LLM) or offline heuristic fallback
8
+ 5. Attack Chain Analysis
9
+ 6. Next Step Advisor
10
+ 7. Reporting -> terminal summary + Markdown/JSON/HTML/PDF/SARIF
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ try: # installed package -> use the metadata (single source of truth)
16
+ from importlib.metadata import PackageNotFoundError, version as _version
17
+
18
+ try:
19
+ __version__ = _version("dexsec")
20
+ except PackageNotFoundError: # running from a source checkout
21
+ __version__ = "0.7.0"
22
+ except ImportError: # pragma: no cover - Python < 3.8
23
+ __version__ = "0.7.0"
24
+
25
+ __all__ = ["__version__"]
@@ -0,0 +1,4 @@
1
+ from .cli import main
2
+
3
+ if __name__ == "__main__":
4
+ main()
File without changes