@coana-tech/cli 15.1.1 → 15.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.mjs +170 -22
- package/package.json +1 -1
- package/repos/coana-tech/goana/bin/goana-darwin-amd64.gz +0 -0
- package/repos/coana-tech/goana/bin/goana-darwin-arm64.gz +0 -0
- package/repos/coana-tech/goana/bin/goana-linux-amd64.gz +0 -0
- package/repos/coana-tech/goana/bin/goana-linux-arm64.gz +0 -0
- package/repos/coana-tech/javap-service/javap-service.jar +0 -0
package/cli.mjs
CHANGED
|
@@ -212004,6 +212004,111 @@ function handleNexeBinaryMode() {
|
|
|
212004
212004
|
}
|
|
212005
212005
|
}
|
|
212006
212006
|
|
|
212007
|
+
// ../web-compat-utils/src/package-manager-utils.ts
|
|
212008
|
+
var ALL_PACKAGE_MANAGERS = [
|
|
212009
|
+
"NPM",
|
|
212010
|
+
"PNPM",
|
|
212011
|
+
"YARN",
|
|
212012
|
+
"RUSH",
|
|
212013
|
+
"MAVEN",
|
|
212014
|
+
"GRADLE",
|
|
212015
|
+
"SBT",
|
|
212016
|
+
"POETRY",
|
|
212017
|
+
"PIP_REQUIREMENTS",
|
|
212018
|
+
"PIPENV",
|
|
212019
|
+
"GO",
|
|
212020
|
+
"CARGO",
|
|
212021
|
+
"NUGET",
|
|
212022
|
+
"RUBYGEMS",
|
|
212023
|
+
"COMPOSER"
|
|
212024
|
+
];
|
|
212025
|
+
var FILTERABLE_PACKAGE_MANAGER_SET = new Set(ALL_PACKAGE_MANAGERS);
|
|
212026
|
+
function getFilterablePackageManagers() {
|
|
212027
|
+
return ALL_PACKAGE_MANAGERS;
|
|
212028
|
+
}
|
|
212029
|
+
function isFilterablePackageManager(value2) {
|
|
212030
|
+
return FILTERABLE_PACKAGE_MANAGER_SET.has(value2);
|
|
212031
|
+
}
|
|
212032
|
+
var PURL_TYPE_TO_SOLE_PACKAGE_MANAGER = {
|
|
212033
|
+
["golang" /* GOLANG */]: "GO",
|
|
212034
|
+
["cargo" /* CARGO */]: "CARGO",
|
|
212035
|
+
["nuget" /* NUGET */]: "NUGET",
|
|
212036
|
+
["gem" /* GEM */]: "RUBYGEMS",
|
|
212037
|
+
["composer" /* COMPOSER */]: "COMPOSER"
|
|
212038
|
+
};
|
|
212039
|
+
function basenameOf(file) {
|
|
212040
|
+
const lastSlash = Math.max(file.lastIndexOf("/"), file.lastIndexOf("\\"));
|
|
212041
|
+
return lastSlash === -1 ? file : file.slice(lastSlash + 1);
|
|
212042
|
+
}
|
|
212043
|
+
function getPackageManagersForManifestFile(file) {
|
|
212044
|
+
const base = basenameOf(file);
|
|
212045
|
+
switch (base) {
|
|
212046
|
+
case "package-lock.json":
|
|
212047
|
+
case "npm-shrinkwrap.json":
|
|
212048
|
+
return ["NPM"];
|
|
212049
|
+
case "pnpm-lock.yaml":
|
|
212050
|
+
case "pnpm-lock.yml":
|
|
212051
|
+
return ["PNPM"];
|
|
212052
|
+
case "yarn.lock":
|
|
212053
|
+
return ["YARN"];
|
|
212054
|
+
case "pom.xml":
|
|
212055
|
+
return ["MAVEN"];
|
|
212056
|
+
case "gradle.lockfile":
|
|
212057
|
+
case "build.gradle":
|
|
212058
|
+
case "build.gradle.kts":
|
|
212059
|
+
case "settings.gradle":
|
|
212060
|
+
case "settings.gradle.kts":
|
|
212061
|
+
return ["GRADLE"];
|
|
212062
|
+
case "build.sbt":
|
|
212063
|
+
return ["SBT"];
|
|
212064
|
+
case "poetry.lock":
|
|
212065
|
+
return ["POETRY"];
|
|
212066
|
+
case "Pipfile":
|
|
212067
|
+
case "Pipfile.lock":
|
|
212068
|
+
return ["PIPENV"];
|
|
212069
|
+
case "go.mod":
|
|
212070
|
+
case "go.sum":
|
|
212071
|
+
return ["GO"];
|
|
212072
|
+
case "Cargo.toml":
|
|
212073
|
+
case "Cargo.lock":
|
|
212074
|
+
return ["CARGO"];
|
|
212075
|
+
case "packages.config":
|
|
212076
|
+
return ["NUGET"];
|
|
212077
|
+
case "Gemfile":
|
|
212078
|
+
case "Gemfile.lock":
|
|
212079
|
+
return ["RUBYGEMS"];
|
|
212080
|
+
case "composer.json":
|
|
212081
|
+
case "composer.lock":
|
|
212082
|
+
return ["COMPOSER"];
|
|
212083
|
+
}
|
|
212084
|
+
if (base.endsWith(".sbt")) return ["SBT"];
|
|
212085
|
+
if (base.endsWith(".csproj") || base.endsWith(".fsproj") || base.endsWith(".vbproj")) return ["NUGET"];
|
|
212086
|
+
if (base.endsWith(".gemspec")) return ["RUBYGEMS"];
|
|
212087
|
+
if (/^requirements[\w.-]*\.txt$/.test(base)) return ["PIP_REQUIREMENTS"];
|
|
212088
|
+
const normalized = file.replace(/\\/g, "/");
|
|
212089
|
+
if (/(^|\/)requirements\/[^/]+\.txt$/.test(normalized)) return ["PIP_REQUIREMENTS"];
|
|
212090
|
+
return [];
|
|
212091
|
+
}
|
|
212092
|
+
function getPackageManagersFromManifestFiles(manifestFiles, purlType) {
|
|
212093
|
+
const result = /* @__PURE__ */ new Set();
|
|
212094
|
+
for (const file of manifestFiles ?? []) {
|
|
212095
|
+
for (const pm of getPackageManagersForManifestFile(file)) {
|
|
212096
|
+
result.add(pm);
|
|
212097
|
+
}
|
|
212098
|
+
}
|
|
212099
|
+
if (result.size === 0 && purlType != null) {
|
|
212100
|
+
const fallback = PURL_TYPE_TO_SOLE_PACKAGE_MANAGER[purlType];
|
|
212101
|
+
if (fallback) result.add(fallback);
|
|
212102
|
+
}
|
|
212103
|
+
return result;
|
|
212104
|
+
}
|
|
212105
|
+
function getPackageManagersForArtifact(artifact) {
|
|
212106
|
+
return getPackageManagersFromManifestFiles(
|
|
212107
|
+
(artifact.manifestFiles ?? []).map((ref) => ref.file),
|
|
212108
|
+
artifact.type
|
|
212109
|
+
);
|
|
212110
|
+
}
|
|
212111
|
+
|
|
212007
212112
|
// ../../node_modules/.pnpm/kleur@4.1.5/node_modules/kleur/index.mjs
|
|
212008
212113
|
var FORCE_COLOR;
|
|
212009
212114
|
var NODE_DISABLE_COLORS;
|
|
@@ -234940,10 +235045,11 @@ async function computeFixesAndUpgradePurls(path9, options, logFile) {
|
|
|
234940
235045
|
}
|
|
234941
235046
|
return { type: "selected-vulnerabilities-do-not-affect-the-current-project" };
|
|
234942
235047
|
}
|
|
234943
|
-
const filteredFixDetails =
|
|
235048
|
+
const filteredFixDetails = filterFixDetails(apiResponse.fixDetails, options.purlTypes, options.packageManagers);
|
|
234944
235049
|
const hadFixesBeforeFilter = Object.values(apiResponse.fixDetails).some(hasFixData);
|
|
234945
235050
|
const hasFixesAfterFilter = Object.values(filteredFixDetails).some(hasFixData);
|
|
234946
|
-
|
|
235051
|
+
const hasAnyFilter = options.purlTypes != null || options.packageManagers != null;
|
|
235052
|
+
if (hasAnyFilter && hadFixesBeforeFilter && !hasFixesAfterFilter) {
|
|
234947
235053
|
logger.info("There is no overlap between the requested fixes and the detected vulnerabilities");
|
|
234948
235054
|
logger.info("Consider running the tool again, requesting a fix for one of the detected vulnerabilities");
|
|
234949
235055
|
const detectedList = apiResponse.allDetectedGhsas ?? Object.keys(apiResponse.fixDetails);
|
|
@@ -235024,26 +235130,47 @@ async function computeFixesAndUpgradePurls(path9, options, logFile) {
|
|
|
235024
235130
|
function hasFixData(detail) {
|
|
235025
235131
|
return (detail.type === "fixFound" || detail.type === "partialFixFound") && (detail.value.fixDetails?.fixes.length ?? 0) > 0;
|
|
235026
235132
|
}
|
|
235027
|
-
function
|
|
235028
|
-
if (!purlTypes)
|
|
235133
|
+
function filterFixDetails(fixDetails, purlTypes, packageManagers) {
|
|
235134
|
+
if (!purlTypes && !packageManagers)
|
|
235029
235135
|
return fixDetails;
|
|
235030
|
-
const
|
|
235031
|
-
const
|
|
235032
|
-
|
|
235033
|
-
|
|
235034
|
-
|
|
235136
|
+
const allowedTypes = purlTypes ? new Set(purlTypes) : void 0;
|
|
235137
|
+
const tryParse = (purl) => {
|
|
235138
|
+
try {
|
|
235139
|
+
return import_packageurl_js.PackageURL.fromString(purl);
|
|
235140
|
+
} catch (err) {
|
|
235141
|
+
logger.warn(`Skipping purl that failed to parse: ${purl} (${err?.message ?? "unknown error"})`);
|
|
235142
|
+
return void 0;
|
|
235143
|
+
}
|
|
235144
|
+
};
|
|
235145
|
+
const matches = (purl, manifestFiles, ghsa) => {
|
|
235146
|
+
const parsed = tryParse(purl);
|
|
235147
|
+
if (parsed === void 0)
|
|
235148
|
+
return true;
|
|
235149
|
+
if (allowedTypes) {
|
|
235150
|
+
const purlType = toPurlType(parsed.type);
|
|
235151
|
+
if (purlType === void 0 || !allowedTypes.has(purlType)) {
|
|
235152
|
+
logger.warn(`Skipping upgrade for ${purl} (${ghsa}) - type '${parsed.type}' not in specified types: ${purlTypes.join(", ")}`);
|
|
235153
|
+
return false;
|
|
235154
|
+
}
|
|
235155
|
+
}
|
|
235156
|
+
if (packageManagers) {
|
|
235157
|
+
const pms = getPackageManagersFromManifestFiles(manifestFiles, parsed.type);
|
|
235158
|
+
if (pms.size === 0) {
|
|
235159
|
+
logger.warn(`Could not determine package manager for ${purl} (${ghsa}) from manifest files [${manifestFiles.join(", ") || "none"}] \u2014 including in --package-managers results`);
|
|
235160
|
+
return true;
|
|
235161
|
+
}
|
|
235162
|
+
if (!packageManagers.some((pm) => pms.has(pm))) {
|
|
235163
|
+
logger.warn(`Skipping upgrade for ${purl} (${ghsa}) - package manager(s) [${[...pms].join(", ")}] not in specified package managers: ${packageManagers.join(", ")}`);
|
|
235164
|
+
return false;
|
|
235165
|
+
}
|
|
235166
|
+
}
|
|
235167
|
+
return true;
|
|
235035
235168
|
};
|
|
235036
235169
|
const filtered = {};
|
|
235037
235170
|
for (const [ghsa, detail] of Object.entries(fixDetails)) {
|
|
235038
235171
|
if (detail.type === "fixFound" || detail.type === "partialFixFound") {
|
|
235039
|
-
const filteredFixes = (detail.value.fixDetails?.fixes ?? []).filter((fix) =>
|
|
235040
|
-
|
|
235041
|
-
return true;
|
|
235042
|
-
const parsed = import_packageurl_js.PackageURL.fromString(fix.purl);
|
|
235043
|
-
logger.warn(`Skipping upgrade for ${fix.purl} (${ghsa}) - type '${parsed.type}' not in specified types: ${purlTypes.join(", ")}`);
|
|
235044
|
-
return false;
|
|
235045
|
-
});
|
|
235046
|
-
const filteredUnfixable = detail.type === "partialFixFound" ? (detail.value.fixDetails?.unfixablePurls ?? []).filter((u8) => matchesType(u8.purl)) : void 0;
|
|
235172
|
+
const filteredFixes = (detail.value.fixDetails?.fixes ?? []).filter((fix) => matches(fix.purl, fix.manifestFiles, ghsa));
|
|
235173
|
+
const filteredUnfixable = detail.type === "partialFixFound" ? (detail.value.fixDetails?.unfixablePurls ?? []).filter((u8) => matches(u8.purl, u8.manifestFiles, ghsa)) : void 0;
|
|
235047
235174
|
filtered[ghsa] = {
|
|
235048
235175
|
...detail,
|
|
235049
235176
|
value: {
|
|
@@ -235056,7 +235183,7 @@ function filterFixDetailsByPurlTypes(fixDetails, purlTypes) {
|
|
|
235056
235183
|
}
|
|
235057
235184
|
};
|
|
235058
235185
|
} else if (detail.type === "fixNotApplicable" || detail.type === "noFixAvailable") {
|
|
235059
|
-
const filteredVuln = (detail.value.vulnerableArtifacts ?? []).filter((v) =>
|
|
235186
|
+
const filteredVuln = (detail.value.vulnerableArtifacts ?? []).filter((v) => matches(v.purl, v.manifestFiles, ghsa));
|
|
235060
235187
|
filtered[ghsa] = {
|
|
235061
235188
|
...detail,
|
|
235062
235189
|
value: { ...detail.value, vulnerableArtifacts: filteredVuln }
|
|
@@ -252288,7 +252415,7 @@ async function onlineScan(dependencyTree, apiKey, timeout) {
|
|
|
252288
252415
|
}
|
|
252289
252416
|
|
|
252290
252417
|
// dist/version.js
|
|
252291
|
-
var version3 = "15.
|
|
252418
|
+
var version3 = "15.2.0";
|
|
252292
252419
|
|
|
252293
252420
|
// dist/cli-core.js
|
|
252294
252421
|
var { mapValues, omit, partition, pickBy: pickBy2 } = import_lodash15.default;
|
|
@@ -253671,6 +253798,16 @@ async function writeAnalysisDebugInfo(outputFilePath, ecosystemToWorkspaceToVuln
|
|
|
253671
253798
|
|
|
253672
253799
|
// dist/index.js
|
|
253673
253800
|
handleNexeBinaryMode();
|
|
253801
|
+
function normalizeAndValidatePackageManagers(values) {
|
|
253802
|
+
if (!values)
|
|
253803
|
+
return void 0;
|
|
253804
|
+
const normalized = values.map((v) => v.toUpperCase());
|
|
253805
|
+
const invalid = normalized.filter((v) => !isFilterablePackageManager(v));
|
|
253806
|
+
if (invalid.length > 0) {
|
|
253807
|
+
throw new Error(`Invalid package manager(s): ${invalid.join(", ")}. Supported values are: ${getFilterablePackageManagers().join(", ")}`);
|
|
253808
|
+
}
|
|
253809
|
+
return normalized;
|
|
253810
|
+
}
|
|
253674
253811
|
var program2 = new Command();
|
|
253675
253812
|
var run2 = new Command();
|
|
253676
253813
|
run2.name("run").argument("<path>", "File system path to folder containing the project").option("-o, --output-dir <path>", "Write json report to <path>/coana-report.json").option("-d, --debug", "Enable debug logging", false).option("-s, --silent", "Silence all debug/warning output", false).option("--silent-spinner", "Silence spinner", "CI" in process.env || !process.stdin.isTTY).option("-p, --print-report", "Print the report to the console", false).option("--offline-database <path>", "Path to a coana-offline-db.json file for running the CLI without internet connectivity", void 0).option("-t, --timeout <timeout>", "Set API <timeout> in milliseconds to Coana backend.", "300000").option("-a, --analysis-timeout <timeout>", "Set <timeout> in seconds for each reachability analysis run").option("--memory-limit <memoryInMB>", "Set memory limit for analysis to <memoryInMB> megabytes of memory.", "8192").option("-c, --concurrency <concurrency>", "Set the maximum number of concurrent reachability analysis runs. It's recommended to choose a concurrency level that ensures that each analysis run has at least the --memory-limit amount of memory available. NPM reachability analysis does not support concurrent execution, so the concurrency level is ignored for NPM.", "1").option("--api-key <key>", "Set the Coana dashboard API key. By setting you also enable the dashboard integration.").addOption(new Option("--write-report-to-file", "Write the report dashboard-compatible report to dashboard-report.json. This report may help the Coana team debug issues with the report insertion mechanism.").default(false).hideHelp()).option("--project-name <repoName>", "Set the name of the repository. Used for dashboard integration.").option("--repo-url <repoUrl>", "Set the URL of the repository. Used for dashboard integration.").option("--include-dirs <relativeDirs...>", "globs for directories to include from the detection of subprojects (space-separated)(use relative paths from the project root). Notice, projects that are not included may still be scanned if they are referenced from included projects.").option("--exclude-dirs <relativeDirs...>", "globs for directories to exclude from the detection of subprojects (space-separated)(use relative paths from the project root). Notice, excluded projects may still be scanned if they are referenced from non-excluded projects.").option("--disable-analysis-splitting", "Limits Coana to at most 1 reachability analysis run per workspace").option("--print-analysis-log-file", "Store log output from the JavaScript/TypeScript reachability analysis in the file js-analysis.log file in the root of each workspace", false).option("--entry-points <entryPoints...>", "List of files to analyze for root workspace. The reachability analysis automatically analyzes all files used by the entry points. If not provided, all JavaScript and TypeScript files are considered entry points. For non-root workspaces, all JavaScript and TypeScript files are analyzed as well.").option("--include-projects-with-no-reachability-support", "Also runs Coana on projects where we support traditional SCA, but does not yet support reachability analysis.", false).option("--ecosystems <ecosystems...>", "List of ecosystems to analyze (space-separated). Currently NPM, PIP, MAVEN, NUGET and GO are supported. Default is all supported ecosystems.").addOption(new Option("--purl-types <purlTypes...>", "List of PURL types to analyze (space-separated). Currently npm, pypi, maven, nuget, golang and cargo are supported. Default is all supported purl types.").hideHelp()).option("--changed-files <files...>", "List of files that have changed. If provided, Coana only analyzes workspaces and modules that contain changed files.").option("--disable-report-submission", "Disable the submission of the report to the Coana dashboard. Used by the pipeline blocking feature.", false).option("--disable-analytics-sharing", "Disable analytics sharing.", false).option("--provider-project <path>", "File system path to folder containing the provider project (Only supported for Maven, Gradle, and SBT)").option("--provider-workspaces <dirs...>", "List of workspaces that build the provided runtime environment (Only supported for Maven, Gradle, and SBT)", (paths) => paths.split(" ")).option("--lightweight-reachability", "Runs Coana in lightweight mode. This increases analysis speed but also raises the risk of Coana misclassifying the reachability of certain complex vulnerabilities. Recommended only for use with Coana Guardrail mode.", false).addOption(new Option("--run-without-docker", "Run package managers and reachability analyzers without using docker").default(process.env.RUN_WITHOUT_DOCKER === "true").hideHelp()).addOption(new Option("--run-env <env>", "Specifies the environment in which the CLI is run. So far only MANAGED_SCAN and UNKNOWN are supported.").default("UNKNOWN").choices(["UNKNOWN", "MANAGED_SCAN"]).hideHelp()).addOption(new Option("--guardrail-mode", "Run Coana in guardrail mode. This mode is used to prevent new reachable vulnerabilities from being introduced into the codebase. Usually run as a CI check when pushing new commits to a pull request.")).option("--ignore-failing-workspaces", "Continue processing when a workspace fails instead of exiting. Failed workspaces will be logged at termination.", false).option("--reach-continue-on-install-errors", "Continue analysis when package installation fails, falling back to precomputed (Tier 2) reachability results. By default, the CLI halts on installation errors in socket mode.", process.env.COANA_REACH_CONTINUE_ON_INSTALL_ERRORS === "true" || process.env.COANA_CONTINUE_ON_INSTALL_ERRORS === "true" || void 0).option("--reach-continue-on-analysis-errors", "Continue analysis when errors occur (timeouts, OOM, parse errors, etc.), falling back to precomputed (Tier 2) reachability results. By default, the CLI halts on analysis errors in socket mode.", process.env.COANA_REACH_CONTINUE_ON_ANALYSIS_ERRORS === "true" || void 0).option("--reach-continue-on-no-source-files", "Continue analysis when a workspace contains no source files for its ecosystem. By default, the CLI halts in socket mode.", process.env.COANA_REACH_CONTINUE_ON_NO_SOURCE_FILES === "true" || void 0).option("--reach-continue-on-missing-lock-files", "Continue analysis when a Gradle or SBT project is missing its lock file (or Gradle version catalog / pre-generated SBOM). By default, the CLI halts in socket mode.", process.env.COANA_REACH_CONTINUE_ON_MISSING_LOCK_FILES === "true" || void 0).addOption(new Option("--socket-mode <output-file>", "Run Coana in socket mode and write report to <output-file>").hideHelp()).addOption(new Option("--manifests-tar-hash <hash>", "Hash of the tarball containing all manifest files already uploaded to Socket. If provided, Socket will be used for computing dependency trees.").hideHelp()).option("--skip-cache-usage", "Do not attempt to use cached analysis configuration from previous runs", false).addOption(new Option("--lazy-mode", "Enable lazy analysis mode for JavaScript/TypeScript. This can significantly speed up analysis by only analyzing code that is actually relevant for the vulnerabilities being analyzed.").default(false).implies({ legacyJsAnalysisEngine: true }).hideHelp()).addOption(new Option("--legacy-js-analysis-engine", "Use the legacy Jelly engine for JavaScript/TypeScript reachability analysis instead of SPAR-JS.").default(false).hideHelp()).addOption(new Option("--min-severity <severity>", "Set the minimum severity of vulnerabilities to analyze. Supported severities are info, low, moderate, high and critical.").choices(["info", "INFO", "low", "LOW", "moderate", "MODERATE", "high", "HIGH", "critical", "CRITICAL"])).option("--use-unreachable-from-precomputation", "Skip the reachability analysis for vulnerabilities that are already known to be unreachable from the precomputed reachability analysis (Tier 2).", false).addOption(new Option("--use-only-pregenerated-sboms", "Only include artifacts that have CDX or SPDX files in their manifest files.").default(false).hideHelp()).option("--disable-external-tool-checks", "Disable validation of external tools (npm, python, go, etc.) before running analysis.", false).version(version3).configureHelp({ sortOptions: true }).action(async (path9, options) => {
|
|
@@ -253690,7 +253827,7 @@ applyFixes.name("apply-fixes").argument("<path>", "File system path to the folde
|
|
|
253690
253827
|
await applyFix(path9, fixIds, options);
|
|
253691
253828
|
}).configureHelp({ sortOptions: true });
|
|
253692
253829
|
var computeFixesAndUpgradePurlsCmd = new Command();
|
|
253693
|
-
computeFixesAndUpgradePurlsCmd.name("compute-fixes-and-upgrade-purls").argument("<path>", "File system path to the folder containing the project").option("-a, --apply-fixes-to <ghsas...>", 'GHSA IDs to compute fixes for. Use "all" to compute fixes for all vulnerabilities.', []).option("--dry-run", "Show what changes would be made without actually making them", false).option("-i, --include <patterns...>", "Glob patterns to include workspaces").option("-e, --exclude <patterns...>", "Glob patterns to exclude workspaces").option("-d, --debug", "Enable debug logging", false).option("-s, --silent", "Silence all debug/warning output", false).option("--silent-spinner", "Silence spinner", "CI" in process.env || !process.stdin.isTTY).option("--range-style <style>", 'Range style to use for the output. Currently only "pin" is supported and it only works for npm.').option("--disable-major-updates", "Do not suggest major updates. If only major update are available, the fix will not be applied.", false).option("-o, --output-file <file>", "Writes output to a JSON file").option("--minimum-release-age <minimumReleaseAge>", "Do not allow upgrades to package versions that are newer than minimumReleaseAge. Format is 2m, 5h, 3d or 1w").option("--show-affected-direct-dependencies", "Show the affected direct dependencies for each vulnerability and what upgrades could fix them - does not apply the upgrades.", false).option("--purl-types <purlTypes...>", "List of PURL types to filter artifacts by (space-separated). Only vulnerabilities from artifacts matching these types will be included.").addOption(new Option("--run-without-docker", "Run package managers without using docker").default(process.env.RUN_WITHOUT_DOCKER === "true").hideHelp()).addOption(new Option("--manifests-tar-hash <hash>", "Hash of the tarball containing all manifest files already uploaded to Socket. If provided, Socket will be used for computing dependency trees.").hideHelp()).option("--disable-external-tool-checks", "Disable validation of external tools (npm, python, go, etc.) before running analysis.", false).version(version3).action(async (path9, options) => {
|
|
253830
|
+
computeFixesAndUpgradePurlsCmd.name("compute-fixes-and-upgrade-purls").argument("<path>", "File system path to the folder containing the project").option("-a, --apply-fixes-to <ghsas...>", 'GHSA IDs to compute fixes for. Use "all" to compute fixes for all vulnerabilities.', []).option("--dry-run", "Show what changes would be made without actually making them", false).option("-i, --include <patterns...>", "Glob patterns to include workspaces").option("-e, --exclude <patterns...>", "Glob patterns to exclude workspaces").option("-d, --debug", "Enable debug logging", false).option("-s, --silent", "Silence all debug/warning output", false).option("--silent-spinner", "Silence spinner", "CI" in process.env || !process.stdin.isTTY).option("--range-style <style>", 'Range style to use for the output. Currently only "pin" is supported and it only works for npm.').option("--disable-major-updates", "Do not suggest major updates. If only major update are available, the fix will not be applied.", false).option("-o, --output-file <file>", "Writes output to a JSON file").option("--minimum-release-age <minimumReleaseAge>", "Do not allow upgrades to package versions that are newer than minimumReleaseAge. Format is 2m, 5h, 3d or 1w").option("--show-affected-direct-dependencies", "Show the affected direct dependencies for each vulnerability and what upgrades could fix them - does not apply the upgrades.", false).option("--purl-types <purlTypes...>", "List of PURL types to filter artifacts by (space-separated). Only vulnerabilities from artifacts matching these types will be included.").option("--package-managers <packageManagers...>", `List of package managers to filter artifacts by (space-separated, e.g. NPM PNPM YARN POETRY GRADLE). Valid values: ${getFilterablePackageManagers().join(", ")}. When combined with --purl-types, both filters must match.`).addOption(new Option("--run-without-docker", "Run package managers without using docker").default(process.env.RUN_WITHOUT_DOCKER === "true").hideHelp()).addOption(new Option("--manifests-tar-hash <hash>", "Hash of the tarball containing all manifest files already uploaded to Socket. If provided, Socket will be used for computing dependency trees.").hideHelp()).option("--disable-external-tool-checks", "Disable validation of external tools (npm, python, go, etc.) before running analysis.", false).version(version3).action(async (path9, options) => {
|
|
253694
253831
|
checkNotWindows();
|
|
253695
253832
|
process.env.DOCKER_IMAGE_TAG ??= version3;
|
|
253696
253833
|
if (options.outputFile && !options.outputFile.endsWith(".json")) {
|
|
@@ -253703,6 +253840,7 @@ computeFixesAndUpgradePurlsCmd.name("compute-fixes-and-upgrade-purls").argument(
|
|
|
253703
253840
|
throw new Error('Range style must be "pin"');
|
|
253704
253841
|
}
|
|
253705
253842
|
options.purlTypes = options.purlTypes?.map((t4) => t4.toLowerCase());
|
|
253843
|
+
options.packageManagers = normalizeAndValidatePackageManagers(options.packageManagers);
|
|
253706
253844
|
const tmpDir = await mkdtemp2(join35(tmpdir5(), "compute-fixes-and-upgrade-purls-"));
|
|
253707
253845
|
const logFile = join35(tmpDir, "compute-fixes-and-upgrade-purls.log");
|
|
253708
253846
|
logger.initWinstonLogger(options.debug, logFile);
|
|
@@ -253762,10 +253900,20 @@ compareReportsCommand.name("compare-reports").argument("<baselineReportPath>", "
|
|
|
253762
253900
|
await compareReports(baselineReport, newReport, options);
|
|
253763
253901
|
});
|
|
253764
253902
|
var findVulnerabilities = new Command();
|
|
253765
|
-
findVulnerabilities.name("find-vulnerabilities").requiredOption("--manifests-tar-hash <hash>", "Hash of the tarball containing all manifest files already uploaded to Socket.").option("--purl-types <purlTypes...>", "List of PURL types to filter artifacts by (space-separated). Only vulnerabilities from artifacts matching these types will be included.").action(async (options) => {
|
|
253903
|
+
findVulnerabilities.name("find-vulnerabilities").requiredOption("--manifests-tar-hash <hash>", "Hash of the tarball containing all manifest files already uploaded to Socket.").option("--purl-types <purlTypes...>", "List of PURL types to filter artifacts by (space-separated). Only vulnerabilities from artifacts matching these types will be included.").option("--package-managers <packageManagers...>", `List of package managers to filter artifacts by (space-separated, e.g. NPM PNPM YARN POETRY GRADLE). Valid values: ${getFilterablePackageManagers().join(", ")}. When combined with --purl-types, both filters must match.`).action(async (options) => {
|
|
253766
253904
|
const purlTypes = options.purlTypes?.map((t4) => t4.toLowerCase());
|
|
253905
|
+
const packageManagers = normalizeAndValidatePackageManagers(options.packageManagers);
|
|
253767
253906
|
const { artifacts } = await fetchArtifactsFromManifestsTarHash(options.manifestsTarHash);
|
|
253768
|
-
const filteredArtifacts =
|
|
253907
|
+
const filteredArtifacts = artifacts.filter((a4) => {
|
|
253908
|
+
if (purlTypes && !purlTypes.includes(a4.type))
|
|
253909
|
+
return false;
|
|
253910
|
+
if (packageManagers) {
|
|
253911
|
+
const artifactPMs = getPackageManagersForArtifact(a4);
|
|
253912
|
+
if (artifactPMs.size > 0 && !packageManagers.some((pm) => artifactPMs.has(pm)))
|
|
253913
|
+
return false;
|
|
253914
|
+
}
|
|
253915
|
+
return true;
|
|
253916
|
+
});
|
|
253769
253917
|
console.log(JSON.stringify(i(filteredArtifacts.flatMap((a4) => a4.vulnerabilities?.map((v) => v.ghsaId) ?? []))));
|
|
253770
253918
|
});
|
|
253771
253919
|
var generateAnalysisDebugInfo = new Command();
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|