mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-12 12:06:16 -08:00
fix(logging): redact sensitive map values
This commit is contained in:
1 parent
60ac519f45
commit
638c1a7951
2 files changed
+29
-4
No files matched your search
@@ -196,6 +196,28 @@ describe('redactSensitiveData', () => {
|
||||
expect(output).toContain('"status":200');
|
||||
});
|
||||
|
||||
it('redacts Map values selected by sensitive keys', () => {
|
||||
const authorization = 'map-authorization-secret';
|
||||
const password = 'map-password-secret';
|
||||
const headers = new Map([
|
||||
['Authorization', `Bearer ${authorization}`],
|
||||
['password', password],
|
||||
['requestId', 'diagnostic-request-id'],
|
||||
]);
|
||||
|
||||
const result = redactSensitiveData(headers);
|
||||
const output = serialized(result);
|
||||
|
||||
expect(output).not.toContain(authorization);
|
||||
expect(output).not.toContain(password);
|
||||
expect(output).toContain('diagnostic-request-id');
|
||||
expect(result).toEqual({
|
||||
Authorization: REDACTED_VALUE,
|
||||
password: REDACTED_VALUE,
|
||||
requestId: 'diagnostic-request-id',
|
||||
});
|
||||
});
|
||||
|
||||
it('redacts Xtream credentials in playback URL paths', () => {
|
||||
const username = 'xtream-path-user-secret';
|
||||
const password = 'xtream-path-password-secret';
|
||||
|
||||
@@ -357,10 +357,13 @@ export function redactSensitiveData(
|
||||
resolved.maxObjectKeys
|
||||
);
|
||||
for (const [key, entry] of mapEntries) {
|
||||
entries[visitString(String(key), depth + 1)] = visit(
|
||||
entry,
|
||||
depth + 1
|
||||
);
|
||||
const stringKey = String(key);
|
||||
const redactedKey = visitString(stringKey, depth + 1);
|
||||
entries[redactedKey] =
|
||||
isSensitiveKey(stringKey) &&
|
||||
!/[/:?=&]/u.test(stringKey)
|
||||
? REDACTED_VALUE
|
||||
: visit(entry, depth + 1);
|
||||
}
|
||||
if (input.size > resolved.maxObjectKeys) {
|
||||
entries['__truncatedKeys'] =
|
||||
|
||||
Reference in new issue
Block a user