From 0fb5c324d53eb637358332c964fe97d1ffa4e10b Mon Sep 17 00:00:00 2001 From: zyhou Date: Thu, 24 Oct 2024 18:10:32 +0200 Subject: [PATCH 1/2] add privacy rule for autocomplete password value --- packages/rum-core/src/domain/privacy.spec.ts | 5 +++++ packages/rum-core/src/domain/privacy.ts | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/rum-core/src/domain/privacy.spec.ts b/packages/rum-core/src/domain/privacy.spec.ts index 2155388cf5..72cb6ba123 100644 --- a/packages/rum-core/src/domain/privacy.spec.ts +++ b/packages/rum-core/src/domain/privacy.spec.ts @@ -175,6 +175,11 @@ describe('getNodeSelfPrivacyLevel', () => { html: '', expected: NodePrivacyLevel.MASK, }, + { + msg: 'is an "input" element and has an autocomplete attribute ending with "-password" (forced override)', + html: '', + expected: NodePrivacyLevel.MASK, + }, { msg: 'is an "input" element and has an autocomplete attribute not starting with "cc-"', html: '', diff --git a/packages/rum-core/src/domain/privacy.ts b/packages/rum-core/src/domain/privacy.ts index 512b65cb0b..97482a06ca 100644 --- a/packages/rum-core/src/domain/privacy.ts +++ b/packages/rum-core/src/domain/privacy.ts @@ -115,8 +115,11 @@ export function getNodeSelfPrivacyLevel(node: Node): NodePrivacyLevel | undefine return NodePrivacyLevel.MASK } const autocomplete = inputElement.getAttribute('autocomplete') - // Handle input[autocomplete=cc-number/cc-csc/cc-exp/cc-exp-month/cc-exp-year] - if (autocomplete && autocomplete.indexOf('cc-') === 0) { + // Handle input[autocomplete=cc-number/cc-csc/cc-exp/cc-exp-month/cc-exp-year/new-password/current-password] + if (autocomplete && ( + autocomplete.startsWith('cc-') || + autocomplete.endsWith('-password') + )) { return NodePrivacyLevel.MASK } } From 8816877ba520d8e4cba4372849258d1e61705424 Mon Sep 17 00:00:00 2001 From: cy-moi Date: Thu, 31 Oct 2024 11:20:00 +0100 Subject: [PATCH 2/2] Run yarn format --- packages/rum-core/src/domain/privacy.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/rum-core/src/domain/privacy.ts b/packages/rum-core/src/domain/privacy.ts index 97482a06ca..13faf19537 100644 --- a/packages/rum-core/src/domain/privacy.ts +++ b/packages/rum-core/src/domain/privacy.ts @@ -115,11 +115,8 @@ export function getNodeSelfPrivacyLevel(node: Node): NodePrivacyLevel | undefine return NodePrivacyLevel.MASK } const autocomplete = inputElement.getAttribute('autocomplete') - // Handle input[autocomplete=cc-number/cc-csc/cc-exp/cc-exp-month/cc-exp-year/new-password/current-password] - if (autocomplete && ( - autocomplete.startsWith('cc-') || - autocomplete.endsWith('-password') - )) { + // Handle input[autocomplete=cc-number/cc-csc/cc-exp/cc-exp-month/cc-exp-year/new-password/current-password] + if (autocomplete && (autocomplete.startsWith('cc-') || autocomplete.endsWith('-password'))) { return NodePrivacyLevel.MASK } }