Skip to content

feat: run subcommand and the full guardrail set - #4

Merged
tannevaled merged 1 commit into
mainfrom
run-cmd-guardrails
Nov 10, 2026
Merged

tannevaled merged 1 commit into
mainfrom
run-cmd-guardrails

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Summary

Final piece of the automation layer (closes the plan at ~/.claude/plans/federated-nibbling-pixel.md): webtest run <scenario.hcl> renders the scenario's page and drives it via driver.Run, with every guardrail go-wasmcontainers asked for:

  • Dry-run by default: a submit step always computes PreviewSubmit's own preview; only --submit performs the real request.
  • Pinned-page check: already in driver.Run itself (PR feat: driver package — execute a scenario against a real LiveDocument #3), nothing new needed here.
  • Session persistence (session.go): cookies the real http.Client actually received are kept in a 0600 file under the user's own config dir, never in an argument/env var/log line. A file found with any other permission is treated as corrupted, not silently trusted. cookiejar.Jar exposes no "list every cookie" method, so saving asks it per-host for exactly the hosts this run touched.
  • Append-only audit log (auditlog.go): one JSON line per submit step (time/url/method/body/dry_run), 0600, rotated past 10 MiB.
  • Bounds: --timeout (default 30s), --max-steps (default 200, checked before any rendering happens).
  • Anti-bot detection (antibot.go): a small, named marker set for well-known CAPTCHA providers and Cloudflare's own interstitial — found, run refuses outright. A heuristic, not exhaustive, and deliberately biased toward false positives over false negatives (stopping on an ordinary page that happens to mention one of these words is the safer failure direction for a tool whose whole point is never to route around a real challenge).

Decisive test: TestRunPersistsCookiesAcrossInvocations — a login run (--submit) followed by a SEPARATE run invocation that only succeeds because the persisted cookie carried the session across.

Test plan

  • TestRunDryRunByDefaultNeverPosts — test server fails if a POST ever arrives
  • TestRunSubmitFlagPerformsRealRequest
  • TestRunMaxStepsExceeded
  • TestRunRefusesAntiBotPage
  • TestRunPersistsCookiesAcrossInvocations
  • TestLoadCookieJarMissingFileIsEmptyNotError / TestLoadCookieJarRefusesWrongPermissions / TestSaveAndLoadCookieJarRoundtrip / TestSaveCookieJarOnlyNamedHosts
  • TestAppendAuditLogCreatesAndAppends / TestAppendAuditLogRotatesWhenTooLarge
  • TestDetectAntiBotFindsRecaptcha / TestDetectAntiBotFindsCloudflareInterstitial / TestDetectAntiBotOrdinaryPage
  • go build/go vet/gofmt -l/govulncheck ./... clean
  • go test ./... green (46 tests across all packages), go test ./... -race clean

🤖 Generated with Claude Code

webtest run <scenario.hcl> renders the scenario's page and drives it
via driver.Run, with every guardrail go-wasmcontainers asked for:

- Dry-run by default: a submit step always computes PreviewSubmit's
  own preview; only --submit performs the real request.
- Pinned-page check: already in driver.Run itself, nothing new needed
  here.
- Session persistence (session.go): cookies the real http.Client
  actually received are kept in a 0600 file under the user's own
  config dir, never in an argument/env var/log line. A file found with
  any other permission is treated as corrupted, not silently trusted.
  cookiejar.Jar exposes no "list every cookie" method, so saving asks
  it per-host for exactly the hosts this run touched.
- Append-only audit log (auditlog.go): one JSON line per submit step
  (time/url/method/body/dry_run), 0600, rotated past 10 MiB.
- Bounds: --timeout (default 30s), --max-steps (default 200, checked
  before any rendering happens).
- Anti-bot detection (antibot.go): a small, named marker set for
  well-known CAPTCHA providers and Cloudflare's own interstitial —
  found, run refuses outright. A heuristic, not exhaustive, and
  deliberately biased toward false positives over false negatives
  (stopping on an ordinary page that happens to mention one of these
  words is the safer failure direction for a tool whose whole point is
  never to route around a real challenge).

Decisive test: TestRunPersistsCookiesAcrossInvocations — a login run
(--submit) followed by a SEPARATE run invocation that only succeeds
because the persisted cookie carried the session across.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit faa248b into main Nov 10, 2026
1 check passed
@tannevaled
tannevaled deleted the run-cmd-guardrails branch November 10, 2026 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant