Skip to content

Commit 554f468

Browse files
committed
f
1 parent 308fe3a commit 554f468

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

.github/workflows/nodejs.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ jobs:
1111
name: Node.js
1212
uses: node-modules/github-actions/.github/workflows/node-test.yml@master
1313
with:
14-
os: 'ubuntu-latest'
1514
version: '16, 18, 20, 22, 23'
1615
secrets:
1716
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

test/fs.test.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,32 @@ describe('test/fs.test.ts', () => {
2323
assert.equal(stats.isDirectory(), true);
2424
assert.equal(stats.isFile(), false);
2525
assert.equal(await exists(__dirname + '/nonexistent'), false);
26+
});
27+
28+
it('should throw error on Linux', async () => {
29+
if (process.platform !== 'linux') {
30+
return;
31+
}
32+
await assert.rejects(async () => {
33+
await exists('/root/../../../../../etc/passwd');
34+
}, (err: any) => {
35+
// Error: EACCES: permission denied, stat '/root/../../../../../etc/passwd'
36+
assert.equal(err.code, 'EACCES');
37+
return true;
38+
});
39+
});
2640

27-
assert.equal(await exists('/root/../../../../../etc/passwd'), false);
41+
it('should throw error on win32', async () => {
42+
if (process.platform !== 'win32') {
43+
return;
44+
}
45+
await assert.rejects(async () => {
46+
await exists('C:\\Windows\\System32\\drivers\\etc\\hosts');
47+
}, (err: any) => {
48+
// Error: EACCES: permission denied, stat 'C:\Windows\System32\drivers\etc\hosts'
49+
assert.equal(err.code, 'EPERM');
50+
return true;
51+
});
2852
});
2953
});
3054
});

0 commit comments

Comments
 (0)