Privacy: Additional tweaks to debug log generation

This commit is contained in:
Scott Nonnenberg 2025-07-23 04:08:36 +10:00 committed by GitHub
commit 510b4f2df7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 31 additions and 38 deletions

View file

@ -12,7 +12,7 @@ describe('Privacy', () => {
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' +
'This is a log line with a card number 1234-1234-1234-12\n' +
'and another one 1234 1234 1234 1234 123';
const actual = Privacy.redactCardNumbers(text);
@ -24,8 +24,6 @@ describe('Privacy', () => {
it('should redact weird credit card numbers', () => {
const text =
'12341234123\n' +
'123412341234\n' +
'1234123412341\n' +
'12341234123412\n' +
'123412341234123\n' +
@ -34,35 +32,29 @@ describe('Privacy', () => {
'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' +
'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-3\n' +
'123-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\n' +
'123-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\n' +
'123-4-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\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 4\n' +
'123 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\n' +
'123 4 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 2 3 4\n' +
'123a412 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 a 2 3 4\n' +
'';
const actual = Privacy.redactCardNumbers(text);
const expected =
'12341234123\n' +
'[REDACTED]\n' +
'[REDACTED]\n' +
'1234123412341\n' +
'[REDACTED]\n' +
'[REDACTED]\n' +
'[REDACTED]\n' +
@ -70,9 +62,7 @@ describe('Privacy', () => {
'[REDACTED]\n' +
'[REDACTED]\n' +
'[REDACTED]4\n' +
'1-2-3-4-1-2-3-4-1-2-3\n' +
'[REDACTED]\n' +
'[REDACTED]\n' +
'123-4-1-2-3-4-1-2-3-4-1\n' +
'[REDACTED]\n' +
'[REDACTED]\n' +
'[REDACTED]\n' +
@ -80,9 +70,7 @@ describe('Privacy', () => {
'[REDACTED]\n' +
'[REDACTED]\n' +
'[REDACTED]-4\n' +
'1 2 3 4 1 2 3 4 1 2 3\n' +
'[REDACTED]\n' +
'[REDACTED]\n' +
'123 4 1 2 3 4 1 2 3 4 1\n' +
'[REDACTED]\n' +
'[REDACTED]\n' +
'[REDACTED]\n' +
@ -90,7 +78,7 @@ describe('Privacy', () => {
'[REDACTED]\n' +
'[REDACTED]\n' +
'[REDACTED] 4\n' +
'1 2 3 a [REDACTED]\n' +
'123a[REDACTED]\n' +
'[REDACTED] a 2 3 4\n' +
'';
assert.equal(actual, expected);
@ -98,6 +86,7 @@ describe('Privacy', () => {
it('should not redact things that are close to credit card numbers', () => {
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
1234123 412341234
1e23412341234
@ -105,6 +94,7 @@ describe('Privacy', () => {
const actual = Privacy.redactCardNumbers(text);
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
1234123 412341234
1e23412341234