mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Fix env func
This commit is contained in:
parent
a1d348b768
commit
28f34a8380
1 changed files with 10 additions and 6 deletions
|
|
@ -8,25 +8,29 @@ import { getCombinedCaBundlePath } from "../../registryProxy/certBundle.js";
|
||||||
*
|
*
|
||||||
* @param {NodeJS.ProcessEnv} env - Env object
|
* @param {NodeJS.ProcessEnv} env - Env object
|
||||||
* @param {string} combinedCaPath - Path to the combined CA bundle
|
* @param {string} combinedCaPath - Path to the combined CA bundle
|
||||||
|
* @return {NodeJS.ProcessEnv} Modified environment object
|
||||||
*/
|
*/
|
||||||
function setPipXCaBundleEnvironmentVariables(env, combinedCaPath) {
|
function getPipXCaBundleEnvironmentVariables(env, combinedCaPath) {
|
||||||
|
let retVal = env;
|
||||||
|
|
||||||
// SSL_CERT_FILE: Used by Python SSL libraries and underlying HTTP clients
|
// SSL_CERT_FILE: Used by Python SSL libraries and underlying HTTP clients
|
||||||
if (env.SSL_CERT_FILE) {
|
if (env.SSL_CERT_FILE) {
|
||||||
ui.writeWarning("Safe-chain: User defined SSL_CERT_FILE found in environment. It will be overwritten.");
|
ui.writeWarning("Safe-chain: User defined SSL_CERT_FILE found in environment. It will be overwritten.");
|
||||||
}
|
}
|
||||||
env.SSL_CERT_FILE = combinedCaPath;
|
retVal.SSL_CERT_FILE = combinedCaPath;
|
||||||
|
|
||||||
// REQUESTS_CA_BUNDLE: Used by the requests library (may be used by tooling under pipx)
|
// REQUESTS_CA_BUNDLE: Used by the requests library (may be used by tooling under pipx)
|
||||||
if (env.REQUESTS_CA_BUNDLE) {
|
if (env.REQUESTS_CA_BUNDLE) {
|
||||||
ui.writeWarning("Safe-chain: User defined REQUESTS_CA_BUNDLE found in environment. It will be overwritten.");
|
ui.writeWarning("Safe-chain: User defined REQUESTS_CA_BUNDLE found in environment. It will be overwritten.");
|
||||||
}
|
}
|
||||||
env.REQUESTS_CA_BUNDLE = combinedCaPath;
|
retVal.REQUESTS_CA_BUNDLE = combinedCaPath;
|
||||||
|
|
||||||
// PIP_CERT: Some underlying pip operations may respect this
|
// PIP_CERT: Some underlying pip operations may respect this
|
||||||
if (env.PIP_CERT) {
|
if (env.PIP_CERT) {
|
||||||
ui.writeWarning("Safe-chain: User defined PIP_CERT found in environment. It will be overwritten.");
|
ui.writeWarning("Safe-chain: User defined PIP_CERT found in environment. It will be overwritten.");
|
||||||
}
|
}
|
||||||
env.PIP_CERT = combinedCaPath;
|
retVal.PIP_CERT = combinedCaPath;
|
||||||
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -41,14 +45,14 @@ export async function runPipX(command, args) {
|
||||||
const env = mergeSafeChainProxyEnvironmentVariables(process.env);
|
const env = mergeSafeChainProxyEnvironmentVariables(process.env);
|
||||||
|
|
||||||
const combinedCaPath = getCombinedCaBundlePath();
|
const combinedCaPath = getCombinedCaBundlePath();
|
||||||
setPipXCaBundleEnvironmentVariables(env, combinedCaPath);
|
const modifiedEnv = getPipXCaBundleEnvironmentVariables(env, combinedCaPath);
|
||||||
|
|
||||||
// Note: pipx uses HTTPS_PROXY and HTTP_PROXY environment variables for proxy configuration
|
// Note: pipx uses HTTPS_PROXY and HTTP_PROXY environment variables for proxy configuration
|
||||||
// These are already set by mergeSafeChainProxyEnvironmentVariables
|
// These are already set by mergeSafeChainProxyEnvironmentVariables
|
||||||
|
|
||||||
const result = await safeSpawn(command, args, {
|
const result = await safeSpawn(command, args, {
|
||||||
stdio: "inherit",
|
stdio: "inherit",
|
||||||
env,
|
env: modifiedEnv,
|
||||||
});
|
});
|
||||||
|
|
||||||
return { status: result.status };
|
return { status: result.status };
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue