mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Allow to exclude packages from the minimum package age
This commit is contained in:
parent
5898fc851a
commit
6815b62019
9 changed files with 387 additions and 1 deletions
|
|
@ -16,6 +16,7 @@ import { getEcoSystem } from "./settings.js";
|
|||
* @typedef {Object} SafeChainRegistryConfiguration
|
||||
* We cannot trust the input and should add the necessary validations.
|
||||
* @property {unknown | string[]} customRegistries
|
||||
* @property {unknown | string[]} minimumPackageAgeExclusions
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -127,6 +128,27 @@ export function getPipCustomRegistries() {
|
|||
return customRegistries.filter((item) => typeof item === "string");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the minimum package age exclusions from the config file
|
||||
* @returns {string[]}
|
||||
*/
|
||||
export function getNpmMinimumPackageAgeExclusions() {
|
||||
const config = readConfigFile();
|
||||
|
||||
if (!config || !config.npm) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const npmConfig = /** @type {SafeChainRegistryConfiguration} */ (config.npm);
|
||||
const exclusions = npmConfig.minimumPackageAgeExclusions;
|
||||
|
||||
if (!Array.isArray(exclusions)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return exclusions.filter((item) => typeof item === "string");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../api/aikido.js").MalwarePackage[]} data
|
||||
* @param {string | number} version
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue