fix: redigování citlivých dat před odesláním do Sentry
CI / Generate TypeScript types (push) Successful in 10s
CI / Server unit tests (push) Successful in 22s
CI / Build server (push) Successful in 27s
CI / Build client (push) Successful in 39s
CI / Playwright E2E tests (push) Successful in 1m28s
CI / Build and push Docker image (push) Successful in 44s
CI / Notify (push) Successful in 2s

Console eventy nesou celé argumenty console.error — u axios chyb tedy
i config s hlavičkami a request body (Bolt token, Gotify/NTFY klíče).
beforeSend nově rekurzivně rediguje citlivé klíče a tokeny v řetězcích
napříč extra/breadcrumbs/contexts/request/exception.
This commit is contained in:
batmanisko committed 2026-07-14 11:30:03 +02:00
1 parent f8c5d28f47
commit 9ea2916c7a
2 files changed
+60

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
import { scrubEventData } from '../instrument';
describe('scrubEventData', () => {
test('rediguje citlivé klíče (hlavičky, tokeny, API klíče)', () => {
const scrubbed = scrubEventData({
headers: { Authorization: 'Bearer abc123', 'X-Gotify-Key': 'gk1', accept: 'application/json' },
data: { token: 'deadbeef'.repeat(8) },
apiKey: 'k',
}) as any;
expect(scrubbed.headers.Authorization).toBe('[redacted]');
expect(scrubbed.headers['X-Gotify-Key']).toBe('[redacted]');
expect(scrubbed.headers.accept).toBe('application/json');
expect(scrubbed.data.token).toBe('[redacted]');
expect(scrubbed.apiKey).toBe('[redacted]');
});
test('rediguje tokeny uvnitř řetězců (query parametry, JSON body)', () => {
expect(scrubEventData('https://ntfy.example.com/topic?token=tajny&x=1')).toBe(
'https://ntfy.example.com/topic?token=[redacted]&x=1'
);
expect(scrubEventData('{"token":"deadbeef","other":1}')).toBe('{"token":"[redacted]","other":1}');
});
test('nechává běžná data beze změny včetně vnořených polí', () => {
const input = { breadcrumbs: [{ message: 'Bolt tracking: stav accepted → preparing', level: 'log' }], count: 2 };
expect(scrubEventData(input)).toEqual(input);
});
});