mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Improve comments
This commit is contained in:
parent
03d67d92be
commit
149a28e0dc
3 changed files with 4 additions and 5 deletions
|
|
@ -259,8 +259,9 @@ export async function validatePowerShellExecutionPolicy(shellExecutableName) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// For Windows PowerShell (5.1), clean PSModulePath to avoid conflicts with PowerShell 7 modules
|
// For Windows PowerShell (5.1), clean PSModulePath to avoid conflicts with PowerShell 7 modules
|
||||||
// When PowerShell 7 is installed, it adds its module paths to PSModulePath, causing
|
// When safe-chain is invoked from PowerShell 7, it sets its module paths to PSModulePath, causing
|
||||||
// Windows PowerShell to try loading incompatible PowerShell 7 modules (TypeData conflicts)
|
// Windows PowerShell to try loading incompatible PowerShell 7 modules.
|
||||||
|
// Setting the environment to Windows PowerShell's modules fixes this.
|
||||||
let spawnOptions;
|
let spawnOptions;
|
||||||
if (shellExecutableName === "powershell") {
|
if (shellExecutableName === "powershell") {
|
||||||
const userProfile = process.env.USERPROFILE || "";
|
const userProfile = process.env.USERPROFILE || "";
|
||||||
|
|
@ -283,7 +284,7 @@ export async function validatePowerShellExecutionPolicy(shellExecutableName) {
|
||||||
const commandResult = await safeSpawn(
|
const commandResult = await safeSpawn(
|
||||||
shellExecutableName,
|
shellExecutableName,
|
||||||
["-Command", "Get-ExecutionPolicy"],
|
["-Command", "Get-ExecutionPolicy"],
|
||||||
spawnOptions
|
spawnOptions,
|
||||||
);
|
);
|
||||||
|
|
||||||
const policy = commandResult.stdout.trim();
|
const policy = commandResult.stdout.trim();
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@ function teardown(tools) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setup() {
|
async function setup() {
|
||||||
// Check execution policy
|
|
||||||
const { isValid, policy } =
|
const { isValid, policy } =
|
||||||
await validatePowerShellExecutionPolicy(executableName);
|
await validatePowerShellExecutionPolicy(executableName);
|
||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@ function teardown(tools) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setup() {
|
async function setup() {
|
||||||
// Check execution policy
|
|
||||||
const { isValid, policy } =
|
const { isValid, policy } =
|
||||||
await validatePowerShellExecutionPolicy(executableName);
|
await validatePowerShellExecutionPolicy(executableName);
|
||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue