mirror of
https://github.com/UNITRONIX/BetterDesk.git
synced 2026-09-10 09:35:39 +00:00
648a8d4f8a
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.
27 lines
995 B
JavaScript
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=***');
|
|
});
|
|
});
|