Improve logging in VoiceNotesPlaybackContext

This commit is contained in:
trevor-signal 2024-08-30 16:22:49 -04:00 committed by GitHub
parent 03ab5b4b34
commit 01581b04d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 62 additions and 16 deletions

View file

@ -103,6 +103,30 @@ describe('Privacy', () => {
});
});
describe('redactAttachmentUrlKeys', () => {
it('should redact key= values ', () => {
const text =
'Log line with url attachment://v2/e6/abcdee64?key=hxKJ9cTfK0v3KEsnzJ2j%2F4Crwe0yu&size=39360&contentType=png ' +
'and another already partially redacted attachment://v2/e6/[REDACTED]?LOCALKEY=hxKJ9cTfK0v3KEsnzJ2j%2F4Crwe0yu&size=39360&contentType=png';
const actual = Privacy.redactAttachmentUrlKeys(text);
const expected =
'Log line with url attachment://v2/e6/abcdee64?key=[REDACTED] ' +
'and another already partially redacted attachment://v2/e6/[REDACTED]?LOCALKEY=[REDACTED]';
assert.equal(actual, expected);
});
});
describe('redactAttachmentUrl', () => {
it('should remove search params ', () => {
const url =
'attachment://v2/e6/abcdee64?key=hxKJ9cTfK0v3KEsnzJ2j%2F4Crwe0yu&size=39360&contentType=png';
const actual = Privacy.redactAttachmentUrl(url);
const expected = 'attachment://v2/e6/abcdee64';
assert.equal(actual, expected);
});
});
describe('redactAll', () => {
it('should redact all sensitive information', () => {
const encodedAppRootPath = APP_ROOT_PATH.replace(/ /g, '%20');
@ -114,7 +138,8 @@ describe('Privacy', () => {
`path2 file:///${encodedAppRootPath}/js/background.js.` +
'phone2 +13334445566 lorem\n' +
'group2 group(abcdefghij) doloret\n' +
'path3 sensitive-path/attachment.noindex\n';
'path3 sensitive-path/attachment.noindex\n' +
'attachment://v2/ab/abcde?key=specialkey\n';
const actual = Privacy.redactAll(text);
const expected =
@ -125,7 +150,8 @@ describe('Privacy', () => {
'path2 [REDACTED]/js/background.js.' +
'phone2 +[REDACTED]566 lorem\n' +
'group2 group([REDACTED]hij) doloret\n' +
'path3 [REDACTED]/attachment.noindex\n';
'path3 [REDACTED]/attachment.noindex\n' +
'attachment://v2/ab/abcde?key=[REDACTED]\n';
assert.equal(actual, expected);
});
});