Metadata-Version: 2.4
Name: vishap-analyzer
Version: 7.3.15
Summary: Vishap - multi-material IT analyst (code, config, spec, logs, data). 6-stage LLM pipeline with SAST/SCA, SARIF 2.1.0, OWASP Top 10, audit trail (SHA-256), provenance, exploitability.
Author-email: "David (dvddv9)" <hndav9@yahoo.com>
License-Expression: AGPL-3.0-or-later
Keywords: vishap,vishap-analyzer,security,sast,sca,sarif,owasp,llm,multi-material,code-review,audit-trail,compliance,pii,deepseek
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.32.0
Requires-Dist: python-dotenv>=1.0.0
Requires-Dist: fastapi>=0.115.0
Requires-Dist: uvicorn[standard]>=0.30.0
Requires-Dist: pydantic>=2.9.0
Requires-Dist: pydantic-settings>=2.5.0
Requires-Dist: radon>=6.0.0
Requires-Dist: tenacity>=9.2.0
Requires-Dist: httpx>=0.27.0
Requires-Dist: cyclonedx-bom>=7.0.0
Requires-Dist: sqlalchemy[asyncio]>=2.0.30
Requires-Dist: asyncpg>=0.29.0
Requires-Dist: alembic>=1.13.0
Requires-Dist: structlog>=24.0.0
Requires-Dist: prometheus-client>=0.20.0
Requires-Dist: cryptography>=42.0.0
Requires-Dist: zstandard>=0.22.0
Requires-Dist: celery[redis]>=5.3.0
Requires-Dist: redis>=5.0.0
Requires-Dist: PyJWT>=2.9.0
Requires-Dist: stripe>=10.0.0
Requires-Dist: opentelemetry-api>=1.25.0
Requires-Dist: opentelemetry-sdk>=1.25.0
Requires-Dist: opentelemetry-instrumentation-fastapi>=0.46b0
Requires-Dist: opentelemetry-instrumentation-celery>=0.46b0
Requires-Dist: opentelemetry-exporter-otlp>=1.25.0
Requires-Dist: pyyaml>=6.0.0
Requires-Dist: tree-sitter>=0.23.0
Requires-Dist: tree-sitter-javascript>=0.23.0
Requires-Dist: tree-sitter-typescript>=0.23.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
Requires-Dist: black>=24.0.0; extra == "dev"
Dynamic: license-file

# 🐉 Vishap

![Vishap Dashboard](docs/screenshots/dashboard.png)

[![PyPI](https://img.shields.io/pypi/v/vishap-analyzer.svg)](https://pypi.org/project/vishap-analyzer/)
[![CI](https://github.com/dvddv9/vishap/actions/workflows/ci.yml/badge.svg)](https://github.com/dvddv9/vishap/actions/workflows/ci.yml)
[![Docs](https://github.com/dvddv9/vishap/actions/workflows/docs.yml/badge.svg)](https://dvddv9.github.io/vishap/)
[![Version](https://img.shields.io/badge/version-7.3.15-blue)](https://github.com/dvddv9/vishap/releases/tag/v7.3.15)
[![License: AGPL v3](https://img.shields.io/badge/License-AGPL_v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)

> 🐉 **Vishap** — 6-stage LLM pipeline for analyzing engineering materials (code, spec, logs, config, data).

**Vishap** takes a file as input → returns a structured Markdown report with risks, STRIDE threat model, refactoring options and **audit trail** with PII detection and compliance flags.

## 🌐 Live demo

| Service | URL | Stack |
|---------|-----|-------|
| **Frontend** | [vishap-ui.onrender.com](https://vishap-ui.onrender.com) | Next.js 16 · Node 24 |
| **Backend** | [vishap-zwpx.onrender.com](https://vishap-zwpx.onrender.com) | FastAPI · Docker |
| **API docs** | [/docs](https://vishap-zwpx.onrender.com/docs) | Swagger UI |

> ⚠️ Free tier: first request may take 30–50 s (cold start).

## 🎉 What's new in v7.3.15

- **DSH endpoint support** — `dsh-model-endpoint` plugin exposes `http://127.0.0.1:8787/v1` as an OpenAI-compatible API. Set `VISHAP_LLM_PROVIDER=custom`, `CUSTOM_LLM_URL=http://127.0.0.1:8787/v1`, `CUSTOM_LLM_KEY=<dsh-key>`, `CUSTOM_LLM_MODEL=auto`.
- **reasoning_content fallback** — `custom_client.py` falls back to `message.reasoning_content` when `content` is empty (DeepSeek flash / V4).
- **Truncated JSON recovery** — `parse_json_response` recovers JSON truncated at `max_tokens` (closes unclosed `{` / `[`, cuts at last valid object).
- **Version sync** — single source of truth in `src/version.py`; CI checks `pyproject.toml` / `package.json` / `README.md`.

### Previous: v7.3.1

- **JavaScript / TypeScript support**: `detect_language` (.js/.jsx/.mjs/.cjs/.ts/.tsx), `js_parser.scan_js_patterns` (XSS, SQLi, RCE, path traversal, command injection), LLM hints in `build_prompt`.

### Audit evidence (#1–#8)
- **#1 `context_thread`** — wires metrics / cwe / evidence → activates #3 / #5 / #6
- **#2 `compute_critique_verdict`** — `NEEDS_VERIFICATION` / `REQUIRES_REVIEW` / `SAFE`; critical `risk_nodes` / `security` → `REQUIRES_REVIEW`
- **#3 `fidelity_index`** — 0.0–1.0; bias passed when in `[0.3, 0.95]`
- **#4 `negative_evidence`** — checked-but-not-found CWEs with reason
- **#5 `reproducer`** — runnable `python -c` + verified via `sys.executable`
- **#6 `bias_check`** — critical_ratio, FI-range, RCE-without-critical
- **#7 `CWE_MAPPING`** — 15 keys
- **#8 `report_date` / `valid_until`** — ISO + 90 days

### UI (`ui-next/`)
- **LLMSettings**: provider = `custom` (OpenAI-compatible / DSH endpoint)
- **Report v7.2 block**: Fidelity / Bias check / Reproducer / Negative evidence / Report date / valid_until
- **CORS fix**: `app.add_middleware(CORSMiddleware, ...)` — Settings form works in browser
- **mojibake fix**: em-dash `—`, ellipsis `…`, emoji 🐉

### Backend
- **`async_chat`** — respects `VISHAP_LLM_PROVIDER=custom`
- **Docker**: bind `0.0.0.0` — `-p 5001:5001` smoke-test passes
- **CI**: ruff F401 cleanup; `services.postgres` fix
- **Version sync**: 7.2.2 (`pyproject.toml`, `version.py`, `package.json`, `main.py`, `layout.tsx`)

## 🔌 DSH (DeepSeek Harness) — via endpoint (**optional**)

> **Default:** DeepSeek API (`https://api.deepseek.com/v1`). Use DSH endpoint **only** if you want local inference (no API key). (**optional**)

> **Default:** DeepSeek API (`https://api.deepseek.com/v1`). Use DSH endpoint **only** if you want local inference (no API key).

DSH has **no inbound HTTP API**. To use DSH with Vishap, you need the [`dsh-model-endpoint`](https://github.com/Xxsttb/dsh-model-endpoint) plugin, which exposes DSH as an OpenAI-compatible endpoint (`http://127.0.0.1:8787/v1`).

### 1. Install the plugin in DSH

```bash
dsh plugin --profile desktop add github:Xxsttb/dsh-model-endpoint
```

> ⚠️ The plugin is **not** published on npm as `dsh-model-endpoint` — install it from GitHub (or from a local folder/tarball, see plugin README).

### 2. Enable the endpoint in DSH

- DSH → **Settings → Model endpoint**
- Toggle **Run the endpoint** (on)
- **Generate** an API key (copy it — you will need it in Vishap)
- Optional: **Lend this profile's tools** (on) — gives Vishap access to DSH tools (bash, files, search). This is the "smart mode".
- **Save**

The endpoint will listen on `http://127.0.0.1:8787/v1`.

### 3. Configure Vishap

In `.env`:

```
VISHAP_LLM_PROVIDER=custom
CUSTOM_LLM_URL=http://127.0.0.1:8787/v1
CUSTOM_LLM_KEY=<dsh-key>
CUSTOM_LLM_MODEL=auto
```

> **`CUSTOM_LLM_MODEL=auto`** means: *"use the model currently selected in DSH"*. The plugin ignores the literal `auto` value and routes to whatever model is picked in the DSH chat / Settings → Models. It is **not** auto-detection by Vishap and **not** a model name.

### Verify

```powershell
Test-NetConnection 127.0.0.1 -Port 8787 -InformationLevel Quiet
# True = endpoint is listening
```

And a quick smoke test:

```powershell
cd C:\path\to\vishap
.\venv\Scripts\python.exe -c "from src.llm.client import chat; print(chat('You are a helpful assistant.', 'Say hello in 5 words.'))"
```

Expected: `mode: custom`, text like `Hello there, how are you?`.

---

## 🛠️ Features

- **6-stage pipeline:** Ingestion → Taint Analysis → Dataflow → Risk Assessment → Verdict → Report.
- **Multi-language:** Python, Java, C, **JavaScript / TypeScript** (AST + taint patterns).
- **Multi-provider LLM:** DeepSeek (custom), any OpenAI-compatible endpoint (Groq, OpenAI, Mistral, OpenRouter, Together), or a local DSH endpoint via the `dsh-model-endpoint` plugin (`http://127.0.0.1:8787/v1`). Endpoint-only since v7.3.5 (legacy `harness` removed).
- **Async API:** FastAPI + Celery workers (optional in-process fallback).
- **Security:** HMAC-SHA256 for API keys (with pepper), Fernet for secrets.
- **Observability:** Structlog (JSON), Prometheus `/metrics`, OpenTelemetry traces.
- **CI/CD:** GitHub Actions (tests, lint, docs deploy).
- **Desktop:** Tauri app for Windows.

## 🎯 When to use Vishap (and when not)

**Vishap is not a replacement for SonarQube or Snyk.** It is a **different tool** for **different material**.

| Tool | What it does | When to use |
|---|---|---|
| **SonarQube** | 40+ languages, Quality Gates, deterministic SAST, IDE integration | **Code review** — you have source code, you want fast, deterministic rules. |
| **Snyk** | Dependencies, containers, IaC, SBOM | **Supply chain** — you want CVE in deps / images / Terraform. |
| **Vishap** | 6-stage LLM pipeline, multi-material (code / spec / logs / config / data), audit trail with SHA-256, FI, runbook | **Spec / logs / config as material** — when you need an **audit trail** and **LLM reasoning**, not just rules. |

### Choose Vishap when

- You need to analyze **specs, logs, configs, or data** (not just code).
- You need an **audit trail** (SHA-256 provenance, `valid_until`, PII detection).
- You need a **runbook** (LLM-generated fix + verify) in the report.
- You want **FI (fidelity index)** — a measure of how honest the report is.
- You want **opt-in self-adversarial loops** (red team / translator / tester / fixer).

### Don't use Vishap when

- You just need **fast, deterministic SAST** on source code → **SonarQube**.
- You need **CVE in dependencies / containers / IaC** → **Snyk**.
- You need **IDE integration** (real-time linting) → **SonarLint** / **Snyk IDE**.

> **Bottom line:** Vishap **complements** SonarQube / Snyk. Run SonarQube for code, Snyk for deps, Vishap for **spec / logs / config + audit trail + runbook**.

## 📦 Quick Start

### Python (pip)

```bash
pip install vishap-analyzer==7.3.15
```

```python
from vishap_analyzer import analyze  # or: from src.pipeline.orchestrator import run_pipeline
result = analyze(material="def get_user(name): ...", filename="sqli.py")
print(result["audit"]["critique_verdict"])
```

> **Version pin:** `==7.3.15` — the version documented here. See [PyPI](https://pypi.org/project/vishap-analyzer/) for the latest.

### Backend (Docker)
```bash
docker build -t vishap .
docker run --rm -p 5001:5001 \
  -e VISHAP_DEV=true \
  -e VISHAP_LLM_PROVIDER=custom \
  -e CUSTOM_LLM_URL=https://api.deepseek.com/v1 \
  -e CUSTOM_LLM_MODEL=deepseek-chat \
  -e CUSTOM_LLM_KEY=sk-... \
  vishap

## 🧠 Claude Desktop extension

Install **Vishap Security Analysis** in Claude Desktop (Windows/macOS):

1. Download [`claude-plugin/claude-plugin.mcpb`](claude-plugin/claude-plugin.mcpb).
2. Claude → **Settings** → **Extensions** → **Install extension** → select `.mcpb`.
3. **Configure**:
   - `LLM Base URL` — `https://api.deepseek.com/v1` (or OpenAI / Groq / Ollama / any OpenAI-compatible)
   - `LLM API Key` — your key (empty for local Ollama)
   - `LLM Model` — `deepseek-chat` / `gpt-4o-mini` / `llama3.1` / ...
4. **Enable** → ask Claude: *"Analyze this code for SQL injection: ..."*

Source: [`claude-plugin/`](claude-plugin/) · `.mcpb` built with `mcpb pack`.

