fix(GRO-2299): redact googleMapsApiKey from PATCH /api/admin/settings response #195
Reference in New Issue
Block a user
Delete Branch "gro-2299-redact-patch-settings"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
GRO-2299 — Redact googleMapsApiKey from PATCH /api/admin/settings (symmetric with GRO-2294 GET fix)
LOW / defense-in-depth follow-up surfaced by the GRO-2298 security review.
Problem
redactSettings()(added in GRO-2294) was applied only to GET/api/admin/settings. The sibling PATCH handler returned the full row via.returning()without redaction, so a settings PATCH echoed the encryptedgoogleMapsApiKeyciphertext back to the caller.Fix
src/routes/settings.ts: add a!updatedguard and wrap the PATCH return in the existingredactSettings(updated)helper, so redaction is symmetric across all settings responses.src/__tests__/settings.test.ts: newPATCH /settingsdescribe block asserting the response omitsgoogleMapsApiKey(existing-row and auto-create-then-update branches) while still returning non-secret updated fields.googleMapsApiKey, mirroring TC-API-13.1.Verification (local)
pnpm typecheck— cleanpnpm vitest run src/__tests__/settings.test.ts— 4 passedRisk: LOW. Endpoint is
requireSuperUser()-gated; value is AES-256-GCM ciphertext, not plaintext; not a regression.Source review: GRO-2298. Parent: GRO-2294.
Co-Authored-By: Paperclip noreply@paperclip.ing