fix(security): audit run-4 fixes and run-3 leftovers (#26)

Corrects passthrough metering, the cost gate, credential redaction, reload drain, response headers and the discovery cap.
This commit is contained in:
2026-11-29 10:50:36 +00:00
committed by GitHub
parent 009de03264
commit f1b198bce4
48 changed files with 3598 additions and 211 deletions
+3 -2
View File
@@ -181,6 +181,7 @@ func effectiveTTL(c *responseCache, grp *group) time.Duration {
// Body automatically (it is a []byte field), matching spec §2's "value:
// JSON {status, contentType, body(base64)}".
type cachedResponse struct {
// ContentType is upstream-chosen and replayed verbatim on a hit.
ContentType string `json:"contentType"`
Body []byte `json:"body"`
Status int `json:"status"`
@@ -459,12 +460,12 @@ func cacheKey(provider, upstreamModel, requestedModel, endpoint string, req map[
}
// normalizeBetaSet canonicalises anthropic-beta header values into one
// sorted, de-duplicated, lower-case comma list; "" when no value is set.
// sorted, de-duplicated comma list; names keep their case, as Anthropic documents the exact name as the value; "" when no value is set.
func normalizeBetaSet(values []string) string {
var parts []string
for _, v := range values {
for _, f := range strings.Split(v, ",") {
f = strings.ToLower(strings.TrimSpace(f))
f = strings.TrimSpace(f)
if f != "" {
parts = append(parts, f)
}