fix: address remaining CodeQL alerts (#332)
This commit is contained in:
25
src/utils/execFileNoThrow.test.ts
Normal file
25
src/utils/execFileNoThrow.test.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { expect, test } from 'bun:test'
|
||||
import { execFileNoThrowWithCwd } from './execFileNoThrow.js'
|
||||
|
||||
test('execFileNoThrowWithCwd rejects shell-like executable names', async () => {
|
||||
const result = await execFileNoThrowWithCwd('openclaude && whoami', [])
|
||||
|
||||
expect(result.code).toBe(1)
|
||||
expect(result.error).toContain('Unsafe executable')
|
||||
})
|
||||
|
||||
test('execFileNoThrowWithCwd rejects cwd values with control characters', async () => {
|
||||
const result = await execFileNoThrowWithCwd(process.execPath, ['--version'], {
|
||||
cwd: 'C:\\repo\nmalicious',
|
||||
})
|
||||
|
||||
expect(result.code).toBe(1)
|
||||
expect(result.error).toContain('Unsafe working directory')
|
||||
})
|
||||
|
||||
test('execFileNoThrowWithCwd rejects arguments with control characters', async () => {
|
||||
const result = await execFileNoThrowWithCwd(process.execPath, ['--version\nmalicious'])
|
||||
|
||||
expect(result.code).toBe(1)
|
||||
expect(result.error).toContain('Unsafe argument')
|
||||
})
|
||||
Reference in New Issue
Block a user