Skip to content

Commit 8230c73

Browse files
committed
security: remove node os from inline validation
1 parent acf99c9 commit 8230c73

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

packages/cli/src/agent/command-runner.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,6 @@ function buildInlineNodeValidationSource(sourceRoot: string, cwd: string, userSo
712712
const realFsp = require('node:fs/promises');
713713
const path = require('node:path');
714714
const url = require('node:url');
715-
const os = require('node:os');
716715
const realProcess = require('node:process');
717716
const ROOT = ${JSON.stringify(rootReal)};
718717
const CWD = ${JSON.stringify(cwdReal)};
@@ -831,7 +830,6 @@ function buildInlineNodeValidationSource(sourceRoot: string, cwd: string, userSo
831830
if (id === 'fs/promises') return safePromises;
832831
if (id === 'path') return path;
833832
if (id === 'url') return url;
834-
if (id === 'os') return os;
835833
if (id === 'process') return safeProcess;
836834
fail('module ' + moduleId + ' is not allowlisted');
837835
};

scripts/verify-command-runner.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,15 @@ if (node20Available) {
196196
assert.equal(result.outputTruncated, true)
197197
assert.equal(result.reason, 'output_limit_exceeded')
198198

199+
result = await runSafeCommand({ ...exactBase, executable: 'node', args: ['-e', "require('node:os')"] })
200+
assert.equal(result.status, 'failed')
201+
assert.match(result.stderr, /module node:os is not allowlisted/)
202+
203+
result = await runSafeCommand({ ...exactBase, executable: 'node', args: ['-e', "console.log(JSON.stringify({platform:process.platform,arch:process.arch}))"] })
204+
assert.equal(result.status, 'completed')
205+
assert(result.stdout.includes(process.platform))
206+
assert(result.stdout.includes(process.arch))
207+
199208
result = await runSafeCommand({ ...exactBase, executable: 'node', args: ['-e', "require('node:child_process')"] })
200209
assert.equal(result.status, 'failed')
201210
assert.match(result.stderr, /module node:child_process is not allowlisted/)

0 commit comments

Comments
 (0)