Skip to content

Commit

Permalink
feat(v8/replay): Mask srcdoc iframe contents per default (#14779)
Browse files Browse the repository at this point in the history
  • Loading branch information
chargome authored Dec 18, 2024
1 parent b1d393e commit 8107512
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/replay-internal/src/util/getPrivacyOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function getOption(selectors: string[], defaultSelectors: string[]): string {
* Returns privacy related configuration for use in rrweb
*/
export function getPrivacyOptions({ mask, unmask, block, unblock, ignore }: GetPrivacyOptions): GetPrivacyReturn {
const defaultBlockedElements = ['base[href="/"]'];
const defaultBlockedElements = ['base', 'iframe[srcdoc]:not([src])'];

const maskSelector = getOption(mask, ['.sentry-mask', '[data-sentry-mask]']);
const unmaskSelector = getOption(unmask, []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ describe('Integration | integrationSettings', () => {
it('sets the correct configuration when `blockAllMedia` is disabled', async () => {
const { replay } = await mockSdk({ replayOptions: { blockAllMedia: false } });

expect(replay['_recordingOptions'].blockSelector).toBe('.sentry-block,[data-sentry-block],base[href="/"]');
expect(replay['_recordingOptions'].blockSelector).toBe(
'.sentry-block,[data-sentry-block],base,iframe[srcdoc]:not([src])',
);
});
});

Expand Down
4 changes: 2 additions & 2 deletions packages/replay-internal/test/integration/rrweb.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('Integration | rrweb', () => {
});
expect(mockRecord.mock.calls[0]?.[0]).toMatchInlineSnapshot(`
{
"blockSelector": ".sentry-block,[data-sentry-block],base[href="/"],img,image,svg,video,object,picture,embed,map,audio,link[rel="icon"],link[rel="apple-touch-icon"]",
"blockSelector": ".sentry-block,[data-sentry-block],base,iframe[srcdoc]:not([src]),img,image,svg,video,object,picture,embed,map,audio,link[rel="icon"],link[rel="apple-touch-icon"]",
"collectFonts": true,
"emit": [Function],
"errorHandler": [Function],
Expand Down Expand Up @@ -62,7 +62,7 @@ describe('Integration | rrweb', () => {

expect(mockRecord.mock.calls[0]?.[0]).toMatchInlineSnapshot(`
{
"blockSelector": ".sentry-block,[data-sentry-block],base[href="/"],img,image,svg,video,object,picture,embed,map,audio,link[rel="icon"],link[rel="apple-touch-icon"]",
"blockSelector": ".sentry-block,[data-sentry-block],base,iframe[srcdoc]:not([src]),img,image,svg,video,object,picture,embed,map,audio,link[rel="icon"],link[rel="apple-touch-icon"]",
"checkoutEveryNms": 360000,
"collectFonts": true,
"emit": [Function],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('Unit | util | getPrivacyOptions', () => {
}),
).toMatchInlineSnapshot(`
{
"blockSelector": ".custom-block,.sentry-block,[data-sentry-block],base[href="/"]",
"blockSelector": ".custom-block,.sentry-block,[data-sentry-block],base,iframe[srcdoc]:not([src])",
"ignoreSelector": ".custom-ignore,.sentry-ignore,[data-sentry-ignore],input[type="file"]",
"maskTextSelector": ".custom-mask,.sentry-mask,[data-sentry-mask]",
"unblockSelector": ".custom-unblock",
Expand Down

0 comments on commit 8107512

Please sign in to comment.