Uh oh!
There was an error while loading. Please reload this page.
feat: add sensitive struct - #41
Conversation
e0df198 to
2a040a5CompareThere was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d5a2529. Configure here.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| // Copy Symbol-keyed properties from `props` so that brands set on an inner | ||
| // struct (e.g. the sensitive marker) are automatically inherited by any | ||
| // wrapper that spreads the struct into a new constructor call. | ||
| for (const sym of Object.getOwnPropertySymbols(props)) { | ||
| Object.defineProperty( | ||
| this, | ||
| sym, | ||
| // No need to check for undefined, since we are iterating over | ||
| // `Object.getOwnPropertySymbols`. | ||
| Object.getOwnPropertyDescriptor(props, sym) as PropertyDescriptor, | ||
| ); | ||
| } |
There was a problem hiding this comment.
This is necessary to forward the brand (marker) inside structs when we are re-constructing them.
Type-wise, that does not change anything, those are just plain symbols that are used as markers for us to detect later if a re-constructed struct was banded as sensitive (we could use this same logic for other kind of decorators in the future too).
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com>
Uh oh!
There was an error while loading. Please reload this page.

Add a new struct
sensitivethat can used withobjectortype. Any value for this field will get redacted automatically if any validation/errors happen.This also apply if a sibling field validation is failing, so there's no way to make the value escape out of the actual payload being validated.
Note
Medium Risk
Changes the validation error surface for object schemas and failure messages, which is security-relevant for secret handling but is additive and covered by extensive validation tests.
Overview
Adds a
sensitive()wrapper so validation failures replace the real value with***inStructErrormessages,value, andbranch, including refiner failures where the default message would otherwise echo the secret.object()andtype()now detect branded sensitive fields and wrap sibling entry structs so when another key fails, the parent object inbranchis shallow-copied with sensitive keys redacted (usingcontext.branchso this still works under coercion).Structcopies Symbol-keyed brands when wrappers spread an inner struct, sooptional/exactOptionalcompositions keep the sensitive marker without extra changes.Also exports
isSensitiveStructand documents the feature in the changelog.Reviewed by Cursor Bugbot for commit 9ba5b1c. Bugbot is set up for automated code reviews on this repo. Configure here.