Skip to content

Commit

Permalink
[Security solution] Remove extra data from tracking clicks (#164378)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephmilovic authored Sep 14, 2023
1 parent cfd65eb commit 14af57b
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,17 @@
import { fromEvent } from 'rxjs';
import type { AnalyticsClient } from '@kbn/analytics-client';

/** HTML attributes that should be skipped from reporting because they might contain user data */
const POTENTIAL_PII_HTML_ATTRIBUTES = ['value'];
/** HTML attributes that should be skipped from reporting because they might contain data we do not wish to collect */
const HTML_ATTRIBUTES_TO_REMOVE = [
'data-href',
'data-ech-series-name',
'data-provider-id',
'data-rfd-drag-handle-draggable-id',
'data-rfd-droppable-id',
'data-rfd-draggable-id',
'href',
'value',
];

/**
* Registers the event type "click" in the analytics client.
Expand Down Expand Up @@ -71,7 +80,7 @@ function getTargetDefinition(target: HTMLElement): string[] {
...(target.parentElement ? getTargetDefinition(target.parentElement) : []),
target.tagName,
...[...target.attributes]
.filter((attr) => !POTENTIAL_PII_HTML_ATTRIBUTES.includes(attr.name))
.filter((attr) => !HTML_ATTRIBUTES_TO_REMOVE.includes(attr.name))
.map((attr) => `${attr.name}=${attr.value}`),
];
}

0 comments on commit 14af57b

Please sign in to comment.