Skip to content

Commit 645a102

Browse files
author
Christian-Sidak
committed
test(filesystem): add UNC path test cases for isPathWithinAllowedDirectories
1 parent be89ae6 commit 645a102

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

src/filesystem/__tests__/path-validation.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,28 @@ describe('Path Validation', () => {
439439
expect(isPathWithinAllowedDirectories('\\\\other\\share\\project', allowed)).toBe(false);
440440
}
441441
});
442+
443+
it('allows UNC path within allowed UNC directory', () => {
444+
if (path.sep === '\\') {
445+
const allowed = ['\\\\server\\share\\project'];
446+
expect(isPathWithinAllowedDirectories('\\\\server\\share\\project\\subdir\\file.txt', allowed)).toBe(true);
447+
}
448+
});
449+
450+
it('blocks UNC path outside allowed UNC directory', () => {
451+
if (path.sep === '\\') {
452+
const allowed = ['\\\\server\\share\\project'];
453+
expect(isPathWithinAllowedDirectories('\\\\server\\share\\other', allowed)).toBe(false);
454+
expect(isPathWithinAllowedDirectories('\\\\other\\share\\project', allowed)).toBe(false);
455+
}
456+
});
457+
458+
it('allows exact UNC path match', () => {
459+
if (path.sep === '\\') {
460+
const allowed = ['\\\\server\\share\\project'];
461+
expect(isPathWithinAllowedDirectories('\\\\server\\share\\project', allowed)).toBe(true);
462+
}
463+
});
442464
});
443465

444466
describe('Symlink Tests', () => {

0 commit comments

Comments
 (0)