| 
									
										
										
										
											2023-01-03 11:55:46 -08:00
										 |  |  | // Copyright 2018 Signal Messenger, LLC
 | 
					
						
							| 
									
										
										
										
											2020-10-30 15:34:04 -05:00
										 |  |  | // SPDX-License-Identifier: AGPL-3.0-only
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-01 11:15:23 -07:00
										 |  |  | import { assert } from 'chai'; | 
					
						
							| 
									
										
										
										
											2018-03-06 16:25:43 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-01 11:15:23 -07:00
										 |  |  | import * as Privacy from '../../util/privacy'; | 
					
						
							|  |  |  | import { APP_ROOT_PATH } from '../../util/privacy'; | 
					
						
							| 
									
										
										
										
											2018-03-06 16:25:43 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-01 11:15:23 -07:00
										 |  |  | Privacy.addSensitivePath('sensitive-path'); | 
					
						
							| 
									
										
										
										
											2018-03-06 16:25:43 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | describe('Privacy', () => { | 
					
						
							| 
									
										
										
										
											2025-07-22 06:44:08 +10:00
										 |  |  |   describe('redactCardNumbers', () => { | 
					
						
							|  |  |  |     it('should redact anything that looks like a credit card', () => { | 
					
						
							|  |  |  |       const text = | 
					
						
							|  |  |  |         'This is a log line with a card number 1234-1234-1234\n' + | 
					
						
							|  |  |  |         'and another one 1234 1234 1234 1234 123'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       const actual = Privacy.redactCardNumbers(text); | 
					
						
							|  |  |  |       const expected = | 
					
						
							|  |  |  |         'This is a log line with a card number [REDACTED]\n' + | 
					
						
							|  |  |  |         'and another one [REDACTED]'; | 
					
						
							|  |  |  |       assert.equal(actual, expected); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should redact weird credit card numbers', () => { | 
					
						
							|  |  |  |       const text = | 
					
						
							|  |  |  |         '12341234123\n' + | 
					
						
							|  |  |  |         '123412341234\n' + | 
					
						
							|  |  |  |         '1234123412341\n' + | 
					
						
							|  |  |  |         '12341234123412\n' + | 
					
						
							|  |  |  |         '123412341234123\n' + | 
					
						
							|  |  |  |         '1234123412341234\n' + | 
					
						
							|  |  |  |         '12341234123412341\n' + | 
					
						
							|  |  |  |         '123412341234123412\n' + | 
					
						
							|  |  |  |         '1234123412341234123\n' + | 
					
						
							|  |  |  |         '12341234123412341234\n' + | 
					
						
							|  |  |  |         '1-2-3-4-1-2-3-4-1-2-3\n' + | 
					
						
							|  |  |  |         '1-2-3-4-1-2-3-4-1-2-3-4\n' + | 
					
						
							|  |  |  |         '1-2-3-4-1-2-3-4-1-2-3-4-1\n' + | 
					
						
							|  |  |  |         '1-2-3-4-1-2-3-4-1-2-3-4-1-2\n' + | 
					
						
							|  |  |  |         '1-2-3-4-1-2-3-4-1-2-3-4-1-2-3\n' + | 
					
						
							|  |  |  |         '1-2-3-4-1-2-3-4-1-2-3-4-1-2-3-4\n' + | 
					
						
							|  |  |  |         '1-2-3-4-1-2-3-4-1-2-3-4-1-2-3-4-1\n' + | 
					
						
							|  |  |  |         '1-2-3-4-1-2-3-4-1-2-3-4-1-2-3-4-1-2\n' + | 
					
						
							|  |  |  |         '1-2-3-4-1-2-3-4-1-2-3-4-1-2-3-4-1-2-3\n' + | 
					
						
							|  |  |  |         '1-2-3-4-1-2-3-4-1-2-3-4-1-2-3-4-1-2-3-4\n' + | 
					
						
							|  |  |  |         '1 2 3 4 1 2 3 4 1 2 3\n' + | 
					
						
							|  |  |  |         '1 2 3 4 1 2 3 4 1 2 3 4\n' + | 
					
						
							|  |  |  |         '1 2 3 4 1 2 3 4 1 2 3 4 1\n' + | 
					
						
							|  |  |  |         '1 2 3 4 1 2 3 4 1 2 3 4 1 2\n' + | 
					
						
							|  |  |  |         '1 2 3 4 1 2 3 4 1 2 3 4 1 2 3\n' + | 
					
						
							|  |  |  |         '1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4\n' + | 
					
						
							|  |  |  |         '1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1\n' + | 
					
						
							|  |  |  |         '1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2\n' + | 
					
						
							|  |  |  |         '1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3\n' + | 
					
						
							|  |  |  |         '1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4\n' + | 
					
						
							|  |  |  |         '1 2 3 a 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4\n' + | 
					
						
							|  |  |  |         '1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 a 2 3 4\n' + | 
					
						
							|  |  |  |         ''; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       const actual = Privacy.redactCardNumbers(text); | 
					
						
							|  |  |  |       const expected = | 
					
						
							|  |  |  |         '12341234123\n' + | 
					
						
							|  |  |  |         '[REDACTED]\n' + | 
					
						
							|  |  |  |         '[REDACTED]\n' + | 
					
						
							|  |  |  |         '[REDACTED]\n' + | 
					
						
							|  |  |  |         '[REDACTED]\n' + | 
					
						
							|  |  |  |         '[REDACTED]\n' + | 
					
						
							|  |  |  |         '[REDACTED]\n' + | 
					
						
							|  |  |  |         '[REDACTED]\n' + | 
					
						
							|  |  |  |         '[REDACTED]\n' + | 
					
						
							|  |  |  |         '[REDACTED]4\n' + | 
					
						
							|  |  |  |         '1-2-3-4-1-2-3-4-1-2-3\n' + | 
					
						
							|  |  |  |         '[REDACTED]\n' + | 
					
						
							|  |  |  |         '[REDACTED]\n' + | 
					
						
							|  |  |  |         '[REDACTED]\n' + | 
					
						
							|  |  |  |         '[REDACTED]\n' + | 
					
						
							|  |  |  |         '[REDACTED]\n' + | 
					
						
							|  |  |  |         '[REDACTED]\n' + | 
					
						
							|  |  |  |         '[REDACTED]\n' + | 
					
						
							|  |  |  |         '[REDACTED]\n' + | 
					
						
							|  |  |  |         '[REDACTED]-4\n' + | 
					
						
							|  |  |  |         '1 2 3 4 1 2 3 4 1 2 3\n' + | 
					
						
							|  |  |  |         '[REDACTED]\n' + | 
					
						
							|  |  |  |         '[REDACTED]\n' + | 
					
						
							|  |  |  |         '[REDACTED]\n' + | 
					
						
							|  |  |  |         '[REDACTED]\n' + | 
					
						
							|  |  |  |         '[REDACTED]\n' + | 
					
						
							|  |  |  |         '[REDACTED]\n' + | 
					
						
							|  |  |  |         '[REDACTED]\n' + | 
					
						
							|  |  |  |         '[REDACTED]\n' + | 
					
						
							|  |  |  |         '[REDACTED] 4\n' + | 
					
						
							|  |  |  |         '1 2 3 a [REDACTED]\n' + | 
					
						
							|  |  |  |         '[REDACTED] a 2 3 4\n' + | 
					
						
							|  |  |  |         ''; | 
					
						
							|  |  |  |       assert.equal(actual, expected); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should not redact things that are close to credit card numbers', () => { | 
					
						
							|  |  |  |       const text = `
 | 
					
						
							|  |  |  |         12--3412341234 | 
					
						
							|  |  |  |         1234123  412341234 | 
					
						
							|  |  |  |         1e23412341234 | 
					
						
							|  |  |  |       `;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       const actual = Privacy.redactCardNumbers(text); | 
					
						
							|  |  |  |       const expected = `
 | 
					
						
							|  |  |  |         12--3412341234 | 
					
						
							|  |  |  |         1234123  412341234 | 
					
						
							|  |  |  |         1e23412341234 | 
					
						
							|  |  |  |       `;
 | 
					
						
							|  |  |  |       assert.equal(actual, expected); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-06 16:25:43 -05:00
										 |  |  |   describe('redactPhoneNumbers', () => { | 
					
						
							|  |  |  |     it('should redact all phone numbers', () => { | 
					
						
							| 
									
										
										
										
											2018-04-27 17:25:04 -04:00
										 |  |  |       const text = | 
					
						
							|  |  |  |         'This is a log line with a phone number +12223334455\n' + | 
					
						
							| 
									
										
										
										
											2018-03-06 16:25:43 -05:00
										 |  |  |         'and another one +13334445566'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       const actual = Privacy.redactPhoneNumbers(text); | 
					
						
							| 
									
										
										
										
											2018-04-27 17:25:04 -04:00
										 |  |  |       const expected = | 
					
						
							|  |  |  |         'This is a log line with a phone number +[REDACTED]455\n' + | 
					
						
							| 
									
										
										
										
											2018-03-06 16:25:43 -05:00
										 |  |  |         'and another one +[REDACTED]566'; | 
					
						
							|  |  |  |       assert.equal(actual, expected); | 
					
						
							| 
									
										
										
										
											2020-03-05 13:14:58 -08:00
										 |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   describe('redactUuids', () => { | 
					
						
							|  |  |  |     it('should redact all uuids', () => { | 
					
						
							|  |  |  |       const text = | 
					
						
							|  |  |  |         'This is a log line with a uuid 9e420799-acdf-4bf4-8dee-353d7e2096b4\n' + | 
					
						
							| 
									
										
										
										
											2024-10-16 11:59:38 -04:00
										 |  |  |         'and another one IN ALL UPPERCASE 340727FB-E43A-413B-941B-AADA033B6CA3\n' + | 
					
						
							|  |  |  |         'and a v7 uuid: 019291b5-fea7-7007-9261-31ca82451a6e\n' + | 
					
						
							|  |  |  |         'and my story: 00000000-0000-0000-0000-000000000000'; | 
					
						
							| 
									
										
										
										
											2020-03-05 13:14:58 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |       const actual = Privacy.redactUuids(text); | 
					
						
							|  |  |  |       const expected = | 
					
						
							| 
									
										
										
										
											2020-03-20 15:01:15 -04:00
										 |  |  |         'This is a log line with a uuid [REDACTED]6b4\n' + | 
					
						
							| 
									
										
										
										
											2024-10-16 11:59:38 -04:00
										 |  |  |         'and another one IN ALL UPPERCASE [REDACTED]CA3\n' + | 
					
						
							|  |  |  |         'and a v7 uuid: [REDACTED]a6e\n' + | 
					
						
							|  |  |  |         'and my story: [REDACTED]000'; | 
					
						
							| 
									
										
										
										
											2020-03-05 13:14:58 -08:00
										 |  |  |       assert.equal(actual, expected); | 
					
						
							| 
									
										
										
										
											2018-03-06 16:25:43 -05:00
										 |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   describe('redactGroupIds', () => { | 
					
						
							|  |  |  |     it('should redact all group IDs', () => { | 
					
						
							| 
									
										
										
										
											2018-04-27 17:25:04 -04:00
										 |  |  |       const text = | 
					
						
							|  |  |  |         'This is a log line with two group IDs: group(123456789)\n' + | 
					
						
							| 
									
										
										
										
											2018-03-06 16:25:43 -05:00
										 |  |  |         'and group(abcdefghij)'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       const actual = Privacy.redactGroupIds(text); | 
					
						
							| 
									
										
										
										
											2018-04-27 17:25:04 -04:00
										 |  |  |       const expected = | 
					
						
							|  |  |  |         'This is a log line with two group IDs: group([REDACTED]789)\n' + | 
					
						
							| 
									
										
										
										
											2018-03-06 16:25:43 -05:00
										 |  |  |         'and group([REDACTED]hij)'; | 
					
						
							|  |  |  |       assert.equal(actual, expected); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2018-05-03 11:46:21 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     it('should remove newlines from redacted group IDs', () => { | 
					
						
							|  |  |  |       const text = | 
					
						
							|  |  |  |         'This is a log line with two group IDs: group(12345678\n9)\n' + | 
					
						
							|  |  |  |         'and group(abc\ndefghij)'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       const actual = Privacy.redactGroupIds(text); | 
					
						
							|  |  |  |       const expected = | 
					
						
							|  |  |  |         'This is a log line with two group IDs: group([REDACTED]789)\n' + | 
					
						
							|  |  |  |         'and group([REDACTED]hij)'; | 
					
						
							|  |  |  |       assert.equal(actual, expected); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     it('should remove newlines from redacted group V2 IDs', () => { | 
					
						
							|  |  |  |       const text = | 
					
						
							|  |  |  |         'This is a log line with three group IDs: groupv2(abcd32341a==)\n' + | 
					
						
							|  |  |  |         'and groupv2(abcd32341ad=) and and groupv2(abcd32341ade)'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       const actual = Privacy.redactGroupIds(text); | 
					
						
							|  |  |  |       const expected = | 
					
						
							|  |  |  |         'This is a log line with three group IDs: groupv2([REDACTED]41a==)\n' + | 
					
						
							|  |  |  |         'and groupv2([REDACTED]1ad=) and and groupv2([REDACTED]ade)'; | 
					
						
							|  |  |  |       assert.equal(actual, expected); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2018-03-06 16:25:43 -05:00
										 |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-22 13:19:50 -08:00
										 |  |  |   describe('redactCallLinkRoomIds', () => { | 
					
						
							|  |  |  |     it('should redact call link room IDs', () => { | 
					
						
							|  |  |  |       const text = | 
					
						
							|  |  |  |         'Log line with call link room ID 7f3d431d4512b30754915a262db43cd789f799d710525a83429d48aee8c2cd4b\n' + | 
					
						
							|  |  |  |         'and another IN ALL UPPERCASE 7F3D431D4512B30754915A262DB43CD789F799D710525A83429D48AEE8C2CD4B'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       const actual = Privacy.redactCallLinkRoomIds(text); | 
					
						
							|  |  |  |       const expected = | 
					
						
							|  |  |  |         'Log line with call link room ID [REDACTED]d4b\n' + | 
					
						
							|  |  |  |         'and another IN ALL UPPERCASE [REDACTED]D4B'; | 
					
						
							|  |  |  |       assert.equal(actual, expected); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   describe('redactCallLinkRootKeys', () => { | 
					
						
							|  |  |  |     it('should redact call link root keys', () => { | 
					
						
							|  |  |  |       const text = | 
					
						
							|  |  |  |         'Log line with call link https://signal.link/call/#key=hktt-kskq-dhcn-bgkm-hbbg-qqkq-sfbp-czmc\n' + | 
					
						
							|  |  |  |         'and another IN ALL UPPERCASE HKTT-KSKQ-DHCN-BGKM-HBBG-QQKQ-SFBP-CZMC'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       const actual = Privacy.redactCallLinkRootKeys(text); | 
					
						
							|  |  |  |       const expected = | 
					
						
							|  |  |  |         'Log line with call link https://signal.link/call/#key=[REDACTED]hktt\n' + | 
					
						
							|  |  |  |         'and another IN ALL UPPERCASE [REDACTED]HKTT'; | 
					
						
							|  |  |  |       assert.equal(actual, expected); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-30 16:22:49 -04:00
										 |  |  |   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); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-06 16:25:43 -05:00
										 |  |  |   describe('redactAll', () => { | 
					
						
							|  |  |  |     it('should redact all sensitive information', () => { | 
					
						
							| 
									
										
										
										
											2018-04-06 12:54:29 -04:00
										 |  |  |       const encodedAppRootPath = APP_ROOT_PATH.replace(/ /g, '%20'); | 
					
						
							| 
									
										
										
										
											2018-04-27 17:25:04 -04:00
										 |  |  |       const text = | 
					
						
							|  |  |  |         'This is a log line with sensitive information:\n' + | 
					
						
							| 
									
										
										
										
											2018-03-06 16:25:43 -05:00
										 |  |  |         `path1 ${APP_ROOT_PATH}/main.js\n` + | 
					
						
							|  |  |  |         'phone1 +12223334455 ipsum\n' + | 
					
						
							|  |  |  |         'group1 group(123456789) doloret\n' + | 
					
						
							| 
									
										
										
										
											2018-04-06 12:54:29 -04:00
										 |  |  |         `path2 file:///${encodedAppRootPath}/js/background.js.` + | 
					
						
							| 
									
										
										
										
											2018-03-06 16:25:43 -05:00
										 |  |  |         'phone2 +13334445566 lorem\n' + | 
					
						
							| 
									
										
										
										
											2021-06-01 11:15:23 -07:00
										 |  |  |         'group2 group(abcdefghij) doloret\n' + | 
					
						
							| 
									
										
										
										
											2024-08-30 16:22:49 -04:00
										 |  |  |         'path3 sensitive-path/attachment.noindex\n' + | 
					
						
							| 
									
										
										
										
											2025-07-22 06:44:08 +10:00
										 |  |  |         'cc 1234 1234 1234 1234 and another 1234123412341234\n' + | 
					
						
							| 
									
										
										
										
											2024-08-30 16:22:49 -04:00
										 |  |  |         'attachment://v2/ab/abcde?key=specialkey\n'; | 
					
						
							| 
									
										
										
										
											2018-03-06 16:25:43 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |       const actual = Privacy.redactAll(text); | 
					
						
							| 
									
										
										
										
											2018-04-27 17:25:04 -04:00
										 |  |  |       const expected = | 
					
						
							|  |  |  |         'This is a log line with sensitive information:\n' + | 
					
						
							| 
									
										
										
										
											2018-03-06 16:25:43 -05:00
										 |  |  |         'path1 [REDACTED]/main.js\n' + | 
					
						
							|  |  |  |         'phone1 +[REDACTED]455 ipsum\n' + | 
					
						
							|  |  |  |         'group1 group([REDACTED]789) doloret\n' + | 
					
						
							| 
									
										
										
										
											2023-06-16 11:40:58 -07:00
										 |  |  |         'path2 [REDACTED]/js/background.js.' + | 
					
						
							| 
									
										
										
										
											2018-03-06 16:25:43 -05:00
										 |  |  |         'phone2 +[REDACTED]566 lorem\n' + | 
					
						
							| 
									
										
										
										
											2021-06-01 11:15:23 -07:00
										 |  |  |         'group2 group([REDACTED]hij) doloret\n' + | 
					
						
							| 
									
										
										
										
											2024-08-30 16:22:49 -04:00
										 |  |  |         'path3 [REDACTED]/attachment.noindex\n' + | 
					
						
							| 
									
										
										
										
											2025-07-22 06:44:08 +10:00
										 |  |  |         'cc [REDACTED] and another [REDACTED]\n' + | 
					
						
							| 
									
										
										
										
											2024-08-30 16:22:49 -04:00
										 |  |  |         'attachment://v2/ab/abcde?key=[REDACTED]\n'; | 
					
						
							| 
									
										
										
										
											2018-03-06 16:25:43 -05:00
										 |  |  |       assert.equal(actual, expected); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2018-04-06 12:54:29 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |   describe('_redactPath', () => { | 
					
						
							| 
									
										
										
										
											2018-04-06 13:24:43 -04:00
										 |  |  |     it('should redact file paths', () => { | 
					
						
							|  |  |  |       const testPath = '/Users/meow/Library/Application Support/Signal Beta'; | 
					
						
							| 
									
										
										
										
											2018-04-27 17:25:04 -04:00
										 |  |  |       const text = | 
					
						
							|  |  |  |         'This is a log line with sensitive information:\n' + | 
					
						
							| 
									
										
										
										
											2018-04-06 13:24:43 -04:00
										 |  |  |         `path1 ${testPath}/main.js\n` + | 
					
						
							|  |  |  |         'phone1 +12223334455 ipsum\n'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       const actual = Privacy._redactPath(testPath)(text); | 
					
						
							| 
									
										
										
										
											2018-04-27 17:25:04 -04:00
										 |  |  |       const expected = | 
					
						
							|  |  |  |         'This is a log line with sensitive information:\n' + | 
					
						
							| 
									
										
										
										
											2018-04-06 13:24:43 -04:00
										 |  |  |         'path1 [REDACTED]/main.js\n' + | 
					
						
							|  |  |  |         'phone1 +12223334455 ipsum\n'; | 
					
						
							|  |  |  |       assert.equal(actual, expected); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-06 12:54:29 -04:00
										 |  |  |     it('should redact URL-encoded paths', () => { | 
					
						
							|  |  |  |       const testPath = '/Users/meow/Library/Application Support/Signal Beta'; | 
					
						
							|  |  |  |       const encodedTestPath = encodeURI(testPath); | 
					
						
							| 
									
										
										
										
											2018-04-27 17:25:04 -04:00
										 |  |  |       const text = | 
					
						
							|  |  |  |         'This is a log line with sensitive information:\n' + | 
					
						
							| 
									
										
										
										
											2018-04-06 12:54:29 -04:00
										 |  |  |         `path1 ${testPath}/main.js\n` + | 
					
						
							|  |  |  |         'phone1 +12223334455 ipsum\n' + | 
					
						
							|  |  |  |         'group1 group(123456789) doloret\n' + | 
					
						
							|  |  |  |         `path2 file:///${encodedTestPath}/js/background.js.`; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       const actual = Privacy._redactPath(testPath)(text); | 
					
						
							| 
									
										
										
										
											2018-04-27 17:25:04 -04:00
										 |  |  |       const expected = | 
					
						
							|  |  |  |         'This is a log line with sensitive information:\n' + | 
					
						
							| 
									
										
										
										
											2018-04-06 12:54:29 -04:00
										 |  |  |         'path1 [REDACTED]/main.js\n' + | 
					
						
							|  |  |  |         'phone1 +12223334455 ipsum\n' + | 
					
						
							|  |  |  |         'group1 group(123456789) doloret\n' + | 
					
						
							| 
									
										
										
										
											2023-06-16 11:40:58 -07:00
										 |  |  |         'path2 [REDACTED]/js/background.js.'; | 
					
						
							| 
									
										
										
										
											2018-04-06 12:54:29 -04:00
										 |  |  |       assert.equal(actual, expected); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2018-04-06 13:19:41 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     it('should redact stack traces with both forward and backslashes', () => { | 
					
						
							| 
									
										
										
										
											2018-04-27 17:25:04 -04:00
										 |  |  |       const testPath = | 
					
						
							|  |  |  |         'C:/Users/Meow/AppData/Local/Programs/signal-desktop-beta'; | 
					
						
							| 
									
										
										
										
											2018-04-06 13:19:41 -04:00
										 |  |  |       const modifiedTestPath = | 
					
						
							|  |  |  |         'C:\\Users\\Meow\\AppData\\Local\\Programs\\signal-desktop-beta'; | 
					
						
							| 
									
										
										
										
											2018-04-27 17:25:04 -04:00
										 |  |  |       const text = | 
					
						
							|  |  |  |         'This is a log line with sensitive information:\n' + | 
					
						
							| 
									
										
										
										
											2018-04-06 13:19:41 -04:00
										 |  |  |         `path1 ${testPath}\\main.js\n` + | 
					
						
							|  |  |  |         'phone1 +12223334455 ipsum\n' + | 
					
						
							|  |  |  |         'group1 group(123456789) doloret\n' + | 
					
						
							|  |  |  |         `path2 ${modifiedTestPath}\\js\\background.js.`; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       const actual = Privacy._redactPath(testPath)(text); | 
					
						
							| 
									
										
										
										
											2018-04-27 17:25:04 -04:00
										 |  |  |       const expected = | 
					
						
							|  |  |  |         'This is a log line with sensitive information:\n' + | 
					
						
							| 
									
										
										
										
											2018-04-06 13:19:41 -04:00
										 |  |  |         'path1 [REDACTED]\\main.js\n' + | 
					
						
							|  |  |  |         'phone1 +12223334455 ipsum\n' + | 
					
						
							|  |  |  |         'group1 group(123456789) doloret\n' + | 
					
						
							|  |  |  |         'path2 [REDACTED]\\js\\background.js.'; | 
					
						
							|  |  |  |       assert.equal(actual, expected); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2018-04-06 14:25:55 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     it('should redact stack traces with escaped backslashes', () => { | 
					
						
							| 
									
										
										
										
											2018-04-27 17:25:04 -04:00
										 |  |  |       const testPath = | 
					
						
							|  |  |  |         'C:\\Users\\Meow\\AppData\\Local\\Programs\\signal-desktop-beta'; | 
					
						
							| 
									
										
										
										
											2018-04-06 14:25:55 -04:00
										 |  |  |       const modifiedTestPath = | 
					
						
							|  |  |  |         'C:\\\\Users\\\\Meow\\\\AppData\\\\Local\\\\Programs\\\\signal-desktop-beta'; | 
					
						
							| 
									
										
										
										
											2018-04-27 17:25:04 -04:00
										 |  |  |       const text = | 
					
						
							|  |  |  |         'This is a log line with sensitive information:\n' + | 
					
						
							| 
									
										
										
										
											2018-04-06 14:25:55 -04:00
										 |  |  |         `path1 ${testPath}\\main.js\n` + | 
					
						
							|  |  |  |         'phone1 +12223334455 ipsum\n' + | 
					
						
							|  |  |  |         'group1 group(123456789) doloret\n' + | 
					
						
							|  |  |  |         `path2 ${modifiedTestPath}\\js\\background.js.`; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       const actual = Privacy._redactPath(testPath)(text); | 
					
						
							| 
									
										
										
										
											2018-04-27 17:25:04 -04:00
										 |  |  |       const expected = | 
					
						
							|  |  |  |         'This is a log line with sensitive information:\n' + | 
					
						
							| 
									
										
										
										
											2018-04-06 14:25:55 -04:00
										 |  |  |         'path1 [REDACTED]\\main.js\n' + | 
					
						
							|  |  |  |         'phone1 +12223334455 ipsum\n' + | 
					
						
							|  |  |  |         'group1 group(123456789) doloret\n' + | 
					
						
							|  |  |  |         'path2 [REDACTED]\\js\\background.js.'; | 
					
						
							|  |  |  |       assert.equal(actual, expected); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2018-04-06 12:54:29 -04:00
										 |  |  |   }); | 
					
						
							| 
									
										
										
										
											2018-03-06 16:25:43 -05:00
										 |  |  | }); |