This commit is contained in:
Reinier Criel 2025-10-22 06:59:32 -07:00
parent d0f2edec0a
commit f086aeb2be
6 changed files with 44 additions and 6 deletions

View file

@ -12,6 +12,7 @@ export async function main(args) {
await proxy.startServer();
try {
console.log(chalk.blueBright.bold("main.js: Scanning for malicious packages..."));
// This parses all the --safe-chain arguments and removes them from the args array
args = initializeCliArguments(args);

View file

@ -9,11 +9,14 @@ import {
createPnpxPackageManager,
} from "./pnpm/createPackageManager.js";
import { createYarnPackageManager } from "./yarn/createPackageManager.js";
import { createPipPackageManager } from "./pip/createPipPackageManager.js";
const state = {
packageManagerName: null,
};
const PIP_COMMANDS = new Set(["pip", "pip3"]);
export function initializePackageManager(packageManagerName) {
if (packageManagerName === "npm") {
state.packageManagerName = createNpmPackageManager();
@ -29,6 +32,8 @@ export function initializePackageManager(packageManagerName) {
state.packageManagerName = createBunPackageManager();
} else if (packageManagerName === "bunx") {
state.packageManagerName = createBunxPackageManager();
} else if (PIP_COMMANDS.has(packageManagerName)) {
state.packageManagerName = createPipPackageManager(packageManagerName);
} else {
throw new Error("Unsupported package manager: " + packageManagerName);
}

View file

@ -2,9 +2,14 @@ import { ui } from "../../environment/userInteraction.js";
import { safeSpawn } from "../../utils/safeSpawn.js";
import { mergeSafeChainProxyEnvironmentVariables } from "../../registryProxy/registryProxy.js";
export function createPipPackageManager() {
/**
* Creates a package manager interface for Python's pip package installer
*
* @param {string} [command="pip"] - The pip command to use (e.g., "pip", "pip3") defaults to "pip"
*/
export function createPipPackageManager(command = "pip") {
return {
runCommand: (args) => runPipCommand("pip3", args),
runCommand: (args) => runPipCommand(command, args),
// For pip, set proxy server
isSupportedCommand: () => false,

View file

@ -51,13 +51,14 @@ function bunx() {
}
function pip() {
wrapSafeChainCommand "pip" "aikido-pip" "$@"
wrapSafeChainCommand "pip" "aikido-pip" --target-version-major "2" "$@"
}
function pip3() {
wrapSafeChainCommand "pip3" "aikido-pip" "$@"
wrapSafeChainCommand "pip3" "aikido-pip" --target-version-major "3" "$@"
}
function npm() {
if [[ "$1" == "-v" || "$1" == "--version" ]] && [[ $# -eq 1 ]]; then
# If args is just -v or --version and nothing else, just run the npm version command