Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use sanitizeFilepath when logging Sentry breadcrumbs #95

Merged
merged 1 commit into from
May 7, 2024

Conversation

derekblank
Copy link
Contributor

@derekblank derekblank commented May 7, 2024

Related to #78 and https://github.com/Automattic/dotcom-forge/issues/6701
While reviewing Sentry logs, I noted that there is an additional place where filepaths need to be redacted.

Proposed Changes

Adds to the behavior introduced in #78 that sanitizes userpaths in console.log statements. This pr adds the same sanitizeUserpath util to filepath values when logging Sentry breadcrumbs, too.

Testing Instructions

When running locally, log out the value of sanitizeUserpath when Sentry.addBreadcrumb is logged during user data loading:

if ( err instanceof SyntaxError ) {
Sentry.addBreadcrumb( {
data: {
fileContents: sanitizeUnstructuredData( asString ),
filePath: sanitizeUserpath( filePath ),
},
} );
}

The value of filepaths should appear as [REDACTED]. Example error session where console.log events are using sanitizeUserpath, and Sentry.addBreadcrumb events are not (marked "generic" in the event logs).

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

@derekblank derekblank added the [Type] Enhancement Improvement upon an existing feature label May 7, 2024
@derekblank derekblank requested review from dcalhoun and a team May 7, 2024 09:27
@derekblank derekblank self-assigned this May 7, 2024
Copy link
Member

@dcalhoun dcalhoun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logged values were now redacted in my testing. Thanks!

@dcalhoun dcalhoun merged commit 3600d89 into trunk May 7, 2024
13 checks passed
@dcalhoun dcalhoun deleted the fix/sanitize-userpath-breadcrumb branch May 7, 2024 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement Improvement upon an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants