Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Dec 22, 2024
1 parent 308fe3a commit 554f468
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
1 change: 0 additions & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ jobs:
name: Node.js
uses: node-modules/github-actions/.github/workflows/node-test.yml@master
with:
os: 'ubuntu-latest'
version: '16, 18, 20, 22, 23'
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
26 changes: 25 additions & 1 deletion test/fs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,32 @@ describe('test/fs.test.ts', () => {
assert.equal(stats.isDirectory(), true);
assert.equal(stats.isFile(), false);
assert.equal(await exists(__dirname + '/nonexistent'), false);
});

it('should throw error on Linux', async () => {
if (process.platform !== 'linux') {
return;
}
await assert.rejects(async () => {
await exists('/root/../../../../../etc/passwd');
}, (err: any) => {
// Error: EACCES: permission denied, stat '/root/../../../../../etc/passwd'
assert.equal(err.code, 'EACCES');
return true;
});
});

assert.equal(await exists('/root/../../../../../etc/passwd'), false);
it('should throw error on win32', async () => {
if (process.platform !== 'win32') {
return;
}
await assert.rejects(async () => {
await exists('C:\\Windows\\System32\\drivers\\etc\\hosts');
}, (err: any) => {
// Error: EACCES: permission denied, stat 'C:\Windows\System32\drivers\etc\hosts'
assert.equal(err.code, 'EPERM');
return true;
});
});
});
});

0 comments on commit 554f468

Please sign in to comment.