mirror of
https://github.com/UNITRONIX/BetterDesk.git
synced 2026-09-10 09:35:39 +00:00
f346f891bc
Centralize path-segment validation in goApiProxy for fleet/commercialization/cross-platform routes while preserving RustDesk peer ID compatibility; sanitize panel JS output and cap audit Recent queries.
16 lines
561 B
JavaScript
16 lines
561 B
JavaScript
'use strict';
|
|
|
|
const { safeSegment } = require('../lib/goApiProxy');
|
|
|
|
describe('goApiProxy', () => {
|
|
test('safeSegment encodes valid RustDesk-style peer IDs', () => {
|
|
expect(safeSegment('1192137448', 'deviceId')).toBe('1192137448');
|
|
expect(safeSegment('peer-abc_1', 'deviceId')).toBe('peer-abc_1');
|
|
});
|
|
|
|
test('safeSegment rejects path-smuggling segments', () => {
|
|
expect(() => safeSegment('foo/bar', 'orgId')).toThrow(/Invalid orgId/i);
|
|
expect(() => safeSegment('..', 'orgId')).toThrow(/Invalid orgId/i);
|
|
});
|
|
});
|