mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Handle process exit better + some PR cleanup
This commit is contained in:
parent
bf97f089ca
commit
67304751bd
8 changed files with 21 additions and 9 deletions
|
|
@ -6,7 +6,9 @@ import { initializePackageManager } from "../src/packagemanager/currentPackageMa
|
|||
|
||||
const packageManagerName = "npm";
|
||||
initializePackageManager(packageManagerName, getNpmVersion());
|
||||
await main(process.argv.slice(2));
|
||||
var exitCode = await main(process.argv.slice(2));
|
||||
|
||||
process.exit(exitCode);
|
||||
|
||||
function getNpmVersion() {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -5,4 +5,6 @@ import { initializePackageManager } from "../src/packagemanager/currentPackageMa
|
|||
|
||||
const packageManagerName = "npx";
|
||||
initializePackageManager(packageManagerName, process.versions.node);
|
||||
await main(process.argv.slice(2));
|
||||
var exitCode = await main(process.argv.slice(2));
|
||||
|
||||
process.exit(exitCode);
|
||||
|
|
|
|||
|
|
@ -5,4 +5,6 @@ import { initializePackageManager } from "../src/packagemanager/currentPackageMa
|
|||
|
||||
const packageManagerName = "pnpm";
|
||||
initializePackageManager(packageManagerName, process.versions.node);
|
||||
await main(process.argv.slice(2));
|
||||
var exitCode = await main(process.argv.slice(2));
|
||||
|
||||
process.exit(exitCode);
|
||||
|
|
|
|||
|
|
@ -5,4 +5,6 @@ import { initializePackageManager } from "../src/packagemanager/currentPackageMa
|
|||
|
||||
const packageManagerName = "pnpx";
|
||||
initializePackageManager(packageManagerName, process.versions.node);
|
||||
await main(process.argv.slice(2));
|
||||
var exitCode = await main(process.argv.slice(2));
|
||||
|
||||
process.exit(exitCode);
|
||||
|
|
|
|||
|
|
@ -5,4 +5,6 @@ import { initializePackageManager } from "../src/packagemanager/currentPackageMa
|
|||
|
||||
const packageManagerName = "yarn";
|
||||
initializePackageManager(packageManagerName, process.versions.node);
|
||||
await main(process.argv.slice(2));
|
||||
var exitCode = await main(process.argv.slice(2));
|
||||
|
||||
process.exit(exitCode);
|
||||
|
|
|
|||
|
|
@ -27,5 +27,5 @@ export async function main(args) {
|
|||
await proxy.stopServer();
|
||||
proxy.verifyNoMaliciousPackages();
|
||||
|
||||
process.exit(result.status);
|
||||
return result.status;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export function dryRunScanner(scannerOptions) {
|
|||
};
|
||||
}
|
||||
|
||||
async function scanDependencies(scannerOptions, args) {
|
||||
function scanDependencies(scannerOptions, args) {
|
||||
let dryRunArgs = args;
|
||||
|
||||
if (scannerOptions?.dryRunCommand) {
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ export function mergeSafeChainProxyEnvironmentVariables(env) {
|
|||
const upperKey = key.toUpperCase();
|
||||
|
||||
if (!proxyEnv[upperKey]) {
|
||||
proxyEnv[upperKey] = env[key];
|
||||
proxyEnv[key] = env[key];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -104,7 +104,8 @@ function handleConnect(req, clientSocket, head) {
|
|||
async function isAllowedUrl(url) {
|
||||
const { packageName, version } = parsePackageFromUrl(url);
|
||||
|
||||
// This happens when the URL is not a tarball download url.
|
||||
// packageName and version are undefined when the URL is not a package download
|
||||
// In that case, we can allow the request to proceed
|
||||
if (!packageName || !version) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -123,6 +124,7 @@ async function isAllowedUrl(url) {
|
|||
|
||||
function verifyNoMaliciousPackages() {
|
||||
if (state.blockedRequests.length === 0) {
|
||||
// No malicious packages were blocked, so nothing to block
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue