forked from Ikalus1988/MisakaNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathredact-compliance.js
More file actions
21 lines (19 loc) · 907 Bytes
/
Copy pathredact-compliance.js
File metadata and controls
21 lines (19 loc) · 907 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const r = require('../src/lib/redact');
const cases = [
{ name: 'jwt', input: 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.dozw' },
{ name: 'dsn', input: 'postgres://user:pass@localhost:5432/db' },
{ name: 'aws_key', input: 'AKIA1234567890123456' },
{ name: 'github_token', input: 'ghp_abcdefghijklmnopqrstuvwxyz1234567890' },
{ name: 'openai_key', input: 'sk-abcdefghijklmnopqrstuvwxyz123456' },
{ name: 'long_token', input: 'x' .repeat(45) },
{ name: 'authz_header', input: 'authorization: Bearer somevalue' },
];
let passed = 0;
for (const c of cases) {
const result = r.redact(c.input);
const ok = result.includes('REDACTED');
if (ok) passed++;
console.log(`${ok ? '✓' : '✗'} ${c.name}: ${result.slice(0, 70)}`);
}
console.log(`\n${passed}/${cases.length} patterns passed`);
process.exit(passed === cases.length ? 0 : 1);