Metadata-Version: 2.4
Name: integrity-web-gate
Version: 0.2.0
Summary: The Safe 3-Tier Web Driver & Execution Firewall MCP for AI Agents, DevOps & Legacy Web UIs
Author: Integrity Web Gate Contributors
License: MIT
Project-URL: Homepage, https://integrityharness.dev
Project-URL: Repository, https://github.com/BlackBadHope/integrity-web-gate
Project-URL: Issues, https://github.com/BlackBadHope/integrity-web-gate/issues
Keywords: mcp,ai-agents,web-driver,ssrf-firewall,playwright,http,devops,execution-firewall,declarative-recipes
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: browser
Requires-Dist: playwright>=1.45; extra == "browser"
Provides-Extra: h2
Requires-Dist: h2>=4.1; extra == "h2"
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Dynamic: license-file

<p align="center">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="docs/assets/hero-dark.svg">
    <source media="(prefers-color-scheme: light)" srcset="docs/assets/hero-light.svg">
    <img src="docs/assets/hero-light.svg" alt="integrity-web-gate — Safe 3-Tier Web Driver & Execution Firewall MCP" width="100%">
  </picture>
</p>

<p align="center">
  <img src="docs/assets/badge-python.svg" alt="Python: 3.11+ stdlib">
  <img src="docs/assets/badge-deps.svg" alt="Dependencies: 0 mandatory">
  <img src="docs/assets/badge-mcp.svg" alt="MCP: 9 stdio tools">
  <img src="docs/assets/badge-security.svg" alt="Gates: 4 fail-closed">
  <img src="docs/assets/badge-license.svg" alt="License: MIT">
</p>

<p align="center">
  <a href="#3-line-quickstart">Quickstart</a> ·
  <a href="#real-local-benchmarks">Benchmarks</a> ·
  <a href="#3-tier-architecture">Architecture</a> ·
  <a href="#security-model">Security Model</a> ·
  <a href="#25-built-in-declarative-recipes--webdrv-learn">Recipes</a> ·
  <a href="#honest-comparison">Comparison</a> ·
  <a href="#license">License</a>
</p>

---

# Integrity Web Gate

**The Safe 3-Tier Web Driver & Execution Firewall MCP for AI Agents, DevOps & Legacy Web UIs.**

Give AI agents (Claude Desktop, Cursor, Antigravity, Codex, custom Python pipelines) fast, structured, SSRF-hardened web and API access — with zero mandatory third-party dependencies, automatic Playwright escalation only when JavaScript requires it, and a transactional `Plan -> Preimage -> GO -> Verify -> Rollback` execution firewall for state-changing writes.

---

## 3-Line Quickstart

> **Install source notice (PyPI verification):** `integrity-web-gate` is not yet published on PyPI — install directly from GitHub below until official Trusted Publishing (OIDC) is live. Once published, always verify the publisher is `BlackBadHope` before running `pip install` to avoid dependency confusion / package squatting.

```bash
pip install git+https://github.com/BlackBadHope/integrity-web-gate.git  # 100% Python 3.11+ stdlib core (zero mandatory deps)
integrity-web-gate doctor                                               # Verify Tier-1 HTTP, 25 recipes, Tier-3 Playwright & MCP
python examples/quickstart_60s.py                                       # Self-contained local 60-second end-to-end demo
```

Optional extras:

```bash
pip install "integrity-web-gate[browser] @ git+https://github.com/BlackBadHope/integrity-web-gate.git"  # Tier-3 Playwright Chromium escalation
pip install "integrity-web-gate[h2] @ git+https://github.com/BlackBadHope/integrity-web-gate.git"       # Optional HTTP/2 framing support
pip install "integrity-web-gate[dev] @ git+https://github.com/BlackBadHope/integrity-web-gate.git"      # pytest development suite
```

### MCP Client Configuration (Claude Desktop / Cursor / Antigravity)

Add `integrity-web-gate-mcp` to your MCP server config (`claude_desktop_config.json`, `.cursor/mcp.json`, or Antigravity MCP config):

```json
{
  "mcpServers": {
    "integrity-web-gate": {
      "command": "integrity-web-gate-mcp",
      "args": []
    }
  }
}
```

Exposes 9 hardened JSON-RPC 2.0 stdio tools: `web_probe`, `web_fetch`, `web_extract`, `web_plan_write`, `web_apply_write`, `web_record_cassette`, `web_replay_cassette`, `web_learn_recipe`, and `web_fleet_scan`.

---

## Real Local Benchmarks

<p align="center">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="docs/assets/demo-dark.svg">
    <source media="(prefers-color-scheme: light)" srcset="docs/assets/demo-light.svg">
    <img src="docs/assets/demo-light.svg" alt="integrity-web-gate 60-Second Quickstart & Tier-3 to Tier-1 Cookie Handoff Benchmark" width="100%">
  </picture>
</p>

Reproducible, zero-mock local benchmark (`python benchmarks/bench_http_vs_playwright.py` on Python 3.12, Windows, `127.0.0.1:0` ephemeral server; raw data in [`benchmarks/latest_results.json`](benchmarks/latest_results.json)):

| Workload | Latency / Throughput | Payload Size | Est. LLM Tokens (`chars/4`) | Notes |
| :--- | :---: | :---: | :---: | :--- |
| **Tier-1 Sync HTTP + Markdown Extract** (`SwissArmyDriver`) | **7.37 ms avg** (p50 `5.79 ms`, p95 `23.05 ms`) | 2,737 B | **684 tokens** | **81.9% fewer tokens** than raw HTML |
| **Tier-1 Sync HTTP JSON API** (`UniversalTransport`) | **1.04 ms** | 104 B | **26 tokens** | Keep-Alive stdlib socket engine |
| **Tier-1 Async Fleet** (`AsyncFleetRunner`, 200 reqs @ 40 conc.) | **127.61 ms total (`1,567.3 req/s`)** | 200/200 OK | — | p50 `31.0 ms`, p95 `32.0 ms`, 0 failures |
| **Tier-3 Playwright Chromium** (Cold launch + load) | 566.95 ms | 15,100 B | 3,775 tokens | Full headless Chromium DOM |
| **Tier-3 Playwright Chromium** (Warm reload avg) | 24.88 ms (p50 `22.54 ms`) | 15,100 B | 3,775 tokens | **3.4x slower** than Tier-1 warm |
| **Tier-3 Login -> `handoff_to_http()` -> Tier-1 `/api/me`** | **10.70 ms** (after `325.81 ms` SPA login) | 1 cookie transferred | — | Browser auth -> fast HTTP session |

All 4 inline security gates verified during benchmark execution:
- `169.254.169.254` cloud metadata SSRF: **BLOCKED** (`SSRFBlockedError`)
- `Authorization` & `Set-Cookie` headers: **SCRUBBED** (`SecretScrubber`)
- `apply_write` without Owner GO token: **REFUSED** (`GoRequiredError`)
- Cloudflare Turnstile / CAPTCHA page: **FAIL-CLOSED** (`ChallengeBlockedError`)

---

## 3-Tier Architecture

<picture>
  <source media="(prefers-color-scheme: dark)" srcset="docs/architecture-dark.svg">
  <source media="(prefers-color-scheme: light)" srcset="docs/architecture-light.svg">
  <img alt="integrity-web-gate 3-Tier Architecture" src="docs/architecture-light.svg" width="100%">
</picture>

1. **Tier 1 — Stdlib HTTP/TLS & Async Fleet**: Pure Python 3.11+ socket/TLS transport (`UniversalTransport`) and `asyncio` concurrent runner (`AsyncFleetRunner`) with Keep-Alive pooling, HTTP/0.9 legacy fallback, RSA/Digest/CSRF/Form auth strategies, and offline scrubbed cassette record/replay.
2. **Tier 2 — Declarative Recipe Engine & Auto-Learner**: 25 validated JSON recipes (strictly zero `eval`/`exec`/`import`) plus `RecipeLearner` (`webdrv learn`) to auto-generate declarative recipes from live endpoints.
3. **Tier 3 — Browser Escalation & Cookie Handoff**: Optional Playwright Chromium adapter (`BrowserEscalationAdapter`) for JS-heavy SPAs with bidirectional session transfer (`handoff_to_http()` / `escalate_from_http()`) so agents authenticate once in Chromium and drop straight back to Tier-1 HTTP speed.
4. **Compliant Human-Handoff**: When a target presents MFA, SSO, or anti-bot challenges, `HumanHandoffCoordinator` pauses fail-closed and opens a local headed session for a human operator to complete sign-in — never attempting CAPTCHA bypass.

---

## Security Model

Hardened across 33 adversarial Red Team findings:

- **DNS-Once IP Pinning & SSRF Firewall**: Resolves DNS once, validates all IPs against loopback/RFC1918/link-local/cloud-metadata (`169.254.169.254`, IPv4-mapped IPv6 `::ffff:127.0.0.1`, NAT64, 6to4, Teredo), and pins the validated socket IP to prevent DNS rebinding and redirect-to-internal attacks.
- **Keep-Alive Anti-Smuggling**: Strict `Content-Length` / `Transfer-Encoding` validation, header byte caps, response size caps, and automatic connection reset on malformed framing.
- **SecretScrubber**: Automatically redacts `Authorization`, `Cookie`, `Set-Cookie`, Bearer/JWT tokens, passwords, and API keys from logs, MCP responses, telemetry, and recorded cassettes.
- **Fail-Closed CAPTCHA & Anti-Bot Policy**: Detects Cloudflare Turnstile, reCAPTCHA, hCaptcha, and login lockouts (`LockoutBreaker`) and aborts with exit code `6` (`ChallengeBlockedError`) rather than brute-forcing or bypassing.
- **Transactional Write Firewall (`Plan -> Preimage -> GO -> Verify -> Rollback`)**: Every mutating write captures a live SHA-256 preimage, checks drift under a per-target `DeviceLock`, enforces an explicit `owner_go` approval token (`GoVerifier`), verifies post-write state, and writes an executable `rollback_plan.json`.

---

## 25 Built-In Declarative Recipes + `webdrv learn`

Shipped inside the package (`integrity-web-gate recipes`):

- **APIs & Web Standards**: `generic_json_api`, `generic_form_csrf`, `graphql_endpoint`, `openapi_swagger`, `html_article_docs`, `html_data_table`, `rss_atom_feed`, `sitemap_xml`, `statuspage_health`, `github_public_repo`
- **DevOps & Cloud Control Planes**: `prometheus_metrics`, `grafana_api`, `traefik_dashboard`, `portainer_api`, `proxmox_ve`, `jenkins_web`, `wordpress_admin`
- **Network & Legacy Embedded Web UIs**: `mikrotik_webfig`, `tplink_smart_switch`, `zyxel_web_switch`, `bdcom_web_olt`, `hikvision_isapi`, `des1210_iss`, `des1228_classic`, `des3028_rompager`

Generate a custom recipe for any internal panel in one command:

```bash
webdrv learn http://127.0.0.1:8080 --name my_panel --out my_panel.json --allow-loopback
```

---

## Honest Comparison

| Capability | Integrity Web Gate | Playwright MCP | `httpx` / `requests` | Netmiko | Firecrawl |
| :--- | :---: | :---: | :---: | :---: | :---: |
| Mandatory dependencies | **0 (stdlib)** | Node + Chromium | 4–8 packages | Paramiko/TextFSM | Cloud API / Docker |
| SSRF / DNS-rebinding firewall | **Built-in** | Manual | None | N/A | Managed SaaS |
| Transactional write `Plan -> GO -> Rollback` | **Built-in** | None | None | Manual | Read-only |
| Token-efficient Markdown/JSON extraction | **81.9% smaller** | Raw DOM/a11y | Raw HTML | CLI text | Markdown |
| Tier-1 -> Tier-3 Cookie Handoff | **Built-in** | Browser-only | HTTP-only | SSH-only | Managed |
| Legacy embedded HTTP/0.9 & switch Web UIs | **Built-in** | Fragile | Breaks on HTTP/0.9 | SSH/Telnet | No |
| Native stdio MCP server | **Built-in (9 tools)** | Built-in | No | No | Separate MCP |

---

## License & Disclaimer

MIT License — see [`LICENSE`](LICENSE). Security policy and responsible disclosure: [`SECURITY.md`](SECURITY.md).

> **Independent Open-Source Project:** `integrity-web-gate` is an independent open-source project maintained by BlackBadHope and is not affiliated with, endorsed by, or sponsored by Anthropic, OpenAI, Cursor, Google, Cloudflare, or any hardware/software vendor mentioned in built-in recipes. Use only against targets you own or have explicit authorization to access, and respect `robots.txt` and site terms of service.
