Repository navigation
fix(core): redact secrets from structured log output (#79) - #122
Merged
Merged
Conversation
Add a recursive redaction pass to the logger: fields under secret-shaped key names (password/token/secret/authorization/cookie/session/..., case-insensitive) are masked before serialization, nested objects and arrays are walked, and string values are scanned for embedded Bearer/Basic tokens and Authorization: values. withRequestLogging's catch block redacts error messages the same way. Regression tests: sensitive top-level field, nested token, arrays, bearer-token error message, plus emitted-line assertions.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
6 tasks
8 of 11 tasks
This branch was successfully deployed
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.
Closes #79 (redaction half)
Adds a recursive redaction pass to the structured logger:
packages/core/src/observability/redact.ts: fields under secret-shaped key names (password,token,secret,authorization,cookie,session,apiKey, ... — case-insensitive substring match) are replaced with[REDACTED], nested objects/arrays are walked recursively, and string values are scanned for embeddedBearer/Basictokens and inlineAuthorization:values.write()inlogger.tsapplies the pass to both themessageand every callerfieldsbefore serializing.withRequestLogging's catch block redacts caught-error.messagestrings before emission.@thexjs/core:isSensitiveKey,redactString,redactValue,REDACTED.This is belt-and-suspenders beside the build-time env-leak scanner: that protects client bundles; this protects server logs, in dev and prod.
Regression tests (
packages/core/src/observability/redact.test.ts): sensitive key-name matching, top-levelpasswordfield redacted in the emitted line, nestedtokenredacted, secret nested under a non-sensitive key, arrays, bearer-token error message redacted throughwithRequestLogging.Verified:
bun test(403 pass),biome check,bun run typecheckall clean.