Files
magpie/internal/redact
ggbdpq 9a05a7bcec redact: the mask covers ark- keys, _KEY/_PASS names, auth headers, and JSON field names (#2946)
What changed (one per gap the reporter reproduced on main):

- API_KEY gains the ark- value shape (#2946): Volcano Ark and the relays
  in front of it issue keys with an ark- prefix, and no value rule knew
  one. ARK_API_KEY=<ark key> was masked already (its name has api_key in
  it); ARK_KEY=<ark key>, a key in prose and one in a request body went
  as they were.
- A new SECRET rule takes an upper-case env var whose name only ends in
  KEY or PASS: SERVICE_X_KEY=…, FOO_KEY=…, DB_PASS=… — quoted or not.
  Upper case is the boundary: in the lower case a name that ends in key
  is code's (a sort_key:, a cache_key:, a public key =), so nothing of
  TestMaskGatewayKey's rows moves; notAPlainKey turns the upper-case
  SORT_KEY/PUBLIC_KEY/PROMPT_CACHE_KEY/CACHE_KEY away too.
- A new SECRET rule takes the value of an Authorization: or Cookie:
  header line, whatever it looks like — the opaque bearer tokens and
  session values the shape rules had no eye for (#2946).
- MaskJSON masks the value of a field named for a secret by its name,
  before the ids and names that would keep it: {"api_key": "…"} with a
  value no rule knows, {"db_pass": "…"}, an AKIA under access_key_id
  (its _id kept it from the value's own AKIA rule), {"Authorization":
  "Bearer …"} and {"Cookie": "…"} (#2946). signature,
  encrypted_content and data: values still go as written (#1911), and
  the tools' definitions are untouched. SecretName now says a name
  ending in pass is a secret's name too, so the archive (ScrubJSON) and
  MaskJSON judge a field by the same names.

Why: the reporter's five examples each leak a credential whose value has
no key's shape; the rules judged values by shape alone and field names
only ever kept a value. The boundary the reporter warned about —
sort_key, cache_key, prompt_cache_key, public_key must stay unmasked —
is held by case (lower-case names never enter the new rules) and by
notAPlainKey for the upper-case ones.

Run (rebased onto 9ae79122, upstream/main 10-27): the 18 upstream redact commits since
9b0f4861 (714ab8e8 CJK password rule .. 25341b4c address narrowing) add CJK-named
secret rules, made-up key forms and narrow emails and addresses — none covers
the five families here, so the rules take them side by side; the shared
secretNames rule carries upstream's new notCode boundary (511c4a76). The
_KEY/_PASS rule's boundary is notPlainKeyOrCode (plain key names and code
naming a secret both stay), the same resolution 2ea09ec3 on
codex/verify-2946-redact carried and the issue thread endorsed:
Refs #2946

Review: the ark- key, _KEY/_PASS assignment and Authorization/Cookie
rules land as written here. Two parts were narrowed in this batch's
redact follow-up ("a secret's field name masks only in a tool's
arguments"): a secret's JSON field name now masks only where the user's
data sits (a tool call's arguments and a tool's result, with secrets
on), never across the whole body by name, and an Authorization or Cookie
line masks only when what follows has a credential's shape. None of the
redact commits on main since 10-27 covered these five families.

Landing record (yetone):
Run at the pushed batch head (tree a6b084d0b, on origin/main 616405061),
go1.26.8:
- go test -count=1 -timeout 45m on Linux (wsl-run) of internal/gateway,
internal/redact, internal/provider and internal/plugin (this batch's
packages and those main changed since the full run): all ok. gofmt -l
clean; go vet ./... (darwin), GOOS=linux and GOOS=windows go vet -tags
nogui ./... clean. internal/gui on macOS (mote-run):
TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestMainWindowCorners
(#3949), both red at main too.
- The full go test ./... -timeout 45m -count=1 ran one rebase earlier,
at tree 66a7a4c17 on origin/main 3a3bdb9f2 (main then gained 5bfa9f076's
group stand-in, b19d08593, f856d381a and 616405061). It ran on Linux
(wsl-run): 82 packages ok. internal/agent has 4 reds, all red at
origin/main on that box as well: TestInstalledVersion,
TestGrokInstalled, TestOmpDetectedWithPiDir and
TestCopilotFolderFromAnIDEPluginIsNotTheCLI (#4033, #3548). The root
package and internal/cli need gtk4 to build, so they ran on macOS
(mote-run): ok. TestColdTurnsTaken (#4510) was red there once. An
earlier full run at base d307aa648 was red once in
TestUnroutedHeldReportSaved (#4300), which passes 5 of 5 alone at both
the head and main.
- Each landed patch's diff matches the head ggbdpq posted last on its
issue (patch-id).
- No GUI file is touched, so no GUI test file was run.
Broken by hand: gua's ablations, in the thread. The narrowing is broken
by hand in that follow-up.
Not tried: a real vendor request carrying these values through the
gateway; the rules were tested in internal/redact only.

Review: the ark- key, _KEY/_PASS assignment and Authorization/Cookie
rules land as written here. Two parts were narrowed in this batch's
redact follow-up ("a secret's field name masks only in a tool's
arguments"): a secret's JSON field name now masks only where the user's
data sits (a tool call's arguments and a tool's result, with secrets
on), never across the whole body by name, and an Authorization or Cookie
line masks only when what follows has a credential's shape. None of the
redact commits on main since 10-27 covered these five families.

Landing record (yetone):
Run at tree 7d7955eb9 (this batch on origin/main 3cfba2e37), go1.26.8:
- go test -count=1 -timeout 45m on Linux (wsl-run) of internal/gateway,
internal/redact, internal/provider, internal/agent and internal/usage
(this batch's packages, plus those main changed since the full run): all
ok except internal/agent's TestInstalledVersion, TestGrokInstalled and
TestOmpDetectedWithPiDir, red at origin/main on that box too (#4033,
#3548). gofmt -l clean; go vet ./... (darwin), GOOS=linux and
GOOS=windows go vet -tags nogui ./... clean. On macOS (mote-run), the
root package and internal/cli ok; internal/gui red in
TestSettingsSaveKeepsWhatItDoesNotSend (#4514), TestMainWindowCorners
(#3949) and TestColdTurnsTaken (#4510), the first two red at main too.
- The full go test ./... -timeout 45m -count=1 ran two rebases earlier,
at tree 66a7a4c17 on origin/main 3a3bdb9f2, on Linux (wsl-run): 82
packages ok, internal/agent's 4 reds as above, plus
TestCopilotFolderFromAnIDEPluginIsNotTheCLI (#4033, red at main). The
root package, internal/cli and internal/gui need gtk4 to build, so they
ran on macOS as above. An earlier full run at base d307aa648 was red
once in TestUnroutedHeldReportSaved (#4300), which passes 5 of 5 alone
at both the head and main.
- Each landed patch's diff matches the head ggbdpq posted last on its
issue (patch-id).
- No GUI file is touched, so no GUI test file was run.
- Rebased after these runs onto origin/main c1457f2ee. Its two commits
since 3cfba2e37 (3f2faef62 gui, c1457f2ee agent) touch neither
internal/gateway nor internal/redact, nor any file this batch changes,
and were not run again here.
Broken by hand: gua's ablations, in the thread. The narrowing is broken
by hand in that follow-up.
Not tried: a real vendor request carrying these values through the
gateway; the rules were tested in internal/redact only.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 06:38:00 +08:00
..
gateway: a request archive, off unless turned on, keeps each call's headers and bodies in the user's own S3 bucket and a recent call reads its own back (Jorben on Discord: 请求存档) — the Gateway page's recent calls only ever held the last bodies in memory, the first 256 KB of each, with no headers, gone at a restart. A switch over Recent calls ("Request archive", POST /api/settings/archive, settings' requestArchive) turns it on, refused with a reason while sync isn't set up with an s3:// bucket; with it on, each call the gateway serves gets an id (UTC HHMMSS-<16 hex>, said back in X-Magpie-Archive-Id) and, once it is recorded, its method, path and query, request headers and body and response status, headers and body go as one JSON file to <prefix>/magpie/archive/<YYYY-MM-DD>/<id>.json in the bucket sync keeps its backup in, signed with the same client (davsync.Bucket, no new SDK). Before anything leaves, Authorization, x-api-key, Cookie, Set-Cookie, any header or JSON field or query parameter named for a key, token, secret or password, and anything that looks like a key or token anywhere in the text (the redaction rules' patterns, in a stream's data lines too) become [REDACTED] — gone, no placeholder kept; the archive is plain JSON, readable in the bucket, not sealed with the passphrase. Uploads go one at a time on their own goroutine from a queue of 16 calls, each body capped at the 256 KB the call already keeps and marked truncated; a full queue drops the call with a log line, a failed upload is logged and shown under the switch until the next one goes, and no request waits on any of it. A recent call the archive kept shows its date and id under its bodies, and "Fetch from archive" (GET /api/archive?date=&id=, only a date and an id of that shape) shows the request's and response's headers and bodies as the bucket has them, or says it isn't there yet. The hook is in record() and the Call literal, so PR #239's request log lines are not touched; the archived call carries its usage, and with #239 its vendor request id. Only calls through serve() are archived, not Codex's backend, image or video calls. TestArchiveOn, TestArchiveOff, TestArchiveName, TestRequestArchiveToS3 (a real gateway request through the signature-checking fake S3), TestScrub and request-archive.test.cjs fail without the change; TestSettingsSaveKeepsWhatItDoesNotSend now sets requestArchive. A sandbox magpie web with a fake vendor and a fake S3 server uploaded nothing while off; on, it uploaded a signed archive with none of eight planted secrets in it, read it back through /api/archive and in the page, and with the S3 server down served the call in 0.1 s and said why the upload failed. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass (Claude account tests and TestClaudeRunEndsWhenTheClientLeaves pass alone); request-archive, click-scroll, old-webkit, sse-body, gateway-fold pass.
2026-10-01 17:13:34 +08:00