feat: add sensitive struct#41
Open
ccharly wants to merge 17 commits into
Open
Conversation
e0df198 to
2a040a5
Compare
There 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.
ccharly
commented
Jul 3, 2026
Comment on lines
+74
to
+85
| // 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, | ||
| ); | ||
| } |
Author
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).
hmalik88
reviewed
Jul 7, 2026
hmalik88
reviewed
Jul 7, 2026
hmalik88
reviewed
Jul 7, 2026
hmalik88
reviewed
Jul 7, 2026
hmalik88
reviewed
Jul 8, 2026
1 task
Mrtenz
reviewed
Jul 13, 2026
Mrtenz
reviewed
Jul 15, 2026
Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com>
Mrtenz
approved these changes
Jul 15, 2026
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.

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.