Privacy: Additional tweaks to debug log generation
This commit is contained in:
parent
9fc0cedebb
commit
510b4f2df7
2 changed files with 31 additions and 38 deletions
|
|
@ -12,7 +12,7 @@ describe('Privacy', () => {
|
||||||
describe('redactCardNumbers', () => {
|
describe('redactCardNumbers', () => {
|
||||||
it('should redact anything that looks like a credit card', () => {
|
it('should redact anything that looks like a credit card', () => {
|
||||||
const text =
|
const text =
|
||||||
'This is a log line with a card number 1234-1234-1234\n' +
|
'This is a log line with a card number 1234-1234-1234-12\n' +
|
||||||
'and another one 1234 1234 1234 1234 123';
|
'and another one 1234 1234 1234 1234 123';
|
||||||
|
|
||||||
const actual = Privacy.redactCardNumbers(text);
|
const actual = Privacy.redactCardNumbers(text);
|
||||||
|
|
@ -24,8 +24,6 @@ describe('Privacy', () => {
|
||||||
|
|
||||||
it('should redact weird credit card numbers', () => {
|
it('should redact weird credit card numbers', () => {
|
||||||
const text =
|
const text =
|
||||||
'12341234123\n' +
|
|
||||||
'123412341234\n' +
|
|
||||||
'1234123412341\n' +
|
'1234123412341\n' +
|
||||||
'12341234123412\n' +
|
'12341234123412\n' +
|
||||||
'123412341234123\n' +
|
'123412341234123\n' +
|
||||||
|
|
@ -34,18 +32,14 @@ describe('Privacy', () => {
|
||||||
'123412341234123412\n' +
|
'123412341234123412\n' +
|
||||||
'1234123412341234123\n' +
|
'1234123412341234123\n' +
|
||||||
'12341234123412341234\n' +
|
'12341234123412341234\n' +
|
||||||
'1-2-3-4-1-2-3-4-1-2-3\n' +
|
'123-4-1-2-3-4-1-2-3-4-1\n' +
|
||||||
'1-2-3-4-1-2-3-4-1-2-3-4\n' +
|
'123-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\n' +
|
'123-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\n' +
|
'123-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\n' +
|
'123-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\n' +
|
'123-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\n' +
|
'123-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\n' +
|
'123-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-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' +
|
|
||||||
'123 4 1 2 3 4 1 2 3 4 1\n' +
|
'123 4 1 2 3 4 1 2 3 4 1\n' +
|
||||||
'123 4 1 2 3 4 1 2 3 4 1 2\n' +
|
'123 4 1 2 3 4 1 2 3 4 1 2\n' +
|
||||||
'123 4 1 2 3 4 1 2 3 4 1 2 3\n' +
|
'123 4 1 2 3 4 1 2 3 4 1 2 3\n' +
|
||||||
|
|
@ -60,9 +54,7 @@ describe('Privacy', () => {
|
||||||
|
|
||||||
const actual = Privacy.redactCardNumbers(text);
|
const actual = Privacy.redactCardNumbers(text);
|
||||||
const expected =
|
const expected =
|
||||||
'12341234123\n' +
|
'1234123412341\n' +
|
||||||
'[REDACTED]\n' +
|
|
||||||
'[REDACTED]\n' +
|
|
||||||
'[REDACTED]\n' +
|
'[REDACTED]\n' +
|
||||||
'[REDACTED]\n' +
|
'[REDACTED]\n' +
|
||||||
'[REDACTED]\n' +
|
'[REDACTED]\n' +
|
||||||
|
|
@ -70,9 +62,7 @@ describe('Privacy', () => {
|
||||||
'[REDACTED]\n' +
|
'[REDACTED]\n' +
|
||||||
'[REDACTED]\n' +
|
'[REDACTED]\n' +
|
||||||
'[REDACTED]4\n' +
|
'[REDACTED]4\n' +
|
||||||
'1-2-3-4-1-2-3-4-1-2-3\n' +
|
'123-4-1-2-3-4-1-2-3-4-1\n' +
|
||||||
'[REDACTED]\n' +
|
|
||||||
'[REDACTED]\n' +
|
|
||||||
'[REDACTED]\n' +
|
'[REDACTED]\n' +
|
||||||
'[REDACTED]\n' +
|
'[REDACTED]\n' +
|
||||||
'[REDACTED]\n' +
|
'[REDACTED]\n' +
|
||||||
|
|
@ -80,9 +70,7 @@ describe('Privacy', () => {
|
||||||
'[REDACTED]\n' +
|
'[REDACTED]\n' +
|
||||||
'[REDACTED]\n' +
|
'[REDACTED]\n' +
|
||||||
'[REDACTED]-4\n' +
|
'[REDACTED]-4\n' +
|
||||||
'1 2 3 4 1 2 3 4 1 2 3\n' +
|
'123 4 1 2 3 4 1 2 3 4 1\n' +
|
||||||
'[REDACTED]\n' +
|
|
||||||
'[REDACTED]\n' +
|
|
||||||
'[REDACTED]\n' +
|
'[REDACTED]\n' +
|
||||||
'[REDACTED]\n' +
|
'[REDACTED]\n' +
|
||||||
'[REDACTED]\n' +
|
'[REDACTED]\n' +
|
||||||
|
|
@ -98,6 +86,7 @@ describe('Privacy', () => {
|
||||||
|
|
||||||
it('should not redact things that are close to credit card numbers', () => {
|
it('should not redact things that are close to credit card numbers', () => {
|
||||||
const text = `
|
const text = `
|
||||||
|
INFO 2025-07-22T16:39:12.383Z [background] delivery receipt from [REDACTED]f41.1 1753202353590 for sent message 1753202351897 wasSentEncrypted=true
|
||||||
12--3412341234
|
12--3412341234
|
||||||
1234123 412341234
|
1234123 412341234
|
||||||
1e23412341234
|
1e23412341234
|
||||||
|
|
@ -105,6 +94,7 @@ describe('Privacy', () => {
|
||||||
|
|
||||||
const actual = Privacy.redactCardNumbers(text);
|
const actual = Privacy.redactCardNumbers(text);
|
||||||
const expected = `
|
const expected = `
|
||||||
|
INFO 2025-07-22T16:39:12.383Z [background] delivery receipt from [REDACTED]f41.1 1753202353590 for sent message 1753202351897 wasSentEncrypted=true
|
||||||
12--3412341234
|
12--3412341234
|
||||||
1234123 412341234
|
1234123 412341234
|
||||||
1e23412341234
|
1e23412341234
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ const CALL_LINK_ROOT_KEY_PATTERN =
|
||||||
/([A-Z]{4})-[A-Z]{4}-[A-Z]{4}-[A-Z]{4}-[A-Z]{4}-[A-Z]{4}-[A-Z]{4}-[A-Z]{4}/gi;
|
/([A-Z]{4})-[A-Z]{4}-[A-Z]{4}-[A-Z]{4}-[A-Z]{4}-[A-Z]{4}-[A-Z]{4}-[A-Z]{4}/gi;
|
||||||
const ATTACHMENT_URL_KEY_PATTERN = /(attachment:\/\/[^\s]+key=)([^\s]+)/gi;
|
const ATTACHMENT_URL_KEY_PATTERN = /(attachment:\/\/[^\s]+key=)([^\s]+)/gi;
|
||||||
const REDACTION_PLACEHOLDER = '[REDACTED]';
|
const REDACTION_PLACEHOLDER = '[REDACTED]';
|
||||||
const CARD_NUMBER_PATTERN = /(\d[- ]?){11,18}\d/g;
|
const CARD_NUMBER_PATTERN = /\d\d(\d[- ]?){11,16}\d/g;
|
||||||
|
|
||||||
export type RedactFunction = (value: string) => string;
|
export type RedactFunction = (value: string) => string;
|
||||||
|
|
||||||
|
|
@ -222,15 +222,18 @@ addSensitivePath(APP_ROOT_PATH);
|
||||||
export const redactAll: RedactFunction = text => {
|
export const redactAll: RedactFunction = text => {
|
||||||
let result = text;
|
let result = text;
|
||||||
|
|
||||||
|
// Do these first, to retain last characters
|
||||||
result = redactAttachmentUrlKeys(result);
|
result = redactAttachmentUrlKeys(result);
|
||||||
result = redactCallLinkRoomIds(result);
|
result = redactCallLinkRoomIds(result);
|
||||||
result = redactCallLinkRootKeys(result);
|
result = redactCallLinkRootKeys(result);
|
||||||
result = redactCardNumbers(result);
|
|
||||||
result = redactGroupIds(result);
|
result = redactGroupIds(result);
|
||||||
result = redactPhoneNumbers(result);
|
result = redactPhoneNumbers(result);
|
||||||
result = redactSensitivePaths(result);
|
|
||||||
result = redactUuids(result);
|
result = redactUuids(result);
|
||||||
|
|
||||||
|
// These leave nothing
|
||||||
|
result = redactCardNumbers(result);
|
||||||
|
result = redactSensitivePaths(result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue