chore: Sensitive data refactor part 3#2888
Closed
luke-belton wants to merge 4 commits intoluke/sensitive-data-2from
Closed
chore: Sensitive data refactor part 3#2888luke-belton wants to merge 4 commits intoluke/sensitive-data-2from
luke-belton wants to merge 4 commits intoluke/sensitive-data-2from
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📝 No Changeset FoundThis PR doesn't include a changeset. A changeset (and the release label) is required to release a new version. How to add a changesetRun this command and follow the prompts: pnpm changesetRemember: Never use |
Contributor
Contributor
|
Size Change: +3.09 kB (+0.05%) Total Size: 5.76 MB
ℹ️ View Unchanged
|
Contributor
|
This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the |
Contributor
|
This PR was closed due to lack of activity. Feel free to reopen if it's still relevant. |
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.
Problem
Building off #2647 and the feedback at https://posthog.slack.com/archives/C075D3C5HST/p1764603130371689.
Follows #2887.
In summary, #2647 identified issues with sensitive data detection:
Inconsistent approach to identifying/blocking capture of sensitive data
The old
shouldCaptureElementregex would identify sensitive data and block attribute capture, but still expose the same elements (including attributes) in$elements_chain. This created a false sense of security while still leaking sensitive data.False Positives from Substring Matching
The sensitive name regex used substring matching, causing legitimate elements to be incorrectly flagged:
<a id="password" href="/reset">Reset password</a>would have its href blockedUsers couldn't customize which field names should be considered sensitive, forcing them to rely on our one-size-fits-all heuristics.
Changes
This PR completes the 3-stage sensitive data refactor:
New Configuration Options (for defaults >= '2025-12-11')
sensitive_data_detection: {
allowedInputTypes: string[] // Default: ['button', 'checkbox', 'submit', 'reset']
sensitiveNameRegex?: RegExp // Custom regex (replaces default pattern)
}
Fixed Regex False Positives
All functions now receive full PostHogConfig:
This enables defaults-based branching: config.defaults >= '2025-12-11'
isSensitiveElementhandles all sensitive element detectionallowedInputTypesfor opt-in inputssensitiveNameRegexfor field namesdoesCaptureElementHaveSensitiveDatamaintains backward compatibilitydoesCaptureElementHaveSensitiveDatawith JSDoc annotationFor defaults >= '2025-12-11',
getAugmentPropertiesFromElementnow uses an opt-in model:ph-no-captureclass (respects explicit opt-out)isSensitiveElementfor augment propertiesBehavior Changes
For users with defaults: '2025-12-11' or later:
sensitiveNameRegexoption$elements_chainFor users with older defaults we maintain the existing behavior for backward compatibility.
Release info Sub-libraries affected
Libraries affected
Checklist
If releasing new changes
pnpm changesetto generate a changeset file