Repository navigation
Conversation
Add a shared redact()/safeStringify() helper in lambda/shared/utils.ts and apply it to the request-entry console.log(event) calls across api-ingest, api-devices, api-config, api-commands, api-notehub, and api-public-device. Previously these handlers logged the full API Gateway event (including the Authorization bearer JWT and raw request bodies with Wi-Fi SSID/passwords) to CloudWatch. The helper recursively masks sensitive headers/fields and inline Bearer tokens without mutating the input. Adds utils.test.ts. Closes review finding M15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
M15 — Redact Authorization JWT and request bodies from CloudWatch logs
Finding: Several handlers ran
console.log('...', JSON.stringify(event))atentry, writing the full API Gateway event — including the
Authorizationbearer JWT and raw request bodies (Wi-Fi SSID/passwords, etc.) — to CloudWatch
(14-day retention).
Affected handlers:
api-ingest(120, 136),api-devices(37),api-config(92),api-commands(117),api-notehub(118),api-public-device(29).Fix
redact()/safeStringify()helper inlambda/shared/utils.ts:authorization,cookie,x-api-key, security/session tokens) case-insensitively.password,secret,token,*_token,api_key,ssid,wifi,credentials, …).Bearer <token>substrings inside string values.JSON.stringify(event)calls in all six handlerswith
safeStringify(event).Tests
lambda/shared/utils.test.tscovers header redaction (both casings),body-field redaction, nested/array redaction, inline bearer masking,
primitive pass-through, and non-mutation.
Verification
npm run build— passes (tsc clean).npm test— 464 passed (33 files).Closes review finding M15