feat: add sensitive struct#41
Open
ccharly wants to merge 15 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
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 failure payloads and messages for schemas using sensitive fields—intentional for security but may break consumers that logged full values; validation semantics are unchanged.
Overview
Adds
sensitive(), a struct wrapper that keeps validation behavior the same but replaces secret material in failures with***(SENSITIVE_REDACTED) invalue, defaultmessage, andbranch(including nested entry failures and refiner names without leaking the raw value).object()andtype()now detect sensitive-marked fields and wrap sibling entry structs so when another field fails, parent objects inbranchare shallow-copied with sensitive keys redacted; this usescontext.branchso coercion does not break reference matching.The
Structconstructor copies Symbol-keyed properties from spread props so brands (e.g. afteroptional) still propagate. Public exports includesensitiveandSENSITIVE_REDACTED; changelog and validation tests cover siblings, coercion, exactOptional, outersensitive(object(...)), and non-plain objects.Reviewed by Cursor Bugbot for commit 37ec520. Bugbot is set up for automated code reviews on this repo. Configure here.