Repository navigation
fix(mcp): honor proxy in config schema so large servers collapse to 2 meta-tools - #26
Closed
overtimepog wants to merge 27 commits into
Closed
overtimepog wants to merge 27 commits into
overtimepog wants to merge 27 commits into
Conversation
Adds the OPENCODE_UA_OVERRIDE flag and applies it to the User-Agent header used for model requests. Needed to use OpenCode Zen free models from this build; see OPENCODE_FREE_TIER.md.
…udit tools - phases: recon, enumeration, vuln-assess, exploitation (all 7 PTES phases now covered) - playbooks: methodology (PTES/OWASP/NIST/OSSTMM/ATT&CK + RoE), api (OWASP API Top 10), social-engineering (GoPhish/vishing/physical) - services: mobile-ios (class-dump/ATS/Keychain/Frida) - cloud playbook: add ScoutSuite/Prowler/Pacu posture auditing
scope-matcher-extraction.test.ts regression (code-token FP flood fix) made internal-TLD and exotic-gTLD extraction intentional. Update 4 stale tests in scope-matcher.test.ts to assert the new no-warn behavior for .zip/.mov/ .security/.company/.network/.agency and internal .local hosts.
Reproduces SkillV2.load() glob+frontmatter logic against ./skills and asserts all 30 skills (incl. the 8 new methodology skills) resolve with a name and description.
- /engagement (aliases /engagements, /eng) opens the engagement picker mid-session; previously it only auto-opened once on startup - .selected is now applied even when an engagement is already loaded, so picking mid-session actually switches on the next prompt - + New engagement prompts for a name and queues "__new__:<name>"; reusing an existing name loads it instead of clobbering its state - No engagement (freestyle) now unloads the active engagement and drops the .last auto-resume pointer (new store.unload)
The b8edec4 rename changed both server reads to x-pentestcode-directory, but the SDK (sdk/js/src/v2/client.ts) and the server test suite send x-opencode-directory. Clients' directory headers were invisible, so the legacy route resolver (workspace-routing defaultDirectory) and the v2 location middleware both fell back to process.cwd(): sessions landed in the checkout while run listened on a different instance, printing nothing and never exiting. Accept both spellings (opencode first).
…andler run.ts's handler resolves its root from PWD ?? cwd, but effect-cmd's bootstrap loaded the instance from the command's directory option, which only consulted process.cwd(). With launch wrappers (bun --cwd, etc.) the two disagree and two instances were loaded. The option now resolves exactly like the handler.
…ailover - Free Zen models run through the fork via the User-Agent override (OPENCODE_FREE_TIER.md documents the gate, the pin, and the wrapper) - getSmallModel keeps Zen auto-picks on cost-0 models; fallbackModel maps refused Zen/Go turns (402/403/free-limit/GoUsageLimit) to the equivalent OpenRouter model once, updating the assistant message - /connect lists OpenCode Go first with a Go/Go Plus hint; its API-key hint is shared with the opencode provider
…ived naming Cost: - add_vuln attributes the model spend since the previous finding to each finding; session-tree aware (subagents recursively) via Session.costTree and an engagement cost ledger whose cursors survive restarts - state_query costs lists per-finding spend + unattributed total; vuln listings, subagent completions, findings.md and reports carry their full tree cost Creation: - create_engagement requires user approval (ctx.ask + create_engagement ask rule placed after the * allow wildcard) — no silent/orphan engagements; run without --auto auto-rejects - '+ New engagement' defers naming to the agent (bare __new__ plus a <new-engagement-requested> directive): names come from the target/product/program (e.g. okta-bugcrowd-2026-10), never from the working directory (that produced opencode-2026-10 junk folders) - custom-name row kept for deliberate naming; CLAUDE.md documents both rules so they do not regress
…n API Adds sync.session.treeCost(sessionID) (self + descendants, recursively) and exposes it as TuiPluginApi.state.session.treeCost. The sidebar 'spent' line, the prompt footer, and the subagent footer now show the full tree cost — a session's number includes every subagent it spawned.
New 'Set as default' action (ctrl+o) writes model to the global config (jsonc-preserving), toasts, and marks the row '· Default' / '(Default)' immediately. Applies to new sessions and pentestcode run without -m.
Some providers reject an over-sized prompt with their own wording instead of a context-length error (OrcaRouter free tier: 'This prompt is longer than the free tier allows for a single request...'). That message was not classified, so the turn failed hard instead of using the existing overflow recovery (halt → compaction → retry). - classify the OrcaRouter free-tier cap message as context overflow - bound overflow recovery: compact once, retry once; if the retried turn overflows again compaction cannot shrink the prompt (e.g. one huge pasted message), so fail with a clear ContextOverflowError instead of compacting in a loop
…ta-tools
Some providers cap the number of tools per request (BugBunny: 128 function
tools). Servers that expose one tool per action blow past that: drost alone
registers 159, so no model on such a provider could use it.
New per-server config flag `proxy: true` registers exactly two meta-tools
instead of one tool per action:
- <server>_catalog — list all actions compactly, or fetch one action's full
input schema
- <server>_run — execute any action: { tool: "<name>", arguments: {...} }
Every action stays reachable; only two entries occupy the request's tool
list. The flag is opt-in per server and works for local and remote MCP
servers. Includes tests for listing, schema lookup, dispatch, and unknown-
tool errors.
A subagent that finished with a full report could produce no coordinator message at all: the orchestrator built the completion note with EngagementSchema.formatCost, and when that export was missing (a partial working-tree revert of core/engagement/schema.ts) the TypeError was swallowed by `catchCause(() => Effect.void)` at the debounce flush. Log every failure in the completion path instead of discarding it: - flushBatch's prompt injection - the debounced flush itself (where the render TypeError landed) - both inject helpers (orchestrator + background task) - both background wait handlers - the orchestrator watchdog loop Interrupt-only causes still pass through so cancellation stays quiet.
Sync s0ld13rr/pentestcode v0.2.7: command-injection + arbitrary-file-write security fix (tunnel_manage/report_gen), subagent.kill keybinding, version bump, and upstream methodology-corpus docs. Conflicts in state-query.ts and state-update.ts resolved by keeping local NO_ENGAGEMENT wording and the per-finding cost-attribution work, and adding upstream's COORDINATOR_AGENTS / ENGAGEMENT_LIFECYCLE_ACTIONS coordinator gating. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Close the discovery gap: pentestcode found bugs only from tool output (nmap/nuclei/sqlmap parsers) with no agent that reads source code. - source_auditor (claude-opus-5-5): source-level vuln discovery by dataflow reasoning — memory safety (OOB/UAF/int-overflow/length-into-fixed-buffer), injection sinks, deserialization, auth/logic/TOCTOU, crypto/parser boundaries. Emits candidates with file:line dataflow + trigger hypothesis. - variant_hunter (claude-fable-5-2): 1-day/variant analysis — distills a bug or CVE patch into a code-shape rule, sweeps the codebase (ripgrep/ast-grep/semgrep) for reachable siblings, records reusable shape rules via knowledge. Both slot into the existing discover -> exploit_dev -> critic loop. Models are bound per-agent via the Info.model field and overridable in .pentestcode config. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…uditor/variant_hunter Walks a local source tree and returns a ranked sink/taint LEAD map (memory, injection, deserialization, unsafe, crypto-boundary, path, ssrf, format) across C/C++/Rust/Go/Python/ PHP/Ruby/Java/JS/TS/C#. Leads are STRONG when an attacker-taint marker sits near the sink. Pure analyzer: never executes target code and never writes engagement state — the driving subagent traces reachability and records candidates itself (keeps the [UNVERIFIED] discipline). Wires source_audit into the registry and grants it to source_auditor + variant_hunter, and points both prompts at it as the first-pass map. Closes the gap where those subagents had a methodology but no structured instrument (parity with inject_probe -> webapp). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…e-audit Complete the source-audit rework and add the n-day->variant engine, aligning the code-audit path with the AI-assisted source-audit methodology behind nginx2root / java4shell (find NOVEL bugs by reading source, not scanning). Agents: - Replace source_auditor + variant_hunter with a unified code_auditor (Opus 5.5), registered in agent.ts and auto-discoverable by the coordinator. - Grant patch_diff to pentest / exploiter / exploit_dev. Tools: - Add patch_diff: n-day->variant engine. action=plan emits the git fetch+diff commands; action=analyze parses a fix diff into the vulnerable shape, the guard the fix added, ripgrep/semgrep variant sweeps, and an incomplete-fix checklist. - Register semgrep_parse and patch_diff in the tool registry; drop the old source_audit tool. Prompts / skill: - code-audit.txt: target-selection (cross-boundary fast paths, lifecycle->UAF, integer/length->OOB) + coverage-ledger / finder-not-verifier / multi-pass / sandbox discipline. - critic.txt: source->sink reachability proof standard (trace + bounded result). - skills/research/source-audit: coverage-led, disprove-first loop. Docs: - docs/code-auditor-upgrades.md: research + prioritized upgrade plan. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Checkpoint of ongoing work-in-progress across the fork — free-tier UA override, provider/model wiring, MCP config, compaction, session prompt/system/instruction, pentest.txt, TUI dialogs/keybinds, tests, README/CLAUDE docs, and the cloud playbook. Grouped as a single snapshot commit, not a finished feature; untracked scratch (findings/, "Claude outputs/", .bak files) deliberately excluded. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
CodeQL/Joern SARIF parser that folds cross-function source->sink dataflow leads into engagement state — the layer semgrep cannot reach, targeting nginx2root-class bugs (a pointer freed in one function and used in another; a length that wraps across a call boundary). - tool: codeql_parse parses SARIF v2.1.0, extracts the full codeFlow path (source -> ... -> sink across files/functions) as evidence, maps the rule's security-severity to severity, dedups by (ruleId, path, line), records each as suspected/unverified for the auditor to trace and critic to disprove. - registry: register codeql_parse; grant it to the code_auditor agent. - ensure_tools: add semgrep (was missing), codeql, and joern under a new `audit` category with best-effort installers. - skill/prompts: CodeQL cpp-security-extended DB-build + analyze recipe and the Joern no-build alternative in the source-audit skill; tool refs updated in code-audit.txt. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Agent-level evals that measure the whole code-audit loop (not just a parser): clone a real known-CVE project at its vulnerable commit, let code_auditor audit it, and score whether it recorded the known bug in engagement state. - score.ts: reads engagement state.json, collects vuln-like objects, fuzzy-matches each against a challenge's ground truth (file / text / class); exit 0 = FOUND, 1 = NOT FOUND, partial credit shown. - challenges/cjson-cve-2019-11835: cJSON 1.7.10 cJSON_Minify OOB (CWE-125/787). Ground truth taken directly from the repo's own fix commit a43fa56, not a third-party writeup. setup.sh clones the vulnerable v1.7.10 into ./work/src (gitignored). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Second source-audit challenge, this one built to exercise cross-function
dataflow (the codeql_parse / Joern path) rather than intra-function
reasoning like the cJSON smoke test.
Target: mongoose mbedTLS teardown. mg_ssl_if_conn_free() frees ctx->conf
(mbedtls_ssl_config_free + MG_FREE) and THEN calls
mg_ssl_if_mbed_free_certs_and_keys(ctx), whose first statement is
`ctx->conf->key_cert = NULL;` — a write through the freed pointer. The
free is in the caller, the use is in the callee, so neither function is
wrong on its own; the bug only appears when you follow the call edge.
Ground truth taken directly from the repo's own fix commit d6259332
("Fix use-after-free", "Free keys and cert before conf, not after"), not
a third-party writeup. setup.sh clones the exact parent of that fix
(260229a) so the vulnerable checkout is tag-free and exact; work/ is
gitignored. Verified the generic scorer reports FOUND (100/100) on a
matching cross-function finding and NOT FOUND on an unrelated one.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ent) `pentestcode run --agent code_auditor` silently falls back to the default agent — run.ts rejects subagents passed to --agent. code_auditor is a subagent, so it's reached through the pentest coordinator (which delegates via the task tool), not run directly. - README + both setup.sh now show `pentestcode run "Delegate to the code_auditor subagent: <prompt>"` (coordinator delegates), with a note that --agent on a subagent falls back. - Also fix the echoed challenge.json path: ../challenge.json -> ./challenge.json (the command runs from the challenge dir, same as the score step). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
code_auditor was hardcoded to anthropic/claude-opus-5-5. Drop the model field so it inherits the session's configured default like every other agent (model is Schema.optional). The ProviderV2/ModelV2 imports stay — still used by the agent schema and the model resolver. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… 2 meta-tools
Proxy mode (src/mcp/catalog.ts) exposes a server as `<name>_catalog` +
`<name>_run` instead of one tool per action, read in src/mcp/index.ts via
`"proxy" in mcpConfig && mcpConfig.proxy === true`. But `proxy` was never in
the MCP config schema, so Effect's decoder stripped it before index.ts saw it:
the existing `proxy: true` on drost was silently inert and every tool was still
listed.
- core/v1/config/mcp.ts: add optional `proxy` to McpLocalConfig/McpRemoteConfig.
- core/v1/config/config.ts: the partial-overlay union member `{enabled}` becomes
`{enabled?, proxy?}` so an overlay file can flip a server to proxy without
redefining it.
Backward compatible. On a small-context local model (Inkling 2 Mini via Strata)
the pentestcode first-turn prompt drops from 95,258 to 28,340 tokens with all 6
MCP servers still reachable.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Author
|
Opened against the wrong repo (meant for my own fork). Closing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Proxy mode (
src/mcp/catalog.ts) collapses an MCP server into two meta-tools (<name>_catalogto list tools / fetch one schema,<name>_runto execute one) instead of one tool per action.src/mcp/index.tsactivates it via"proxy" in mcpConfig && mcpConfig.proxy === true.But
proxywas never part of the MCP config schema (core/v1/config/mcp.ts). Effect's decoder strips unknown struct keys, soproxywas removed beforeindex.tscould read it — the existingproxy: trueon the drost server was silently inert, and every tool was still listed on every request.Fix
core/v1/config/mcp.ts: add optionalproxytoMcpLocalConfigandMcpRemoteConfig.core/v1/config/config.ts: the partial-overlay union member{ enabled }becomes{ enabled?, proxy? }, so an overlay file can flip a server to proxy without redefining it in full.Backward compatible: the default profile loads unchanged.
Measured impact
pentestcode against a small-context local model (Inkling 2 Mini served by Strata), first-turn prompt size (server-reported
prompt_tokens):Every tool stays reachable; the prompt drops 3.4x. Verified the model dispatches a proxied meta-tool (
crypto_catalog) end-to-end.🤖 Generated with Claude Code