Repository navigation
fix(networking): never carry a webui request's custom headers to another origin - #1787
Conversation
|
Important Review skippedWe couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
[High impact] The PR appears safe to merge; no actionable new defects were found.
|
…1789) ## Linked issue No issue: a maintainer-requested chore. ## What changed About 10% of our Swift was comments (28,500 of them, 29,000 lines). Most restated the code, a few gave cover to shortcuts, and the ones that recorded a real decision were scattered where nobody looks for decisions. This PR deletes them and bans new ones. - **Every comment was classified** as a tautology, stale, an excuse, or a decision record. The decision records are now 180 ADRs holding 979 decisions under `docs/adr/` (format in `docs/adr/README.md`). The excuses became #1781, #1782, #1783, #1784 and #1785. - **The comments are gone**: 29,032 lines across 665 Swift files. Two third-party licence notices stay (`ReviewDiffCanvasView.swift`, `BotProfileAppearance.swift`) because no file in `ThirdPartyNotices/` covers them yet, and so do the `// test-wait:` annotations `ci/check_test_waits.py` reads. - **`ci/check_comments.py` fails a Swift file that gains a comment.** It runs in Tooling Tests. `ci/comment_baseline.txt` lists the two files that still hold comments; a count there only goes down, and a pull request cannot raise it past the target branch's. - **The `delete-comment` skill** (`.agents/skills/delete-comment`, linked from `.claude/skills`) repeats the sweep for whatever is left. `.gitignore` now tracks repo skills. - **`AGENTS.md`** states the rule in Taste and points decisions at `docs/adr/`. Nothing but comments and the blank lines around them changes in Swift. ## How it was tested - **Only comments changed.** An oracle built on the toolchain's SwiftParser compared the token stream of all 701 Swift files with `master`'s: none differ. The only comment trivia it finds at this head are the 26 licence lines and 15 `// test-wait:` lines. - **The checker finds what Swift finds.** Its scanner and SwiftParser agree on every one of the 28,507 comments in the 701 files at the base. - `python3 -m unittest discover -s ci -p 'test_*.py'`: 21 passed. `python3 ci/check_comments.py` and `python3 ci/check_test_waits.py` pass. - `scripts/test-sim` on iPhone 17e, after the rebase onto current `master`: 246 passed, 0 failed. The selection is the classes that read source-relative fixtures or had a `test-wait` annotation rewritten, plus the files `master` changed under the rebase: `HermesSlashCommandTests`, `HermesInsightsClientTests`, `HermesChatSettingsTests`, `LocalizationCatalogTests`, `HermesAgentFixtureTests`, `SSEClientTests`, `KanbanLiveUpdateTests`, `CronManagementModelTests`, `CronManagementViewModelTests`, `HermesCronClientTests`, `HermesConversationTests`, `HermesBranchDuplicateTests`, `ToolCallSummaryFormatterTests`. The full suite is left to this PR's CI. ## Checklist - [x] Local validation passes using `scripts/test-sim <assigned-simulator-udid>` with the tests required by `AGENTS.md` § Verifying; the selection and results are recorded above - [x] New/changed `Codable` models decode tolerantly (none changed) - [x] No new third-party dependencies (the list in `AGENTS.md` is locked) - [x] No invented API endpoints or JSON shapes (none touched) Reviewed with sol-loop: 3 rounds with gpt-6.2-sol on high. Sol verdict: changes requested in round 3 (a regex literal after a comment, stray `test-wait` annotations, paths outside the checkout); all fixed in the last commit, which Sol has not re-reviewed. Created with Claude Fable 5.2 in Claude Code (T3 Code). Classification and ADR drafting by Claude Opus 5.5 subagents. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
…ross-origin redirects Fixes #1781 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0e00419 to
a5a813a
Compare
Linked issue
Fixes #1781
What changed
A webui request in flight when the user signed out, switched server, or edited a header could carry its custom headers (often a proxy secret) to another origin. The redirect guard looked up the header names to strip when the redirect arrived, and by then the store held another server's headers or none.
Each request now snapshots its headers once, applies them, and gets a redirect guard built from exactly those headers (
CrossOriginHeaderStripper(baseURL:sentHeaders:)). Same-origin redirects keep their headers, and a cross-origin redirect of anything but GET or HEAD is still refused.HermesConnectionalready built its guard from the headers it admitted, and it now uses the same initializer. ADR 0095 now records the rule.How it was tested
testStripsSentHeaderOnRedirectAfterTheStoreIsReplacedreplaces the header store before the mock redirects to another host. It failed on the base (X-Api-Key: k1reached the new origin) and passes with the fix.scripts/test-sim <udid> --onlyonCrossOriginRedirectHeaderTests,CustomHeaderAPIClientInjectionTests,CustomHeaderModelTests,CustomHeaderSSEInjectionTests,CustomHeaderAuthManagerTests,HermesConnectionTests: all pass.python3 ci/check_comments.py,python3 ci/check_test_waits.py,python3 -m unittest discover -s ci -p 'test_*.py': pass.Checklist
scripts/test-sim <assigned-simulator-udid>with the tests required byAGENTS.md§ Verifying; the selection and results are recorded aboveCodablemodels decode tolerantly (optionals for fields the server might add or rename)AGENTS.mdis locked)Reviewed with sol-loop: 1 round with gpt-6.2-sol. Sol verdict: approved
Created with Claude Opus 5.5 in Claude Code (T3 Code).
🤖 Generated with Claude Code