Skip to content

Commit 8107512

Browse files
authored
feat(v8/replay): Mask srcdoc iframe contents per default (#14779)
1 parent b1d393e commit 8107512

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

packages/replay-internal/src/util/getPrivacyOptions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function getOption(selectors: string[], defaultSelectors: string[]): string {
2525
* Returns privacy related configuration for use in rrweb
2626
*/
2727
export function getPrivacyOptions({ mask, unmask, block, unblock, ignore }: GetPrivacyOptions): GetPrivacyReturn {
28-
const defaultBlockedElements = ['base[href="/"]'];
28+
const defaultBlockedElements = ['base', 'iframe[srcdoc]:not([src])'];
2929

3030
const maskSelector = getOption(mask, ['.sentry-mask', '[data-sentry-mask]']);
3131
const unmaskSelector = getOption(unmask, []);

packages/replay-internal/test/integration/integrationSettings.test.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ describe('Integration | integrationSettings', () => {
1717
it('sets the correct configuration when `blockAllMedia` is disabled', async () => {
1818
const { replay } = await mockSdk({ replayOptions: { blockAllMedia: false } });
1919

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

packages/replay-internal/test/integration/rrweb.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('Integration | rrweb', () => {
2323
});
2424
expect(mockRecord.mock.calls[0]?.[0]).toMatchInlineSnapshot(`
2525
{
26-
"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"]",
26+
"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"]",
2727
"collectFonts": true,
2828
"emit": [Function],
2929
"errorHandler": [Function],
@@ -62,7 +62,7 @@ describe('Integration | rrweb', () => {
6262

6363
expect(mockRecord.mock.calls[0]?.[0]).toMatchInlineSnapshot(`
6464
{
65-
"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"]",
65+
"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"]",
6666
"checkoutEveryNms": 360000,
6767
"collectFonts": true,
6868
"emit": [Function],

packages/replay-internal/test/unit/util/getPrivacyOptions.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('Unit | util | getPrivacyOptions', () => {
2121
}),
2222
).toMatchInlineSnapshot(`
2323
{
24-
"blockSelector": ".custom-block,.sentry-block,[data-sentry-block],base[href="/"]",
24+
"blockSelector": ".custom-block,.sentry-block,[data-sentry-block],base,iframe[srcdoc]:not([src])",
2525
"ignoreSelector": ".custom-ignore,.sentry-ignore,[data-sentry-ignore],input[type="file"]",
2626
"maskTextSelector": ".custom-mask,.sentry-mask,[data-sentry-mask]",
2727
"unblockSelector": ".custom-unblock",

0 commit comments

Comments
 (0)