Fix command injection

This commit is contained in:
Sander Declerck 2025-07-18 11:15:21 +02:00
parent 8ffb0191f5
commit 41bf3252d9
No known key found for this signature in database
11 changed files with 116 additions and 29 deletions

View file

@ -15,7 +15,6 @@ describe("PowerShell Core shell integration", () => {
// Mock the helpers module
mock.module("../helpers.js", {
namedExports: {
execAndGetOutput: () => mockStartupFile,
doesExecutableExistOnSystem: () => true,
addLineToFile: (filePath, line) => {
if (!fs.existsSync(filePath)) {
@ -33,6 +32,13 @@ describe("PowerShell Core shell integration", () => {
}
});
// Mock child_process execSync
mock.module("child_process", {
namedExports: {
execSync: () => mockStartupFile,
},
});
// Import powershell module after mocking
powershell = (await import("./powershell.js")).default;
});