mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 20:20:49 +00:00
Refactor PyPI logic and cleanup
This commit is contained in:
parent
e7cf3488b7
commit
e211f531c5
11 changed files with 450 additions and 138 deletions
|
|
@ -1,17 +1,21 @@
|
|||
import { runPip } from "./runPipCommand.js";
|
||||
import { getCurrentPipInvocation } from "./pipSettings.js";
|
||||
import { PIP_COMMAND } from "./pipSettings.js";
|
||||
|
||||
/**
|
||||
* @param {{ tool: string, args: string[] }} [context] - Optional context with tool name and args
|
||||
* @returns {import("../currentPackageManager.js").PackageManager}
|
||||
*/
|
||||
export function createPipPackageManager() {
|
||||
export function createPipPackageManager(context) {
|
||||
const tool = context?.tool || PIP_COMMAND;
|
||||
|
||||
return {
|
||||
/**
|
||||
* @param {string[]} args
|
||||
*/
|
||||
runCommand: (args) => {
|
||||
const invocation = getCurrentPipInvocation();
|
||||
const fullArgs = [...invocation.args, ...args];
|
||||
return runPip(invocation.command, fullArgs);
|
||||
// Args from main.js are already stripped of --safe-chain-* flags
|
||||
// We just pass the tool (e.g. "python3") and the args (e.g. ["-m", "pip", "install", ...])
|
||||
return runPip(tool, args);
|
||||
},
|
||||
// For pip, rely solely on MITM proxy to detect/deny downloads from known registries.
|
||||
isSupportedCommand: () => false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue