Metadata-Version: 2.4
Name: sidik
Version: 1.3.7
Summary: SIDIK: Secret Identification and Dependency Inspection Kit (Lightweight Offline Python SAST & SCA)
Author: Radityo Budi Waskito, Fauzi Nur Ibrahim, Raditya Ahmad Pratama, Zayyan Fadhlur Rahman, Muhammad Fahri Indra Saputra, Mohamad Hilman
License-Expression: MIT
Project-URL: Homepage, https://github.com/radityobw/SIDIK
Project-URL: Repository, https://github.com/radityobw/SIDIK
Project-URL: Issues, https://github.com/radityobw/SIDIK/issues
Project-URL: Changelog, https://github.com/radityobw/SIDIK/blob/main/CHANGELOG.md
Keywords: security,sast,sca,secret-detection,vulnerability-scanner,osv,sarif
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: packaging>=23.0
Requires-Dist: tomli>=2.0.0; python_version < "3.11"
Provides-Extra: gui
Requires-Dist: pillow>=10.0.0; extra == "gui"
Requires-Dist: matplotlib>=3.8.0; extra == "gui"
Provides-Extra: dev
Requires-Dist: python-docx>=1.2.0; extra == "dev"
Requires-Dist: pip-audit>=2.10.0; extra == "dev"
Requires-Dist: build>=1.0.0; extra == "dev"
Requires-Dist: twine>=5.0.0; extra == "dev"
Dynamic: license-file

<div align="center">

<img src="https://raw.githubusercontent.com/radityobw/SIDIK/main/logo/SIDIK-nobg-dark.png" alt="SIDIK Logo" width="320"/>

# SIDIK: *Secret Identification and Dependency Inspection Kit*

**Instrumen Analisis Keamanan Statis (*SAST*) & Analisis Komposisi Perangkat Lunak (*SCA*) Luring Terpadu untuk Ekosistem Python**  
*Unified Offline Static Application Security Testing (SAST) & Software Composition Analysis (SCA) for Python*

[![Python 3.9+](https://img.shields.io/pypi/pyversions/sidik?color=3b82f6)](https://pypi.org/project/sidik/)
[![PyPI Version](https://img.shields.io/pypi/v/sidik?label=PyPI&color=0ea5e9)](https://pypi.org/project/sidik/)
[![GitHub Release](https://img.shields.io/github/v/release/radityobw/SIDIK?label=Release&color=0284c7)](https://github.com/radityobw/SIDIK/releases/latest)
[![CI Status](https://img.shields.io/github/actions/workflow/status/radityobw/SIDIK/sidik-security.yml?label=CI&color=22c55e)](https://github.com/radityobw/SIDIK/actions/workflows/sidik-security.yml)
[![Offline OSV DB](https://img.shields.io/badge/Offline%20OSV%20DB-35%2C304%20Advisories-10b981.svg)](https://github.com/radityobw/SIDIK/blob/main/sidik/data/pypi_advisories.json)
[![License: MIT](https://img.shields.io/badge/License-MIT-a855f7.svg)](https://github.com/radityobw/SIDIK/blob/main/LICENSE)

</div>

---

# 🇮🇩 Bahasa Indonesia

## 📌 Ikhtisar Proyek

**SIDIK** (*Secret Identification and Dependency Inspection Kit*) adalah instrumen analisis keamanan statis (*Static Application Security Testing* / SAST) dan analisis komposisi perangkat lunak (*Software Composition Analysis* / SCA) terpadu berbasis Python yang beroperasi **100% secara luring (*offline*)** tanpa mengirim kode sumber ke peladen pihak ketiga (*zero data leakage*).

Dengan mengintegrasikan **12 aturan ekspresi reguler (*regex*) terkurasi**, **kalkulasi entropi informasi Shannon**, dan **penyaringan konteks leksikal** bersama **basis data kerentanan lokal Google OSV (`35.304` rekaman advisori lintas `13.734` paket PyPI)** yang mendukung **format manifes & *lockfile* Python utama** (`requirements*.txt`, `pyproject.toml`, `Pipfile`/`Pipfile.lock`, `poetry.lock`, `uv.lock`, dan `setup.py`), SIDIK dirancang untuk mengatasi masalah kejenuhan peringatan (*alert fatigue*) sekaligus menghilangkan ketergantungan jaringan internet pada *pipeline* CI/CD maupun jaringan terisolasi (*air-gapped*).

### 👥 Tim Peneliti & Pengembang (Kontribusi Setara / *Equal First Authors*)
Jurusan Informatika, Fakultas Teknik, Universitas Sultan Ageng Tirtayasa (Untirta):
1. **Radityo Budi Waskito** (*Corresponding Author* - Orkestrasi *Pipeline* Terpadu, CLI Interaktif, & *GitHub Actions* CI/CD)
2. **Fauzi Nur Ibrahim** (Mesin Deteksi *Hardcoded Secret* 3 Lapis, Entropi Shannon, & Konteks Leksikal)
3. **Raditya Ahmad Pratama** (Mesin *Offline SCA* 5 Format Manifes, Evaluator Versi Semantik PEP 440, & Indeks OSV)
4. **Zayyan Fadhlur Rahman** (Konstruksi Korpus 25 Repositori GitHub Nyata, *Benchmark* SCA v2, & Evaluasi Komparatif)
5. **Muhammad Fahri Indra Saputra** (*Desktop GUI High-DPI* Dwibahasa, Lokalisasi `i18n`, & Pelaporan 7 Format termasuk SARIF v2.1.0)
6. **Mohamad Hilman** (Pembimbingan Metodologi Riset, Kurasi Riset Ilmiah, & Penelaahan Akademik)

---

## ✨ Fitur dan Kapabilitas Utama

1. **Deteksi *Hardcoded Secret* 3 Lapis (*Multi-Layer Secret Detection*):**
   - Mendeteksi 12 kategori kredensial sensitif (`SEC001` - `SEC012`: *AWS Access Key ID*, *Google API Key*, *OpenAI API Key*, *Stripe Live Key*, *GitHub Classic & Fine-Grained PAT*, *Slack Token*, *JSON Web Token*, *Hardcoded Password*, *Database Connection URI*, *Asymmetric Private Key*, dan *Generic High-Entropy Secret*).
   - Dilengkapi penyaring baris cepat (*fast line pre-check*), kalkulasi entropi Shannon, dan penyaringan konteks leksikal untuk mengeliminasi alarm palsu dari variabel tiruan (*mock*, *dummy*, *example*, *sample*, *test fixture*), UUID, maupun *hash* Git SHA-1.
2. **Analisis Komposisi Perangkat Lunak Luring (*Offline Multi-Manifest SCA*):**
   - Mendukung manifes dan *lockfile* Python utama: `requirements*.txt`, `pyproject.toml` (PEP 621, `[project.optional-dependencies]`, PEP 735 `[dependency-groups]`, & Poetry), `Pipfile`, `Pipfile.lock`, `poetry.lock`, `uv.lock`, dan `setup.py` (ekstraksi AST aman tanpa eksekusi kode dinamis).
   - Mengevaluasi spesifikasi versi terkunci (`==`) maupun rentang versi fleksibel (`>=`, `~=`, `<`, `!=`) sesuai standar PEP 440 serta daftar versi eksplisit OSV terhadap **`35.304` rekaman advisori kerentanan PyPI** (termasuk klasifikasi *CVSS v3/v4/v2* dan paket berbahaya `MAL-*`) secara instan tanpa koneksi internet.
3. **Tiga Mode Antarmuka (*Triple-Interface Ecosystem*):**
   - **Mode 1 - *One-Shot CLI* & Otomasi CI/CD (`python -m sidik` / `action.yml`):** Mendukung *git pre-commit hook* otomatis (`--install-hook`), ambang batas kegagalan (`--fail-on {any,low,medium,high,critical}`), dan integrasi *GitHub Actions*.
   - **Mode 2 - *Interactive CLI Menu* (`run_sidik_cli.bat` / `python sidik.py --cli`):** Antarmuka terminal interaktif berbasis menu bernomor yang mudah dioperasikan tanpa menghafal argumen baris perintah.
   - **Mode 3 - *Desktop GUI High-DPI* Dwibahasa (`run_sidik.bat` / `python sidik.py --gui`):** Antarmuka visual modern bertema gelap (*dark mode*) dengan 5 tombol *preset* korpus riset, pencarian instan (*live search*), penyalinan massal kode & solusi (*bulk copy*), serta tab **Visualisasi & Hasil Riset** yang merender grafik *benchmark* secara adaptif (*auto-resize*).
4. **Dukungan Dwibahasa Dinamis (*Instant Bilingual Toggle* ID ↔ EN) & Panduan Remediasi:**
   - Seluruh tampilan GUI, laporan konsol, dan rekomendasi perbaikan spesifik per aturan/CVE dapat dialihkan secara instan antara **Bahasa Indonesia (`id`)** dan **Bahasa Inggris (`en`)**.
5. **Tujuh Format Ekspor Laporan Standar Industri:**
   - Mendukung ekspor ke **Konsol Berwarna ANSI** (`console`), **OASIS SARIF v2.1.0** (`sarif` untuk *GitHub Code Scanning*), **GitHub Actions Workflow Annotations** (`github`), **Dasbor Web HTML Mandiri** (`html`), **Markdown** (`markdown`), **JSON Terstruktur** (`json`), dan **Tabel CSV/Spreadsheet** (`csv`).
6. **Mekanisme Pengecualian Fleksibel (*Whitelist & Ignore Support*):**
   - Mendukung berkas `.sidikignore` (sintaks pola `.gitignore`) serta komentar penekan sebaris (`# sidik:ignore`, `# nosec`, `# noqa: sidik`).
7. **Arsitektur Ekstensi *Plugin* Terdekupel (`sidik.plugins`):**
   - Menyediakan *hook* pasca-pemindaian berbasis `importlib.metadata.entry_points(group="sidik.plugins")` sehingga ekstensi opsional seperti `SIDIK-ML` dapat memperkaya CLI, konsol interaktif, GUI, serta laporan tanpa menambah dependensi ML ke `sidik`.

---

## 📁 Struktur Direktori Repositori

```text
SIDIK/
├── logo/                              # Aset identitas visual & ikon aplikasi multi-resolusi
├── sidik/                             # Paket inti mesin pemindai SIDIK
│   ├── __init__.py                    # Metadata paket & ekspor publik
│   ├── __main__.py                    # Titik masuk modul (python -m sidik)
│   ├── cli.py                         # Antarmuka One-Shot CLI, TUI Interaktif, & Git Hook
│   ├── core.py                        # Orkestrator SecurityScanner (SAST + SCA terpadu)
│   ├── gui.py                         # Antarmuka Desktop GUI High-DPI & Visualisasi Riset
│   ├── i18n.py                        # Mesin lokalisasi dwibahasa (ID/EN) & kamus remediasi
│   ├── models.py                      # Struktur data (SecretCandidate, Finding, ScanReport)
│   ├── plugins.py                     # Kontrak plugin terdekupel entry_points (sidik.plugins)
│   ├── data/
│   │   └── pypi_advisories.json       # Basis data luring 35.304 advisori OSV (13.734 paket PyPI)
│   ├── secret_detector/               # Subsistem deteksi kredensial rahasia 3 lapis
│   │   ├── patterns.py                # 12 aturan ekspresi reguler terkurasi (SEC001-SEC012)
│   │   ├── entropy.py                 # Kalkulator entropi informasi Shannon
│   │   ├── context.py                 # Penyaring konteks leksikal & indikator mock/test
│   │   └── detector.py                # Mesin pemindai secret dengan fast line pre-check
│   ├── dependency_analyzer/           # Subsistem analisis dependensi luring (Offline SCA)
│   │   ├── parsers.py                 # Pengurai 5 format manifes (req, toml, Pipfile, lock, setup.py)
│   │   ├── matcher.py                 # Pencocok rentang versi semantik PEP 440
│   │   ├── database.py                # Pengelola indeks advisori kerentanan lokal
│   │   ├── osv_import.py              # Kompilator snapshot Google OSV PyPI ke indeks lokal
│   │   └── analyzer.py                # Orkestrator pemindaian manifes dependensi
│   └── reporting/                     # Subsistem agregasi, deduplikasi, & 7 format laporan
│       ├── aggregator.py              # Penggabung temuan & kalkulator ringkasan keparahan
│       └── formatter.py               # Generator laporan (Console, SARIF, GitHub, HTML, MD, JSON, CSV)
├── dataset/                           # Korpus pengujian empiris (Zero Data Leakage)
│   ├── external/                      # Korpus 25 repositori GitHub nyata (186.876 LOC, 109 kandidat)
│   ├── dependencies_v2/               # Benchmark SCA v2 (70 manifes rakitan rilis PyPI; 39 berkas uji / N=200)
│   ├── secrets/                       # Dataset uji terkontrol & studi ablasi secret (N=100 berkas uji)
│   ├── dependencies/                  # Dataset manifes dependensi v1 (N=60)
│   └── ground_truth/                  # Anotasi label kebenaran dasar (JSON)
├── experiments/                       # Skrip otomatis evaluasi ilmiah & komparasi alat industri
│   ├── run_external_benchmarks.py     # Benchmark 25 repo nyata & komparasi Gitleaks, Bandit, Trivy, pip-audit
│   ├── run_experiments.py             # Evaluasi dataset terkontrol terhadap baseline internal
│   ├── ablation_study.py              # Studi ablasi 4 konfigurasi komponen (Konfig A, B, C, D)
│   ├── evaluate_metrics.py            # Kalkulator metrik (Precision, Recall, F1, MCC, FPR, FNR)
│   └── generate_charts.py             # Generator grafik publikasi (300 DPI) & bundel visualisasi GUI
├── figures/                           # Grafik hasil eksperimen (Paper & Dark-Theme GUI Bundle)
├── results/                           # Rekaman JSON hasil eksperimen & benchmark komparatif
├── tests/                             # Suite pengujian otomatis (73 unit & integration tests)
├── CHANGELOG.md                       # Riwayat rilis paket sidik
├── LICENSE                            # Lisensi MIT
├── pyproject.toml                     # Konfigurasi paket, dependencies, & entry points sidik/sidik-gui
├── action.yml                         # Definisi komposit GitHub Actions untuk integrasi CI/CD
├── sidik.py                           # Peluncur universal (GUI, Interactive CLI, & One-Shot CLI)
├── run_sidik.bat                      # Peluncur cepat Desktop GUI (Windows)
├── run_sidik_cli.bat                  # Peluncur cepat Interactive CLI Menu (Windows)
├── run_sidik.sh                       # Peluncur lintas platform (Linux / macOS)
└── requirements.txt                   # Daftar dependensi runtime & visualisasi
```

---

## 📊 Hasil Evaluasi Empiris & *Benchmark* Komparatif

Seluruh hasil pengujian direkam secara transparan di direktori [`results/`](https://github.com/radityobw/SIDIK/tree/main/results) dan divisualisasikan di [`figures/`](https://github.com/radityobw/SIDIK/tree/main/figures):

### 1. Evaluasi Deteksi *Hardcoded Secret* pada 25 Repositori GitHub Nyata (`186.876` LOC, `1.193` Berkas `.py`, `109` Kandidat)
> **Catatan Transparansi Korpus:** Ke-25 repositori publik memiliki `0` kebocoran kunci produksi aktif (`TP = 0`; seluruh `109` kandidat adalah kode pengujian/*fixture*/contoh dokumentasi). Oleh karena itu, evaluasi pada korpus ini mengukur ketahanan terhadap alarm palsu (*False Positive Rate* / FPR) dan kecepatan eksekusi.

| Perangkat Pemindai | Versi | *False Positive* (FP) | *True Negative* (TN) | *False Positive Rate* (FPR) | Waktu Pindai *Secret* | Kecepatan (*Throughput*) |
| :--- | :---: | :---: | :---: | :---: | :---: | :---: |
| **Bandit** | `v1.9.4` | 98 | 11 | 89,91% | 25,26 dtk | 7.398 LOC/dtk |
| *Baseline Regex* | Internal | 14 | 95 | 12,84% | 3,34 dtk | 55.950 LOC/dtk |
| **SIDIK (Usulan)** | **Terpadu** | **14** | **95** | **12,84% (-85,7% vs Bandit)** | **3,19 dtk** | **58.581 LOC/dtk** |
| **Gitleaks** | `v8.30.1` | **0** | **109** | **0,00%** | 10,41 dtk | 17.951 LOC/dtk |

* Pada **Pemindaian Terpadu (*Unified Pipeline*: *Secret* + SCA + `tracemalloc`)** lintas 25 repositori nyata, SIDIK menuntaskan pemeriksaan dalam **`4,64 detik`** (`~2,55 detik` jika dipindai sekaligus) dan mengidentifikasi **`302` kerentanan dependensi nyata** pada 45 berkas manifes proyek publik.

### 2. Evaluasi *Software Composition Analysis* (SCA v2) pada Rilis Paket PyPI (`N=200` Entri di `39` Manifes Uji)

| Perangkat SCA | Cakupan Format Manifes | TP | FP | TN | FN | *Precision* | *Recall* | *F1-Score* | Waktu Pindai |
| :--- | :--- | :-: | :-: | :-: | :-: | :---: | :---: | :---: | :---: |
| **`pip-audit`** (`v2.10.1`) | `requirements.txt` saja (`N=37`) | 0 | 0 | 20 | 17 | 0,0000 | 0,0000 | 0,0000 | 0,15 dtk |
| **Trivy** (`v0.76.1`) | Wajib *lockfile* (`N=200`) | 35 | 0 | 100 | 65 | 1,0000 | 0,3500 | 0,5185 | 132,00 dtk |
| **SIDIK (Usulan)** | **5 Format Lengkap (`N=200`)** | **100** | **0** | **100** | **0** | **1,0000** | **1,0000** | **1,0000** | **0,33 dtk** |

### 3. Studi Ablasi Komponen pada Dataset Uji Terkontrol *Secret* (`N=100` Berkas: `50` Positif, `50` Negatif)

| Konfigurasi Ablasi | *True Positive* (TP) | *False Positive* (FP) | *True Negative* (TN) | *False Negative* (FN) | *Precision* | *Recall* | *F1-Score* | MCC |
| :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| **Konfig A (*Regex* Saja)** | 45 | 10 | 40 | 5 | 0,8182 | 0,9000 | 0,8572 | 0,7035 |
| **Konfig B (*Regex* + Konteks)** | 45 | **0** | **50** | 5 | **1,0000** | 0,9000 | **0,9474** | **0,9045** |
| **Konfig C (*Regex* + Entropi)** | 45 | 10 | 40 | 5 | 0,8182 | 0,9000 | 0,8572 | 0,7035 |
| **Konfig D (SIDIK Penuh)** | 45 | **0** | **50** | 5 | **1,0000** | 0,9000 | **0,9474** | **0,9045** |

### 4. Profil Transparan Konsumsi Memori (RAM) & Waktu Eksekusi
* **Alokasi Memori Pemindaian Aktif (*Active Scanning Memory*):** Berkisar **`0,15 MB - 0,91 MB` per repositori** (rerata **`0,39 MB`** per repositori pada 25 proyek GitHub; **`0,13 - 0,21 MB`** pada uji *secret* `N=100`; serta **`1,58 MB`** untuk pemindaian gabungan 25 repositori sekaligus).
* **Inisialisasi Basis Data OSV Luring (*One-Time DB Index Load*):** Membutuhkan **`116,47 MB`** satu kali di awal (*singleton cache*) saat memuat indeks `29.208` rekaman advisori JSON ke memori.

---

## 🚀 Panduan Penggunaan Cepat (*Quick Start*)

### 1. Instalasi Global via PyPI (Pengguna Umum & CI/CD)
Pastikan Python `3.9+` telah terpasang, lalu pasang langsung dari PyPI:
```bash
# Pemindai CLI & Offline OSV SCA (ringan)
pip install sidik

# Atau lengkap dengan antarmuka Desktop GUI (Pillow + Matplotlib)
pip install "sidik[gui]"

# Atau terisolasi secara global memakai pipx / uv tool
pipx install "sidik[gui]"

# Opsional: aktifkan ekstensi Non-ANN ML di lingkungan yang sama
pip install sidik-ml
```

Untuk pengembangan lokal dari *source repository*:
```bash
python -m venv .venv
.\.venv\Scripts\Activate.ps1          # Windows PowerShell
# source .venv/bin/activate           # Linux / macOS

pip install -e ".[gui]"
```

> **Catatan Windows PowerShell:** Jika Anda masuk ke direktori `.venv\Scripts` tanpa mengaktifkan `.\Activate.ps1`, gunakan awalan `.\` saat menjalankan skrip konsol (misalnya `.\sidik -i`, `.\sidik --gui`, `.\sidik-ml -i`, atau `.\sidik-ml --gui`). Jika aktivasi dibatasi kebijakan eksekusi, jalankan langsung melalui `python -m sidik ...` atau `python -m sidik_ml ...`.

### *Structured Candidate Contract* (`SIDIK` -> `SIDIK-ML`)
Sejak `v1.1.0`, `SecurityScanner.extract_secret_candidates()` dan `SecretDetector.extract_candidates()` menyediakan objek berversi `SecretCandidate` (`schema_version = "1.0.0"`, `compute_stable_id()` berbasis SHA-256) tanpa menyimpan nilai rahasia mentah (`masked_value` + `value_sha256`).

### 2. Menjalankan *Desktop GUI* (Mode Visual)
```bash
sidik --gui                  # atau sidik-gui / python -m sidik --gui
python sidik.py --gui        # atau klik dua kali run_sidik.bat pada Windows
```
* Gunakan tombol **`🌐 English (EN)` / `🌐 Indonesia (ID)`** di kanan atas untuk mengganti bahasa secara instan.
* Gunakan 5 tombol **Presets** (`Uji Secrets (N=100)`, `Uji Dependensi v2`, `25 Repo Eksternal (Secret)`, `25 Repo Eksternal (Full)`, `Kode Sumber SIDIK`) untuk mendemonstrasikan hasil riset secara langsung.
* Buka tab **`Visualisasi & Hasil Riset`** untuk melihat grafik evaluasi RQ1 - RQ4 dan *Master Bundle*.

### 3. Menjalankan *Interactive CLI Menu* (Mode Terminal Interaktif)
```bash
sidik -i                     # setara dengan: sidik interactive / python -m sidik -i
python sidik.py -i           # atau klik dua kali run_sidik_cli.bat pada Windows
```

### 4. Menjalankan *One-Shot CLI* & Ekspor 7 Format Laporan
```bash
# Pemindaian standar di terminal (argumen posisional atau --target / -t)
sidik .
python -m sidik --target dataset/secrets/test --lang id
python -m sidik --target dataset/dependencies_v2/test --lang en

# Ekspor ke 7 format laporan (console, json, markdown, csv, html, sarif, github)
python -m sidik --target dataset/external/_repos --format html --output results/audit_report.html
python -m sidik --target dataset/external/_repos --format sarif --output results/sidik.sarif

# Pasang Git Pre-Commit Hook otomatis & ambang batas CI/CD
python -m sidik --install-hook
python -m sidik --target . --fail-on high

# Gunakan plugin ML opsional (jika sidik-ml terpasang di venv yang sama)
sidik --list-plugins
sidik --target . --enable-ml --ml-model path/ke/model.skops
sidik -i --enable-ml
```

### 5. Menjalankan *Unit Test* & Eksperimen *Benchmark*
```bash
# Jalankan seluruh unit & integration tests
python -m unittest discover tests -v

# Jalankan eksperimen & buat ulang seluruh grafik riset
python experiments/run_experiments.py
python experiments/ablation_study.py
python experiments/run_external_benchmarks.py
python experiments/generate_charts.py
```

### 6. Distribusi *Container* (`ghcr.io`) & Paket Rilis
```bash
# Jalankan lewat GitHub Container Registry (tanpa instalasi Python lokal)
docker run --rm -v "${PWD}:/workspace" ghcr.io/radityobw/sidik:latest --target /workspace --format console

# Atau jalankan langsung dari PyPI (`pip install "sidik[gui]"`) atau aset .whl pada GitHub Releases (releases/latest)
```

---

## 🗺️ Ekosistem Perangkat Lunak Publik (*Public Software Ecosystem*)

| Repositori | Peran Utama | Versi Terkini | Tautan |
| :--- | :--- | :---: | :--- |
| **SIDIK** | Mesin pemindai deterministik SAST & OSV SCA + host *plugin* UI | [![PyPI](https://img.shields.io/pypi/v/sidik?label=PyPI&color=0ea5e9)](https://pypi.org/project/sidik/) | [`github.com/radityobw/SIDIK`](https://github.com/radityobw/SIDIK) |
| **SIDIK-ML** | Perangkat lunak ekstensi *Explainable Non-ANN ML* & *plugin* | [![PyPI](https://img.shields.io/pypi/v/sidik-ml?label=PyPI&color=f59e0b)](https://pypi.org/project/sidik-ml/) | [`github.com/radityobw/SIDIK-ML`](https://github.com/radityobw/SIDIK-ML) |

> **Publikasi Ilmiah:** Artikel penelitian deterministik awal telah diterbitkan di [*Jurnal Media Akademik (JMA)*](https://jurnal.mediaakademik.com/index.php/jma/article/view/9068/6647).

---

# 🇬🇧 English

## 📌 Project Overview

**SIDIK** (*Secret Identification and Dependency Inspection Kit*) is a unified, lightweight Static Application Security Testing (SAST) and Software Composition Analysis (SCA) instrument for Python projects that operates **100% offline** with **zero data leakage**.

By combining **12 curated regular expression rules**, **Shannon entropy verification**, and **lexical context filtering** with an **offline Google OSV advisory database (`35,304` vulnerability records across `13,734` PyPI packages)** supporting major Python manifest and lockfile formats (`requirements*.txt`, `pyproject.toml`, `Pipfile`, `Pipfile.lock`, `poetry.lock`, `uv.lock`, and `setup.py`), SIDIK suppresses false alarms while eliminating network latency and internet dependencies in CI/CD pipelines and air-gapped environments.

---

## ✨ Key Features

1. **Three-Layer Secret Detection Engine:**
   - Covers 12 credential categories (`SEC001` - `SEC012`: AWS, Google Cloud, OpenAI, Stripe, GitHub Classic/Fine-Grained PAT, Slack, JWT, Password Assignments, Database URIs, Private Keys, and Generic Secrets).
   - Combines a fast line pre-check filter, Shannon entropy calculation, and lexical context analysis to suppress false positives from test fixtures, mock tokens, UUIDs, and Git SHA-1 hashes.
2. **Offline Multi-Manifest SCA Engine:**
   - Parses `requirements*.txt`, `pyproject.toml` (PEP 621, optional-dependencies, PEP 735 dependency-groups, & Poetry), `Pipfile`, `Pipfile.lock`, `poetry.lock`, `uv.lock`, and `setup.py` (static AST parsing without code execution).
   - Evaluates exact pins (`==`), semantic version ranges (`>=`, `~=`, `<`), and explicit OSV affected version lists against **`35,304` offline PyPI advisories** (including CVSS v3/v4/v2 and `MAL-*` malicious package alerts).
3. **Triple-Interface Ecosystem & 7 Report Formats:**
   - Operates via **One-Shot CLI** (`python -m sidik`, `--install-hook`, `--fail-on`, GitHub Action `action.yml`), **Interactive CLI Menu** (`python sidik.py --cli`), and **High-DPI Bilingual Desktop GUI** (`python sidik.py --gui`).
   - Exports findings to **ANSI Console**, **OASIS SARIF v2.1.0**, **GitHub Actions Annotations**, **Standalone HTML Dashboard**, **Markdown**, **JSON**, and **CSV**.
4. **Decoupled Plugin Architecture (`sidik.plugins`):**
   - Exposes standard `importlib.metadata.entry_points(group="sidik.plugins")` hooks and the leak-safe `SecretCandidate` contract so external extensions like [`SIDIK-ML`](https://github.com/radityobw/SIDIK-ML) enrich CLI, TUI, GUI, and reports without adding ML dependencies to `sidik`.

---

## 📊 Summary of Empirical Benchmarks

| Benchmark Suite | Dataset Scale | SIDIK Result | Industry / Baseline Comparison |
| :--- | :--- | :--- | :--- |
| **1. Real-World GitHub Secret Scan** | 25 Repos (`186,876` LOC, `1,193` files, `109` candidates) | **14 FP (12.84% FPR)** in **3.19s** (`58,581` LOC/s; `4.64s` unified scan with **302** real dependency CVEs) | **85.7% fewer FPs** than Bandit (`98 FP / 89.91%`, `25.26s`); **3.3x faster** than Gitleaks (`0 FP`, `10.41s`) |
| **2. Multi-Manifest PyPI SCA v2** | `N=200` balanced entries across `39` test manifests (5 formats) | **100/100 TP (Precision 1.00, Recall 1.00, F1 1.00)** in **0.33s** | Outperforms Trivy (`35/100 TP`, `F1 0.5185`, `132.00s`) and `pip-audit` (`0/17 TP` on `N=37` unpinned `requirements.txt`) |
| **3. Controlled Secret Ablation** | `N=100` Python files (`50` positive, `50` negative traps) | **0 FP, 45 TP (Precision 1.00, Recall 0.90, F1 0.9474, MCC 0.9045)** | Context filter eliminates all **10 FPs** produced by regex-only baseline (`F1 0.8572`) |
| **4. Memory & Resource Profile** | `tracemalloc` across all benchmarks | **0.15 - 0.91 MB** active scan RAM/repo (avg **0.39 MB**; **1.58 MB** combined 25 repos) | Transparently reports **116.47 MB** one-time initialization for loading the `29,208`-record OSV JSON index |

---

## 🚀 Quick Start

```bash
# 1. Global installation from PyPI (recommended for end users & CI/CD)
pip install sidik                 # Core CLI & Offline OSV SCA
pip install "sidik[gui]"          # Include Desktop GUI & chart visualization
# pipx install "sidik[gui]"       # Isolated global CLI installation

# (Optional) From a local source checkout:
# python -m venv .venv && pip install -e ".[gui]"

# 2. Launch Desktop GUI, Interactive TUI, or One-Shot CLI
sidik --gui                    # or sidik-gui / python -m sidik --gui
sidik -i --lang en             # or sidik interactive / python -m sidik -i
sidik .                        # or sidik --target . / sidik file1.py file2.py
sidik --target . --format html --output audit_report.html --lang en
sidik --update-db              # Refresh OSV PyPI advisories into user cache

# 3. Baseline, exclusions, and optional SIDIK-ML plugin
sidik . --write-baseline .sidik-baseline.json
sidik . --baseline .sidik-baseline.json --fail-on high
sidik --list-plugins
sidik --target . --enable-ml --ml-model path/to/model.skops

# 4. Run full regression suite
python -m unittest discover tests -v

# 5. Run via GitHub Container Registry (ghcr.io)
docker run --rm -v "${PWD}:/workspace" ghcr.io/radityobw/sidik:latest --target /workspace --format console
```

> **Windows PowerShell Note:** Inside `.venv\Scripts` without prior `.\Activate.ps1`, prefix commands with `.\` (e.g., `.\sidik -i`, `.\sidik --gui`, `.\sidik-ml -i`) or invoke via `python -m sidik ...` / `python -m sidik_ml ...`.

---

## 🗺️ Public Software Ecosystem

| Repository | Primary Role | Latest Version | Link |
| :--- | :--- | :---: | :--- |
| **SIDIK** | Deterministic SAST & OSV SCA core + UI plugin host | [![PyPI](https://img.shields.io/pypi/v/sidik?label=PyPI&color=0ea5e9)](https://pypi.org/project/sidik/) | [`github.com/radityobw/SIDIK`](https://github.com/radityobw/SIDIK) |
| **SIDIK-ML** | Explainable Non-ANN ML extension & `sidik.plugins` adapter | [![PyPI](https://img.shields.io/pypi/v/sidik-ml?label=PyPI&color=f59e0b)](https://pypi.org/project/sidik-ml/) | [`github.com/radityobw/SIDIK-ML`](https://github.com/radityobw/SIDIK-ML) |

> **Scientific Publication:** The foundational deterministic study is published in [*Jurnal Media Akademik (JMA)*](https://jurnal.mediaakademik.com/index.php/jma/article/view/9068/6647).

## 📄 License

Distributed under the **MIT License**. See [LICENSE](https://github.com/radityobw/SIDIK/blob/main/LICENSE).
