@integsec/agentic-pentest-proxy 0.3.4 → 0.3.5

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 (37) hide show
  1. package/README.md +2 -0
  2. package/cloudflare/wrangler.jsonc +1 -1
  3. package/dist/bin/integsec-agentic-pentest-bridge.js +2 -2
  4. package/dist/src/config.js +1 -1
  5. package/dist/src/gateway/admin.html +3 -3
  6. package/dist/src/gateway/docs-home.html +20 -0
  7. package/dist/src/gateway/docs.d.ts +3 -0
  8. package/dist/src/gateway/docs.d.ts.map +1 -0
  9. package/dist/src/gateway/docs.html +12 -0
  10. package/dist/src/gateway/docs.js +94 -0
  11. package/dist/src/gateway/docs.js.map +1 -0
  12. package/dist/src/gateway/runtime.js +2 -2
  13. package/dist/src/gateway/server.d.ts.map +1 -1
  14. package/dist/src/gateway/server.js +20 -0
  15. package/dist/src/gateway/server.js.map +1 -1
  16. package/dist/src/gateway/state.d.ts +1 -1
  17. package/dist/src/index.d.ts +1 -1
  18. package/dist/src/index.js +1 -1
  19. package/docs/configuration.md +70 -0
  20. package/docs/development.md +17 -0
  21. package/docs/images/tui-in-scope.png +0 -0
  22. package/docs/images/tui-in-scope.svg +24 -0
  23. package/docs/images/tui-out-of-scope.png +0 -0
  24. package/docs/images/tui-out-of-scope.svg +25 -0
  25. package/docs/images/tui-policy-blocks.png +0 -0
  26. package/docs/images/tui-policy-blocks.svg +24 -0
  27. package/docs/integrations.md +74 -0
  28. package/docs/managed-gateway.md +2 -0
  29. package/docs/release-readiness-0.2.6.md +27 -0
  30. package/docs/security.md +33 -0
  31. package/docs/superpowers/plans/2026-03-26-mcp-scope-proxy.md +3051 -0
  32. package/docs/superpowers/plans/2026-03-28-tui-monitor.md +863 -0
  33. package/docs/superpowers/plans/2026-03-29-manifest-builder.md +3429 -0
  34. package/docs/superpowers/specs/2026-03-28-tui-monitor-design.md +138 -0
  35. package/docs/superpowers/specs/2026-03-29-manifest-builder-design.md +248 -0
  36. package/docs/tui.md +25 -0
  37. package/package.json +4 -2
@@ -0,0 +1,138 @@
1
+ # TUI Monitor — Design Spec
2
+
3
+ **Date:** 2026-03-28
4
+ **Status:** Approved
5
+
6
+ ## Overview
7
+
8
+ A standalone terminal dashboard that monitors the IntegSec Agentic Pentest MCP Proxy's audit log in real time. Built with Ink (React for terminals). Runs as a separate command alongside the proxy — does not interfere with the proxy's stdio pipeline.
9
+
10
+ ## How It Runs
11
+
12
+ ```bash
13
+ # Default — watches AUDIT_LOG_PATH or ./audit/
14
+ integsec-agentic-pentest-tui
15
+
16
+ # Explicit path
17
+ integsec-agentic-pentest-tui --audit-path ./audit
18
+
19
+ # Filter to one engagement
20
+ integsec-agentic-pentest-tui --engagement ENG-2026-TEST-001
21
+ ```
22
+
23
+ Registered as a separate bin entry in package.json: `"integsec-agentic-pentest-tui"`.
24
+ Entry file: `bin/integsec-agentic-pentest-tui.tsx`.
25
+
26
+ ## Screen Layout
27
+
28
+ ```
29
+ ┌─ ENGAGEMENT ──────────────────────────────────────────────┐
30
+ │ ENG-2026-TEST-001 | IntegSec Internal | security@integsec │
31
+ │ Window: 2026-03-27 → 2026-04-27 | ██████░░ 12d left │
32
+ └───────────────────────────────────────────────────────────┘
33
+ ┌─ STATS ───────────────────────────────────────────────────┐
34
+ │ ✓ Allowed: 42 ✗ Blocked: 7 Total: 49 │
35
+ │ Top targets: integsec.com (18) turbopentest.com (14) │
36
+ │ Top tools: nmap_scan (12) http_request (9) nuclei (8) │
37
+ └───────────────────────────────────────────────────────────┘
38
+ ┌─ LIVE FEED ───────────────────────────────────────────────┐
39
+ │ 14:32:01 ✓ ALLOWED nmap_scan → 10.10.10.5 (2ms) │
40
+ │ 14:32:03 ✗ BLOCKED curl → evil.com [NOT_IN_SCOPE] (1ms) │
41
+ │ 14:32:05 ✓ ALLOWED nuclei → app.integsec.com (4ms) │
42
+ │ 14:32:06 ✓ ALLOWED http_request → turbopentest.com (1ms) │
43
+ │ ...scrolls, most recent at bottom... │
44
+ └───────────────────────────────────────────────────────────┘
45
+ ```
46
+
47
+ ### Regions
48
+
49
+ 1. **Engagement Header** — static info derived from the first audit entry's metadata fields (engagement_id, client, operator, engagement window). Shows a progress bar for time remaining in the window.
50
+
51
+ 2. **Stats Panel** — running counters derived from all entries: allowed count, blocked count, total. Top 3 targets by frequency. Top 3 tools by frequency. Updated on each new entry.
52
+
53
+ 3. **Live Feed** — scrolling list of decision rows. Takes up remaining terminal height. Most recent at bottom, auto-scrolls. Color-coded:
54
+ - Green: ALLOWED
55
+ - Red: BLOCKED_*
56
+ - Dim gray: ALLOWED_NO_TARGET
57
+
58
+ ### Decision Row Format
59
+
60
+ ```
61
+ HH:MM:SS ✓ ALLOWED tool_name → target (Nms)
62
+ HH:MM:SS ✗ BLOCKED tool_name → target [REASON] (Nms)
63
+ ```
64
+
65
+ ## Architecture
66
+
67
+ ### Ink Components
68
+
69
+ | Component | Responsibility |
70
+ |-----------|---------------|
71
+ | `<App>` | Root. Manages entries state array, runs file watcher, derives stats. |
72
+ | `<EngagementHeader>` | Renders engagement info and time window progress bar. |
73
+ | `<StatsPanel>` | Derives and displays counts, top targets, top tools from entries. |
74
+ | `<LiveFeed>` | Scrolling list of DecisionRow components, auto-scrolls to bottom. |
75
+ | `<DecisionRow>` | Single decision line: timestamp, icon, decision, tool, target, duration. |
76
+
77
+ ### File Watcher
78
+
79
+ - Uses `fs.watch()` on the audit directory to detect file changes.
80
+ - Tracks byte offset per file to read only new lines (avoids re-reading).
81
+ - Parses each new line as an `AuditEntry` JSON object.
82
+ - Appends parsed entries to the React state array, triggering re-render.
83
+ - On startup, reads all existing entries from `.jsonl` files to populate historical data.
84
+
85
+ ### Entry Point (`bin/integsec-agentic-pentest-tui.tsx`)
86
+
87
+ - Parses CLI args: `--audit-path` (default: `AUDIT_LOG_PATH` env or `./audit/`), `--engagement` (optional filter).
88
+ - Scans audit directory for existing `.jsonl` files.
89
+ - Loads historical entries.
90
+ - Starts file watcher.
91
+ - Renders `<App>` via Ink's `render()`.
92
+
93
+ ### New Dependencies
94
+
95
+ | Package | Version | Purpose |
96
+ |---------|---------|---------|
97
+ | `ink` | ^5.0.0 | React terminal renderer |
98
+ | `react` | ^18.0.0 | Required by Ink |
99
+ | `ink-spinner` | ^5.0.0 | Loading spinner for "waiting for data" state |
100
+
101
+ ### Build
102
+
103
+ TSX files compiled by TypeScript. Requires updating `tsconfig.json` to set `"jsx": "react-jsx"`. Ink 5 supports this natively.
104
+
105
+ ## Error Handling
106
+
107
+ | Scenario | Behavior |
108
+ |----------|----------|
109
+ | No audit files exist yet | Shows "Waiting for audit data..." with spinner |
110
+ | Malformed JSONL line | Silently skipped, logged to stderr |
111
+ | File deleted or rotated | Watcher resets byte offset, rescans directory |
112
+ | Multiple engagement files | If no `--engagement` flag, shows all entries interleaved chronologically |
113
+ | Terminal resize | Ink handles automatically, feed adjusts height |
114
+ | Ctrl+C | Clean exit via Ink's signal handling |
115
+
116
+ ## Testing
117
+
118
+ - Unit test for the JSONL tail/parse logic (read new lines from offset, parse entries, handle malformed lines).
119
+ - No tests for Ink components — pure display layer over the already-tested audit system.
120
+
121
+ ## Files Created
122
+
123
+ ```
124
+ bin/integsec-agentic-pentest-tui.tsx Entry point
125
+ src/tui/App.tsx Root component
126
+ src/tui/EngagementHeader.tsx Engagement info panel
127
+ src/tui/StatsPanel.tsx Running stats panel
128
+ src/tui/LiveFeed.tsx Scrolling decision feed
129
+ src/tui/DecisionRow.tsx Single decision line
130
+ src/tui/useAuditWatcher.ts Hook: file watcher + JSONL parser
131
+ tests/unit/audit-watcher.test.ts Unit test for watcher/parser
132
+ ```
133
+
134
+ ## Out of Scope
135
+
136
+ - Interactivity (selecting entries, filtering in real time) — future Phase 3 work
137
+ - Intercept queue — future Phase 2 work
138
+ - Mouse support — not needed for read-only monitor
@@ -0,0 +1,248 @@
1
+ # Scope Manifest Builder — Design Spec
2
+
3
+ **Date:** 2026-03-29
4
+ **Status:** Approved
5
+
6
+ ## Overview
7
+
8
+ A CLI wizard and optional web companion for building, editing, reviewing, and sharing MCP scope manifests. Targets three personas: pentest operators (primary), security team leads, and clients filling out their own scope.
9
+
10
+ ## Architecture
11
+
12
+ Three layers, one shared validation core:
13
+
14
+ ```
15
+ ┌─────────────────────────────────────────────────────┐
16
+ │ Shared Core │
17
+ │ manifest-schema.ts (Zod) ← already exists │
18
+ │ smart-validator.ts (Tier 1-2 validation) │
19
+ │ dry-run.ts (reuses ScopeValidator for previews) │
20
+ │ manifest-writer.ts (serialize + output) │
21
+ └──────────┬──────────────────────────┬───────────────┘
22
+ │ │
23
+ ┌──────▼──────┐ ┌────────▼─────────┐
24
+ │ CLI Wizard │ │ Web Server │
25
+ │ (Ink TUI) │ │ (Node http/s) │
26
+ │ │ │ │
27
+ │ • new │◄───────►│ • Client intake │
28
+ │ • edit │ │ • Operator │
29
+ │ • review │ │ preview │
30
+ │ • serve │ │ • Scope dry-run │
31
+ └──────────────┘ └──────────────────┘
32
+ ```
33
+
34
+ The CLI is the primary interface. The web server is started on-demand via the `serve` subcommand. No external web framework — Node built-in `http`/`https` module + static HTML + small JSON API.
35
+
36
+ ## CLI Command
37
+
38
+ New binary: `integsec-agentic-pentest-manifest`
39
+
40
+ ### Modes
41
+
42
+ | Mode | Usage | Description |
43
+ |------|-------|-------------|
44
+ | `new` | `integsec-agentic-pentest-manifest new` | Full wizard, create from scratch |
45
+ | `new --from` | `integsec-agentic-pentest-manifest new --from template.json` | Pre-fill from template |
46
+ | `edit` | `integsec-agentic-pentest-manifest edit scope.json` | Edit existing manifest |
47
+ | `edit --section` | `integsec-agentic-pentest-manifest edit scope.json --section targets` | Jump to specific section |
48
+ | `review` | `integsec-agentic-pentest-manifest review submission.pending.json` | Review client submission |
49
+ | `serve` | `integsec-agentic-pentest-manifest serve` | Start client intake web server |
50
+
51
+ ### Wizard Steps (for `new`)
52
+
53
+ **Step 1: Engagement Info**
54
+ - Fields: `engagement_id`, `client`, `operator`
55
+ - Smart: auto-suggest engagement ID format (ENG-YYYY-NNNN)
56
+
57
+ **Step 2: Engagement Window**
58
+ - Fields: `start`, `end` (ISO 8601)
59
+ - Smart: warn if window > 30 days, start in the past, or window < 1 hour
60
+
61
+ **Step 3: Authorized Targets — Domains**
62
+ - Add domains one at a time or comma-separated
63
+ - Smart: resolve each domain live via `DnsResolver`, show mapped IPs
64
+ - Smart: if `*.foo.com` is added, prompt about including `foo.com` (apex)
65
+
66
+ **Step 4: Authorized Targets — IP Ranges**
67
+ - Add CIDRs
68
+ - Smart: warn if range broader than /16 ("covers X,XXX addresses")
69
+ - Smart: flag overlap with domains already added
70
+
71
+ **Step 5: Authorized Targets — URLs & Cloud Accounts**
72
+ - URLs (optional, for reference)
73
+ - Cloud account IDs (optional)
74
+
75
+ **Step 6: Exclusions**
76
+ - Excluded targets (IPs, domains)
77
+ - Smart: auto-suggest cloud metadata IPs (169.254.169.254), localhost
78
+ - Smart: warn if excluded target isn't within any authorized range (redundant)
79
+
80
+ **Step 7: Techniques**
81
+ - Multi-select from known technique categories
82
+ - Excluded techniques pre-populated with `dos`, `destructive`, `social_engineering`
83
+ - Smart: show which tools each category covers
84
+
85
+ **Step 8: Review & Dry-Run**
86
+ - Full manifest summary
87
+ - Dry-run: synthetic tool calls against the validator
88
+ - Show what would be allowed/blocked
89
+ - Confirm → write to file
90
+
91
+ ### Power-User Shortcuts
92
+
93
+ - `--from template.json` to pre-fill values
94
+ - `--section targets` to jump directly when editing
95
+ - Each wizard step shows `[s]kip` to jump ahead, `[b]ack` to go back
96
+
97
+ ## Web Server — Client Intake Mode
98
+
99
+ ### Operator Commands
100
+
101
+ ```bash
102
+ # Local only (operator previewing or sharing over SSH tunnel)
103
+ integsec-agentic-pentest-manifest serve --template scope-template.json
104
+
105
+ # Exposed to network (client access) — TLS required
106
+ integsec-agentic-pentest-manifest serve \
107
+ --host 0.0.0.0 \
108
+ --tls-cert ./certs/server.pem \
109
+ --tls-key ./certs/server-key.pem \
110
+ --template scope-template.json
111
+ ```
112
+
113
+ ### Network Security
114
+
115
+ - **Default port: 9471** (unassigned in IANA)
116
+ - **Binds to `127.0.0.1` by default** (localhost only)
117
+ - **`--host 0.0.0.0` requires TLS:** `--tls-cert` and `--tls-key` are mandatory when host is not localhost
118
+ - Server refuses to start without TLS on non-localhost and prints: `"Refusing to serve client intake form over plaintext on a non-localhost interface. Provide --tls-cert and --tls-key."`
119
+
120
+ ### Client Experience
121
+
122
+ - Clean, technical-but-approachable form with IntegSec branding
123
+ - Sections match manifest structure with tooltips explaining each field (e.g., "CIDR notation: 10.0.0.0/24 covers 10.0.0.0–10.0.0.255")
124
+ - Live validation as they type — red/green indicators for CIDR format, domain resolution, date parsing
125
+ - Pre-filled fields from template shown but locked (grayed out, not editable)
126
+ - Submit button saves a `.pending.json` file to the operator's working directory
127
+
128
+ ### Operator Review Flow
129
+
130
+ 1. Client submits via web form → `.pending.json` saved
131
+ 2. `integsec-agentic-pentest-manifest review client-submission.pending.json`
132
+ 3. Smart validation + dry-run shown in terminal
133
+ 4. Operator can: approve (writes final `.json`), edit (opens edit mode), or reject
134
+
135
+ ### API Endpoints
136
+
137
+ | Method | Path | Description |
138
+ |--------|------|-------------|
139
+ | `GET` | `/` | Serves the client intake form (single HTML file) |
140
+ | `GET` | `/template` | Returns pre-filled template data as JSON |
141
+ | `POST` | `/submit` | Validates submission, saves `.pending.json` |
142
+
143
+ Server auto-shuts down after submission or after 60 minutes of inactivity (configurable via `--timeout <minutes>`).
144
+
145
+ ## Smart Validation — Three Tiers
146
+
147
+ ### Tier 1: Format Validation (synchronous, instant)
148
+
149
+ - CIDR syntax valid (`ip-cidr` library, existing dependency)
150
+ - ISO 8601 date parsing (Zod, existing)
151
+ - Required fields non-empty
152
+ - Domain format valid (no spaces, valid TLD)
153
+ - Engagement ID matches pattern
154
+
155
+ ### Tier 2: Smart Validation (async, network calls)
156
+
157
+ - **Live DNS resolution** — resolve each domain, show IPs. Uses existing `DnsResolver`.
158
+ - **Overlap detection** — warn if domain resolves to IP already covered by authorized CIDR (informational)
159
+ - **Apex/wildcard consistency** — prompt about `foo.com` when `*.foo.com` is added
160
+ - **Broad range warning** — flag CIDRs wider than `/16`
161
+ - **Orphaned exclusion warning** — excluded target not in any authorized range
162
+ - **Window sanity** — start in past, > 30 days, < 1 hour
163
+
164
+ ### Tier 3: Dry-Run Preview (reuses existing `ScopeValidator`)
165
+
166
+ Constructs a temporary `ScopeValidator` from the in-progress manifest and runs synthetic tool calls:
167
+
168
+ | Test | Tool | Expected |
169
+ |------|------|----------|
170
+ | Each authorized domain | `nmap` | ALLOWED |
171
+ | Sample IP from each authorized range | `nmap` | ALLOWED |
172
+ | Each excluded target | `nmap` | BLOCKED |
173
+ | Sensitive targets (169.254.169.254, localhost) | `curl` | BLOCKED (unless explicitly authorized) |
174
+ | Out-of-scope target (8.8.8.8) | `nmap` | BLOCKED |
175
+
176
+ Results displayed as a table with pass/fail indicators. Surprises are flagged.
177
+
178
+ ## File Structure
179
+
180
+ ```
181
+ src/
182
+ builder/
183
+ wizard.tsx ← Ink wizard (main flow, step management)
184
+ steps/
185
+ engagement-info.tsx ← Step 1
186
+ engagement-window.tsx ← Step 2
187
+ domains.tsx ← Step 3
188
+ ip-ranges.tsx ← Step 4
189
+ urls-and-cloud.tsx ← Step 5
190
+ exclusions.tsx ← Step 6
191
+ techniques.tsx ← Step 7
192
+ review.tsx ← Step 8: summary + dry-run
193
+ smart-validator.ts ← Tier 1-2 validation (shared core)
194
+ dry-run.ts ← Tier 3 dry-run engine (shared core)
195
+ manifest-writer.ts ← Serialize + write manifest to disk
196
+ web/
197
+ server.ts ← Node http/https server
198
+ client-form.html ← Single-file client intake form (no build step)
199
+ api.ts ← Route handlers for /template and /submit
200
+
201
+ bin/
202
+ integsec-agentic-pentest-manifest.ts ← new CLI entry point
203
+ ```
204
+
205
+ ### New package.json Entry
206
+
207
+ ```json
208
+ "integsec-agentic-pentest-manifest": "dist/bin/integsec-agentic-pentest-manifest.js"
209
+ ```
210
+
211
+ ## Reused Existing Modules
212
+
213
+ | Module | Reuse |
214
+ |--------|-------|
215
+ | `manifest-schema.ts` | Zod schema for validation |
216
+ | `types.ts` | `ScopeManifest` type |
217
+ | `validator.ts` | `ScopeValidator` for dry-run |
218
+ | `dns-resolver.ts` | Live domain resolution |
219
+ | `ip-matcher.ts` | CIDR validation and overlap detection |
220
+ | `domain-matcher.ts` | Wildcard consistency checks |
221
+ | `technique-checker.ts` | Tool-to-category mappings |
222
+
223
+ ## README Updates
224
+
225
+ Add a new "Manifest Builder" section to README.md covering:
226
+
227
+ - Feature overview and motivation
228
+ - Usage examples for all four modes (`new`, `edit`, `review`, `serve`)
229
+ - Client intake workflow walkthrough (operator creates template → shares link → client fills out → operator reviews)
230
+ - TLS setup instructions for network-exposed intake
231
+ - Smart validation and dry-run explanation
232
+ - Screenshots/examples of the wizard and web form
233
+
234
+ ## Dependencies
235
+
236
+ No new production dependencies required. Everything builds on:
237
+ - `ink` (existing) — for TUI wizard
238
+ - `react` (existing) — for Ink components
239
+ - `zod` (existing) — for schema validation
240
+ - `ip-cidr` (existing) — for CIDR operations
241
+ - Node built-in `http`/`https`/`tls` — for web server
242
+
243
+ ## Incremental Delivery
244
+
245
+ 1. **Phase 1:** CLI wizard (`new` mode) + shared validation core + dry-run
246
+ 2. **Phase 2:** `edit` and `review` modes
247
+ 3. **Phase 3:** Web server (`serve` mode) + client intake form
248
+ 4. **Phase 4:** README updates, polish, edge cases
package/docs/tui.md ADDED
@@ -0,0 +1,25 @@
1
+ # TUI monitor
2
+
3
+ The terminal monitor tails local audit JSONL files written by the proxy. Run it in a separate terminal using the path printed by `integsec-agentic-pentest-setup`:
4
+
5
+ ```bash
6
+ integsec-agentic-pentest-tui --audit-path /path/to/audit
7
+ ```
8
+
9
+ Use `--engagement <id>` to show one engagement. The header shows the engagement, client, and operator from the first matching entry. The stats panel shows allowed and blocked counts and frequent targets and tools. The live feed shows recent decisions, targets, reasons for blocks, and duration.
10
+
11
+ The action shots below use fictional identifiers and documentation-only IP addresses. They are rendered from the actual TUI components.
12
+
13
+ ### In-scope scan
14
+
15
+ ![TUI showing six allowed tool calls for fictional in-scope targets](images/tui-in-scope.png)
16
+
17
+ ### Out-of-scope target blocked
18
+
19
+ ![TUI showing a blocked documentation IP and excluded hostname](images/tui-out-of-scope.png)
20
+
21
+ ### Technique and time guardrails
22
+
23
+ ![TUI showing technique, free-form command, and time-window blocks](images/tui-policy-blocks.png)
24
+
25
+ Regenerate the images from the current TUI components with `npm run build` followed by `node scripts/render-tui-shots.mjs`. The script writes SVG sources; the checked-in PNGs are the rendered documentation previews.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integsec/agentic-pentest-proxy",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "IntegSec Agentic Pentest MCP Proxy — enforce penetration testing engagement scope for AI agents",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,7 +22,7 @@
22
22
  "cloudflare/src/worker.mjs",
23
23
  "cloudflare/package.json",
24
24
  "cloudflare/package-lock.json",
25
- "docs/managed-gateway.md",
25
+ "docs/",
26
26
  "examples/",
27
27
  "scripts/postinstall.cjs",
28
28
  "README.md",
@@ -61,10 +61,12 @@
61
61
  "ink-spinner": "^5.0.0",
62
62
  "ipaddr.js": "^2.5.0",
63
63
  "jose": "^6.2.15",
64
+ "markdown-it": "^14.3.3",
64
65
  "react": "^18.3.1",
65
66
  "zod": "^4.6.7"
66
67
  },
67
68
  "devDependencies": {
69
+ "@types/markdown-it": "^14.2.0",
68
70
  "@types/node": "^22.20.5",
69
71
  "@types/react": "^18.3.28",
70
72
  "typescript": "^5.7.0",