SkillPedia Skills Encyclopedia
中文 EN

技能 2026-10-05 15:34 UTC

VulnClaw

由提交人 Unclecheng-li 提交,主要更新类型为:常规更新与维护。提交说明:Dev (#301)。对项目做了常规维护与小幅调整。

Unclecheng-li 0b34878 Netw0rkNoob/VulnClaw

Commit提交信息原文

Dev (#301)

* fix(traffic): update Content-Length when overriding replay bodies (#283)

* fix(docker): copy protocol/ so hatchling force-include resolves in image builds (#285)

A clean-clone 'docker compose up --build' fails at 'pip install -e .' because
the wheel force-include targets protocol/tui-v1.schema.json but the Dockerfile
never copies protocol/ into the image. Copy it next to the package so both the
editable install and the packaged vulnclaw/protocol/tui-v1.schema.json exist.

Fixes #284

* fix(report): preserve fetch request fields in replay examples (#287)

* fix(report): preserve fetch request fields in replay examples

* test(report): preserve UTF-8 curl arguments on Windows

* fix(deps): guard against the openai<1.55.3 + httpx>=0.28 proxies TypeError (#289)

Fixes #288

Users on freshly resolved environments hit this on every solve turn:

    Thinking... error: Client.__init__() got an unexpected keyword argument 'proxies'

Reproduced 1:1 locally with openai==1.54.1 + httpx==0.28.1: plain
openai.OpenAI(api_key=..., base_url=...) raises exactly that TypeError,
because httpx removed the proxies argument in 0.28 while the default-client
construction in openai releases older than 1.55.3 still passes it. VulnClaw
never passes proxies itself; this is purely a resolver-level mismatch that
our floor-only constraints (openai>=1.30.0, httpx>=0.27.0) allowed.

Two-layer fix:
- pyproject: raise the openai floor to >=1.66.0 with a comment explaining
  the 1.55.3 boundary, so a fresh pip install can never resolve into the
  broken range
- settings.make_openai_client: detect the signature TypeError mentioning
  proxies and re-raise as a RuntimeError carrying the installed versions
  and the one-line remedy, instead of the raw TypeError on every turn

Verified: repro env fires guidance with correct versions; boundary combos
(1.55.3+0.28.1, 1.54.1+0.27.2) fine; healthy env unaffected; pytest
tests/config tests/agent: 686 passed.

* feat(tui): add an interactive LLM settings screen to /config (#291)

* chore(config): refresh provider presets to current models

Retire two presets whose vendors can no longer serve them: 01.AI shut its
public API down on 2026-09-03 (the endpoint now answers 410 Gone) and
Baichuan has shipped no general-purpose model since 2024. Point SenseTime at
its OpenAI-compatible `/compatible-mode/v2` gateway rather than the legacy
native one, which 404s.

Refresh the remaining defaults to the current generation — OpenAI gpt-5.6-sol
(the newer gpt-6-astra requires the Responses API for tool calling, which this
client does not speak), Anthropic and OpenRouter claude-opus-5, GLM 5.3,
Kimi K3, Qwen3.8-Max, Doubao Seed-Evolving, StepFun 3.7 Flash and Ollama
qwen3.5:9b — and derive `LLMConfig.model` from the OpenAI preset so a fresh
install no longer points at gpt-4o.

Also guard `apply_provider_preset` against an outgoing provider that this
build no longer knows, which the removals above would otherwise turn into a
crash for anyone switching away from a retired preset.

* feat(tui): add an interactive LLM settings screen to /config

/config in the Rust workbench used to print a hint pointing at
`vulnclaw config set`. It now opens a modal editing the provider template and
the four fields it drives: website URL, API request URL, API key and model.

The screen has two modes. Enter opens the focused row for typing and a second
Enter confirms it; while a row is open the arrows move its suggestions rather
than the selection, so an unconfirmed edit cannot be walked away from. Esc
unwinds one level at a time — the template list, then the row, then the
screen. Choosing a template reseeds the preset-derived fields, and `custom`
blanks them for hand entry.

Model lists come back from a new config.models operation, which falls back to
the stored credential when no key has been typed. A provider can advertise
hundreds of models (OpenRouter reports 445), so only a six-row window is
drawn; it scrolls with the highlight and closes with a "… N more" row
counting what is still below it, which disappears at the last entry.

Backed by four capability-gated JSONL control operations — config.read,
config.preset, config.models and config.write — that persist through
save_config and rebind the live agent, so a change takes effect without
restarting the TUI. The API key is never echoed back over the protocol.

* fix(cli): show LLM errors in single-turn REPL chat (#292)

* fix(report): let curl calculate body length and reject header controls (#294)

* fix(tui): make Ctrl+V paste into the composer on Windows (#297)

* fix(tui): make Ctrl+V paste into the composer on Windows

Windows has no bracketed paste: crossterm 0.28 parses the sequence on
Unix only, so main.rs gates EnableBracketedPaste on unix and Event::Paste
never fires there. Pasting therefore depended entirely on the terminal
synthesizing keystrokes, which conhost, VSCode, and several embedded
terminals do not do. When that synthesis is absent, Ctrl+V arrives as
Char('v')+CONTROL and the CONTROL guard on the composer's char arm drops
it into '_ => {}' — pasting silently does nothing.

Give Windows a deterministic path: Ctrl+V reads the system clipboard
(the built-in Get-Clipboard -Raw, scripted via stdin so clipboard
payloads can never alter the command line) and inserts it through the
existing insert_text, which already filters newlines so a multi-line
paste never submits. The LLM settings screen gets the same arm while a
row is open, mirroring its Event::Paste routing. Unix keeps bracketed
paste as the primary path; its Ctrl+V shows a pointer toast instead of
failing silently.

Both arms are rejected while the execution-approval modal is pending,
preserving the no-smuggled-keystrokes invariant of that modal.

Tests: cargo fmt/clippy clean; the two new routing tests pass. The 27
pre-existing backend-harness failures reproduce on clean dev (Windows
pipe-instance exhaustion in support.rs, unrelated).

Fixes #296

* fix(tui): stop clipboard children from hiding the shared console window

Spawning powershell.exe with -WindowStyle Hidden from inside the TUI hides
the *parent's* console window too: console children attach to the caller's
shared console, and the hidden window style is applied to that console.
Pressing Ctrl+V therefore made the whole TUI "disappear" while the process
kept running in the background.

Replace -WindowStyle Hidden with the CREATE_NO_WINDOW creation flag
(0x08000000) in all three clipboard helpers:

- tui/src/app.rs read_from_clipboard (Ctrl+V paste, this PR)
- tui/src/app.rs copy_to_clipboard (Ctrl+C copy, pre-existing)
- vulnclaw/cli/tui.py _read_system_clipboard (py TUI panel, pre-existing)

The flag detaches the child from any console window entirely, so no window
flash occurs and the TUI console is never hidden.

* ci: bump allowlisted spawn-site line number after tui.py edit

* fix(cli): make CREATE_NO_WINDOW importable on non-Windows test envs

* perf(tui): read the clipboard via Win32 API and add Shift+Insert / right-click paste

Local verification of #296 surfaced two follow-ups: the paste worked but
took 2-3 seconds per Ctrl+V, and only Ctrl+V could trigger it.

The latency came from the helper shelling out to powershell.exe: every
paste paid a full .NET/PowerShell process startup (1-3 s on typical
machines). Replace the subprocess detour with direct Win32 clipboard
calls through the FFI (OpenClipboard/GetClipboardData/SetClipboardData
on CF_UNICODETEXT) - the same API PowerShell itself wraps, completing in
microseconds. No new dependencies: the symbols come from user32/kernel32,
which the linker already knows.

Ctrl+C copy gets the same treatment: the previous path wrote a temp file
and ran Set-Clipboard through a hidden window-less PowerShell; it now
writes the HGLOBAL directly (also removing the temp-file round trip and
its disk artifact).

Paste also gains two additional triggers alongside Ctrl+V:

- Shift+Insert, the terminal-native paste chord (predates mice and
  Ctrl+V); terminals deliver it as a key event, never as bracketed
  paste, so it needs the same explicit routing in the composer and the
  LLM settings editor.
- Right mouse button, mirroring the Windows Terminal / conhost
  quick-edit convention; the approval/task/settings modal guards ahead
  of the mouse dispatch already swallow it, so no clipboard content can
  reach the composer through a modal.

Unix behavior is unchanged: bracketed paste remains the primary path and
the clipboard helpers return None/false there.

Tests: four new routing tests (Shift+Insert paste, right-click paste,
and both modal-safety variants) pass; full local run shows only the 27
pre-existing Windows pipe-exhaustion failures in the backend harness
(reproduce on clean dev, unrelated). CI was green for the previous
commits on both OSes.

* fix(tui): survive console buffer recreation during maximize/fullscreen toggles (#299)

* fix(tui): survive console buffer recreation during maximize/fullscreen toggles

Windows recreates the console screen buffer when the terminal window
toggles between maximized/restored or enters/leaves fullscreen. During
that moment a size query, a console write, or an event read can fail
exactly once. The main loop propagated every such error straight out of
run(), unwinding main: the process exited, the alternate screen was
torn down, and the window flashed closed with no message. The
probability rises with transcript content because each frame then
writes far more bytes, widening the race window against the buffer
recreation - exactly the "works until the transcript grows, then
crashes on maximize" pattern reported in #298.

Three layers of defence in run():

1. terminal.size() errors are retried after a 75ms backoff instead of
   being fatal. The freshly queried size is also taken before the draw
   so the frame matches what the console can actually accept.
2. The per-frame draw is wrapped in catch_unwind: a rare layout panic
   under an unusual resize geometry now skips that frame instead of
   killing the process. The CompletedFrame result is mapped to () inside
   the closure because it borrows the terminal buffer and cannot escape
   the FnMut body.
3. A panic hook persists every panic payload to
   %TEMP%\vulnclaw-tui-panic.log - the alternate screen hides stderr,
   so until now every crash diagnostic was invisible.

All retry paths are bounded by a consecutive-failure cap (40 failures,
about 3 seconds) so a permanently broken console still terminates the
process instead of spinning forever.

Fixes #298

* fix(tui): also retry poll/read errors and never report errors to a severed stderr

The panic log installed by the previous commit caught the real #298
crash path: "failed printing to stderr: pipe has no peer (os error
233)" at library/std/src/io/stdio.rs. Two gaps remained after the
first fix:

1. event::poll()/event::read() still used bare `?`. When the ConPTY
   pipe is momentarily severed during the fullscreen/maximize
   transition, the read error propagated out of run() exactly like
   the size/draw errors did.
2. After run() returned Err, the Rust runtime reports the error by
   printing it to stderr - the same broken pipe - and that print
   failing panics inside std itself, aborting the process. This is
   the stdio.rs:1166 panic the log captured.

Both ends are now closed:

- poll/read join size/draw in the retry-with-backoff regime, bounded
  by the same consecutive-failure cap.
- main() no longer returns an Err to the runtime: after terminal
  cleanup, a fatal error is appended to the panic log and the process
  exits with code 1 directly, so no runtime error report can ever hit
  the severed pipe.
- The panic hook body itself only writes to the log file, never
  stderr, for the same reason.

Local verification: the two full-screen toggle crashes that produced
the log entries are the reproduction case; after this fix the toggles
survive.

* perf(tui): back off one frame after resize to avoid racing the console host reflow

* fix(tui): skip ratatui Terminal Drop on the fatal-console path

The 20:17 panic-log entry from the latest binary pinpointed the last
unprotected stderr writer: ratatui's Terminal Drop impl calls
eprintln!("Failed to show the cursor") when cursor restoration fails,
and on the already-severed console pipe that print panics inside std
(ratatui-0.29.0/src/terminal/terminal.rs:97) and aborts the process.

When run() fails fatally the process is exiting anyway, so skip the
Drop entirely via mem::forget and let main's own exit path do the
reporting (panic log + exit code). The happy path keeps the normal
Drop-based cleanup.

* chore(release): bump version to 0.4.1 (#300)

---------

Co-authored-by: Colin <C01in@qq.com>
Co-authored-by: FarStar-CN <farstar2272@gmail.com>
Co-authored-by: ducat <49578953+525300887039@users.noreply.github.com>