Skip to content

Commit

Permalink
[lib] Add more keys to redacted values
Browse files Browse the repository at this point in the history
Summary:
Address [[ https://linear.app/comm/issue/ENG-8717/revisit-redacted-values-for-reports | ENG-8717 ]].

- Added more keys to the redacted lists: CSAT, device lists, encrypted blob data
- For Blob URIs, created a separate placeholder value

Test Plan: Triggered crash report on my test account. Verified that some Redux values (like `commServicesAccessToken`) are now redacted.

Reviewers: ashoat

Reviewed By: ashoat

Subscribers: tomek

Differential Revision: https://phab.comm.dev/D13270
  • Loading branch information
barthap committed Sep 11, 2024
1 parent 2bf0928 commit 5622ed8
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/utils/sanitization.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,18 @@ const keysWithStringsToBeRedacted = new Set([
'curve25519',
'picklingKey',
'pickledAccount',
'commServicesAccessToken',
'blobHash',
'blobHolder',
'holder',
'thumbnailHolder',
'encryptionKey',
'thumbnailEncryptionKey',
]);

// eg {"memberIDs":["123", "456"]} => {"memberIDs":["redacted", "redacted"]}
const keysWithArraysToBeRedacted = new Set([
'devices',
'memberIDs',
'messageIDs',
'already_friends',
Expand Down Expand Up @@ -109,6 +117,10 @@ const keysWithImageURIsToBeReplaced = new Set([
'thumbnailURI',
]);

// eg {"uri":"comm-blob-service://1a2b3c4d5e6f"}
// => {"uri":"comm-blob-service://placeholder"}
const keysWithBlobURIsToBeReplaced = new Set(['blobURI, thumbnailBlobURI']);

// (special case that redacts triply-linked [] to handle `daysToEntries` )
// eg "daysToEntries":{"2020-12-29":["123"]}
// => "daysToEntries":{"2020-12-29":["redacted"]}
Expand All @@ -132,6 +144,10 @@ function placeholderImageURI(): string {
return 'https://comm.app/images/placeholder.png';
}

function placeholderBlobURI(): string {
return 'comm-blob-service://placeholder';
}

function scrambleText(str: string): string {
const arr = [];
for (const char of new String(str)) {
Expand Down Expand Up @@ -233,6 +249,8 @@ function sanitizePII(obj: Object, redactionHelpers: RedactionHelpers): void {
obj[k] = scrambleText(obj[k]);
} else if (keysWithImageURIsToBeReplaced.has(k)) {
obj[k] = placeholderImageURI();
} else if (keysWithBlobURIsToBeReplaced.has(k)) {
obj[k] = placeholderBlobURI();
} else if (keysWithArraysToBeRedacted.has(k)) {
obj[k] = obj[k].map(redactionHelpers.redactString);
} else if (typeof obj[k] === 'object') {
Expand Down

0 comments on commit 5622ed8

Please sign in to comment.