Skip to content

fix(core): redact secrets from structured log output (#79) - #122

Merged
abdelkabirouadoukou merged 1 commit into
mainfrom
fix/79-log-redaction
Aug 19, 2026
Merged

abdelkabirouadoukou merged 1 commit into
mainfrom
fix/79-log-redaction

Conversation

@abdelkabirouadoukou

Copy link
Copy Markdown
Member

Closes #79 (redaction half)

Adds a recursive redaction pass to the structured logger:

  • New 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 embedded Bearer/Basic tokens and inline Authorization: values.
  • write() in logger.ts applies the pass to both the message and every caller fields before serializing.
  • withRequestLogging's catch block redacts caught-error .message strings before emission.
  • New exports from @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-level password field redacted in the emitted line, nested token redacted, secret nested under a non-sensitive key, arrays, bearer-token error message redacted through withRequestLogging.

Verified: bun test (403 pass), biome check, bun run typecheck all clean.

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.
@vercel

vercel Bot commented Aug 19, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
thexjs-basic Ready Ready Preview Aug 19, 2026 8:49am
x Ready Ready Preview Aug 19, 2026 8:49am

This branch was successfully deployed

2 active deployments
Preview – x — 14b001cd Deployed Aug 19, 2026 by vercel[bot]
Preview – thexjs-basic — 14b001cd Deployed Aug 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(core): OpenTelemetry tracing correlation + log redaction

1 participant