Layer's browser takes wildcards in the sites agents may use and in saved sign-ins #65

Manually merged
code-villain merged 1 commit from michael/github-pr-11 into main 2026-11-27 21:04:09 +01:00 AGit
Owner

From https://github.com/code-villain-hq/vault/pull/11 by @frazer84.

What changes

  • Sites agents may use (Settings → Browser, browser_request_site): a site can hold a *, which stands for any run of letters, digits and dashes within one name, e.g. pr-*.example.com. It allows pr-12.example.com and its subdomains, as a site already covers its subdomains. A leading *. behaves as before: it is dropped, since example.com already covers *.example.com.
  • Saved sign-ins: a sign-in can be saved for *.staging.example.com or pr-*.example.com, and is filled on every host it stands for. Sign-ins still treat subdomains as other sites, so a * covers exactly one name: *.staging.example.com is not staging.example.com, nor a.b.staging.example.com. Port rules are unchanged.
  • When a written-out sign-in and a wildcard one both fit a page, the written-out one's account is used unless the agent asks for a username.
  • A * may only stand in front of the domain. *, *.com, example.*, ex*.com and a.*.com are refused as sites. Under .localhost anything goes, since it is all this machine.
  • The Settings hints and the browser_request_site description say so. BRW-3 and BRW-18 in docs/features.md are updated.

Why

Preview and per-branch environments (pr-123.dev.example.com, feature-x.staging.example.com) each have their own host. You had to allow every new one, which subdomain coverage only fixes when they share a parent, and save its test account again for each host, since a sign-in is tied to one host. A wildcard does both once.

The guard on where * may go is what keeps BRW-3 and BRW-19 meaningful. A wildcard that could stand in the domain (example.*) would let an agent browse, or have a test password filled on, a domain somebody else owns. With the domain written out, a wildcard only reaches hosts under a domain the user named. Password filling keeps its other rules: only into a password field, and never over plain http off this machine.

How it was checked

From code/apps/layer:

  • bun run check: every step passes up to cargo test (server), including guard, vp check, build, cargo fmt, cargo clippy -D warnings, and cargo test (app) (986 passed). cargo test (server) fails on its 12 Postgres-backed tests with failed to connect to setup test database: PoolTimedOut, because this Mac has no local Postgres. They fail the same way on main.
  • I ran the steps after that by hand, and they pass: generated types are current (no diff), bun test in web and both kits, and the web build.
  • New unit tests:
    • sites.rs: wildcard matching within one name, subdomains of a wildcard site, lookalikes (evil-pr-1.example.com, pr-1.example.com.evil.test), and refused broad patterns.
    • sign_in.rs: wildcard sites with and without a port, one name only, and *.localhost on any port.
  • I haven't tried it in the running app.

🤖 Generated with Claude Code

https://claude.ai/code/session_01P8G9Kc8iSELqvWGnZtW2wm

From https://github.com/code-villain-hq/vault/pull/11 by @frazer84. ## What changes - **Sites agents may use** (Settings → Browser, `browser_request_site`): a site can hold a `*`, which stands for any run of letters, digits and dashes within one name, e.g. `pr-*.example.com`. It allows `pr-12.example.com` and its subdomains, as a site already covers its subdomains. A leading `*.` behaves as before: it is dropped, since `example.com` already covers `*.example.com`. - **Saved sign-ins**: a sign-in can be saved for `*.staging.example.com` or `pr-*.example.com`, and is filled on every host it stands for. Sign-ins still treat subdomains as other sites, so a `*` covers exactly one name: `*.staging.example.com` is not `staging.example.com`, nor `a.b.staging.example.com`. Port rules are unchanged. - When a written-out sign-in and a wildcard one both fit a page, the written-out one's account is used unless the agent asks for a username. - A `*` may only stand in front of the domain. `*`, `*.com`, `example.*`, `ex*.com` and `a.*.com` are refused as sites. Under `.localhost` anything goes, since it is all this machine. - The Settings hints and the `browser_request_site` description say so. BRW-3 and BRW-18 in `docs/features.md` are updated. ## Why Preview and per-branch environments (`pr-123.dev.example.com`, `feature-x.staging.example.com`) each have their own host. You had to allow every new one, which subdomain coverage only fixes when they share a parent, and save its test account again for each host, since a sign-in is tied to one host. A wildcard does both once. The guard on where `*` may go is what keeps BRW-3 and BRW-19 meaningful. A wildcard that could stand in the domain (`example.*`) would let an agent browse, or have a test password filled on, a domain somebody else owns. With the domain written out, a wildcard only reaches hosts under a domain the user named. Password filling keeps its other rules: only into a password field, and never over plain `http` off this machine. ## How it was checked From `code/apps/layer`: - `bun run check`: every step passes up to `cargo test (server)`, including guard, `vp check`, build, `cargo fmt`, `cargo clippy -D warnings`, and `cargo test (app)` (986 passed). `cargo test (server)` fails on its 12 Postgres-backed tests with `failed to connect to setup test database: PoolTimedOut`, because this Mac has no local Postgres. They fail the same way on `main`. - I ran the steps after that by hand, and they pass: generated types are current (no diff), `bun test` in web and both kits, and the web build. - New unit tests: - `sites.rs`: wildcard matching within one name, subdomains of a wildcard site, lookalikes (`evil-pr-1.example.com`, `pr-1.example.com.evil.test`), and refused broad patterns. - `sign_in.rs`: wildcard sites with and without a port, one name only, and `*.localhost` on any port. - I haven't tried it in the running app. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01P8G9Kc8iSELqvWGnZtW2wm
A `*` stands for any run of letters, digits and dashes within one name in
front of a site's domain: `pr-*.example.com` allows every preview
environment, and a sign-in saved for `*.staging.example.com` is filled on
each of them. A `*` never stands in the domain itself (`*.com`,
`example.*`), so a wildcard cannot take in sites nobody meant. When a
written-out sign-in and a wildcard one both fit a page, the written-out one
is used unless the agent names another account.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P8G9Kc8iSELqvWGnZtW2wm
code-villain manually merged commit 1cb201c1fb into main 2026-11-27 21:04:09 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
code-villain/vault!65
No description provided.