fix(gateway): allow the document write under named-origin CORS #6038
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.40) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 296 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.341
Real PR Conversation Timeline
1 comments
"Review active on #6038"
general
weight: 0.35
claude[bot]
Description
Problem
The list policy of
--cors-allowed-originsallowed GET, POST, PATCH, DELETE and OPTIONS. It allowed the content-type, authorization, Anthropic and trace headers, and exposed the request id and the trace context. A browser client under a named origin could not replace the tenant rate-limit document. Its preflight asked forPUTandIf-Matchand got neither, and an answer'sETagand revision were unreadable.Solution
The list policy allows
PUTandIf-Match. It exposesETagand the revision header under the one name the document route defines, which its parent module now reads. The wildcard policy was open already. The list policy covers every route, so a named origin may now sendPUTandIf-Matchanywhere. A named origin is operator-configured. One test drives a preflight and a plain request through the layer.Changes
model_gateway/src/server.rs:create_cors_layerallowsPUTandIf-Matchand exposesETagand the revision header.model_gateway/src/server.rs: the testconfigured_cors_allows_the_document_write.model_gateway/src/server/rate_limit_document.rs: the revision header constant is visible to the server module.Test Plan
cargo test -p smg --lib -- server::: 62 passed, three runs.cargo test -p smg --test security_tests -- rate_limit_document: the document route's tests pass once.cargo clippy -p smg --all-targets -- -D warnings,cargo fmt --checkandcargo doc -p smgwith warnings denied: clean.server.rsrestored after each.PUTdropped: the new test red.If-Matchdropped: red.ETagand the revision header dropped: red.Numbers
| measure | before | after |
|---|---|---|
| methods the list policy allows | 5 | 6 |
| request headers the list policy allows | 6 | 7 |
| response headers the list policy exposes | 4 | 6 |
| server module unit tests | 61 | 62 |
| mutants of the list policy the suite catches | 0 of 3 | 3 of 3 |
The table shows the document write and its headers under named-origin CORS, each pinned by a test.
Release note
A browser client under a named CORS origin can replace the tenant rate-limit document and read its ETag and revision.