Files
BetterDesk/web-nodejs/tests/logRedact.test.js
UNITRONIX 648a8d4f8a security(3.4): harden console and Go server for pre-release audit
Commit web-nodejs lockfile with tar override; CI uses npm ci and moderate npm audit.
Add LOG_LEVEL filtering and log redaction in Node console and Go server.
Validate WS tokens on bd-signal; require single-use token for remote-agent relay.
Limit active relay sessions per IP and block open enrollment without TLS.
2026-07-12 20:44:46 +02:00

27 lines
995 B
JavaScript

'use strict';
const { redactUrlForLog, redactUsernameForLog } = require('../lib/logRedact');
describe('logRedact', () => {
test('redactUrlForLog strips credentials', () => {
expect(redactUrlForLog('https://user:secret@example.com/path'))
.toBe('https://example.com/path');
});
test('redactUsernameForLog masks username', () => {
expect(redactUsernameForLog('admin')).toBe('a***n');
expect(redactUsernameForLog('')).toBe('(empty)');
});
test('sanitizeLogValue strips newlines', () => {
const { sanitizeLogValue } = require('../lib/logRedact');
expect(sanitizeLogValue('line1\nline2')).toBe('line1\\nline2');
});
test('redactAuditDetails masks username and secrets', () => {
const { redactAuditDetails } = require('../lib/logRedact');
expect(redactAuditDetails('Username: administrator')).toBe('Username: a***r');
expect(redactAuditDetails('token=abc123')).toBe('token=***');
});
});