@coana-tech/cli 14.12.221 → 14.12.223
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 +64 -4
- package/package.json +1 -1
- package/reachability-analyzers-cli.mjs +6 -6
- 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
|
@@ -204489,7 +204489,11 @@ async function fetchArtifactsFromManifestsTarHash(manifestsTarHash, includePreco
|
|
|
204489
204489
|
try {
|
|
204490
204490
|
const params = new URLSearchParams({
|
|
204491
204491
|
tarHash: manifestsTarHash,
|
|
204492
|
-
includePrecomputedReachabilityResults: String(includePrecomputedReachabilityResults ?? false)
|
|
204492
|
+
includePrecomputedReachabilityResults: String(includePrecomputedReachabilityResults ?? false),
|
|
204493
|
+
// Opt in to depscan PR #19451: returns artifacts with `missingMetadata: true` for packages
|
|
204494
|
+
// whose precrawl metadata is unavailable (private registry, workspace, git deps). This CLI
|
|
204495
|
+
// version strips them after reachability analysis (see filterMissingMetadataArtifacts).
|
|
204496
|
+
includeMissingMetadata: "true"
|
|
204493
204497
|
});
|
|
204494
204498
|
const url2 = getSocketApiUrl(`orgs/${process.env.SOCKET_ORG_SLUG}/compute-artifacts?${params.toString()}`);
|
|
204495
204499
|
responseData = (await axios2.post(url2, {}, { headers: getAuthHeaders() })).data;
|
|
@@ -236864,6 +236868,60 @@ function displayWorkspaceDiagnosticsSummaryInternal(diagnosticsEntries, vulns) {
|
|
|
236864
236868
|
}
|
|
236865
236869
|
|
|
236866
236870
|
// dist/internal/socket-report-socket-dependency-tree.js
|
|
236871
|
+
function filterMissingMetadataArtifacts(artifacts) {
|
|
236872
|
+
const missingIds = new Set(artifacts.filter((a4) => a4.missingMetadata).map((a4) => a4.id));
|
|
236873
|
+
if (missingIds.size === 0)
|
|
236874
|
+
return artifacts;
|
|
236875
|
+
const byId = new Map(artifacts.map((a4) => [a4.id, a4]));
|
|
236876
|
+
const resolveCache = /* @__PURE__ */ new Map();
|
|
236877
|
+
function resolveDependencies(id, visiting) {
|
|
236878
|
+
const cached = resolveCache.get(id);
|
|
236879
|
+
if (cached)
|
|
236880
|
+
return cached;
|
|
236881
|
+
if (visiting.has(id))
|
|
236882
|
+
return [];
|
|
236883
|
+
visiting.add(id);
|
|
236884
|
+
const node = byId.get(id);
|
|
236885
|
+
const out = /* @__PURE__ */ new Set();
|
|
236886
|
+
if (node) {
|
|
236887
|
+
for (const ref of node.dependencies ?? []) {
|
|
236888
|
+
if (missingIds.has(ref)) {
|
|
236889
|
+
for (const r3 of resolveDependencies(ref, visiting))
|
|
236890
|
+
out.add(r3);
|
|
236891
|
+
} else if (byId.has(ref)) {
|
|
236892
|
+
out.add(ref);
|
|
236893
|
+
}
|
|
236894
|
+
}
|
|
236895
|
+
}
|
|
236896
|
+
visiting.delete(id);
|
|
236897
|
+
const res = [...out];
|
|
236898
|
+
resolveCache.set(id, res);
|
|
236899
|
+
return res;
|
|
236900
|
+
}
|
|
236901
|
+
logger.debug(`Filtered out ${missingIds.size} missing-metadata component(s) after reachability analysis`);
|
|
236902
|
+
return artifacts.filter((a4) => !missingIds.has(a4.id)).map((a4) => {
|
|
236903
|
+
let dependencies = a4.dependencies;
|
|
236904
|
+
if (dependencies?.some((r3) => missingIds.has(r3))) {
|
|
236905
|
+
const out = /* @__PURE__ */ new Set();
|
|
236906
|
+
for (const r3 of dependencies) {
|
|
236907
|
+
if (missingIds.has(r3)) {
|
|
236908
|
+
for (const sub of resolveDependencies(r3, /* @__PURE__ */ new Set())) {
|
|
236909
|
+
if (sub !== a4.id)
|
|
236910
|
+
out.add(sub);
|
|
236911
|
+
}
|
|
236912
|
+
} else {
|
|
236913
|
+
out.add(r3);
|
|
236914
|
+
}
|
|
236915
|
+
}
|
|
236916
|
+
dependencies = [...out];
|
|
236917
|
+
}
|
|
236918
|
+
let toplevelAncestors = a4.toplevelAncestors;
|
|
236919
|
+
if (toplevelAncestors?.some((r3) => missingIds.has(r3))) {
|
|
236920
|
+
toplevelAncestors = toplevelAncestors.filter((r3) => !missingIds.has(r3));
|
|
236921
|
+
}
|
|
236922
|
+
return { ...a4, dependencies, toplevelAncestors };
|
|
236923
|
+
});
|
|
236924
|
+
}
|
|
236867
236925
|
function filterOrphanedArtifacts(artifacts) {
|
|
236868
236926
|
const reachable = /* @__PURE__ */ new Set();
|
|
236869
236927
|
const queue = [];
|
|
@@ -236929,6 +236987,7 @@ function toSocketFactsSocketDependencyTree(artifacts, vulnerabilities, tier1Reac
|
|
|
236929
236987
|
});
|
|
236930
236988
|
}
|
|
236931
236989
|
}
|
|
236990
|
+
artifacts = filterMissingMetadataArtifacts(artifacts);
|
|
236932
236991
|
const componentsWithoutPatterns = artifacts.map((artifact) => {
|
|
236933
236992
|
if (!artifact.vulnerabilities) {
|
|
236934
236993
|
return { ...artifact };
|
|
@@ -251836,7 +251895,7 @@ async function onlineScan(dependencyTree, apiKey, timeout) {
|
|
|
251836
251895
|
}
|
|
251837
251896
|
|
|
251838
251897
|
// dist/version.js
|
|
251839
|
-
var version3 = "14.12.
|
|
251898
|
+
var version3 = "14.12.223";
|
|
251840
251899
|
|
|
251841
251900
|
// dist/cli-core.js
|
|
251842
251901
|
var { mapValues, omit, partition, pickBy: pickBy2 } = import_lodash15.default;
|
|
@@ -252615,7 +252674,8 @@ Subproject: ${subproject}`);
|
|
|
252615
252674
|
}, {
|
|
252616
252675
|
disableBucketing: !!this.options.disableAnalysisSplitting,
|
|
252617
252676
|
lightweightReachability: this.options.lightweightReachability,
|
|
252618
|
-
skipCacheUsage: this.options.skipCacheUsage
|
|
252677
|
+
skipCacheUsage: this.options.skipCacheUsage,
|
|
252678
|
+
jsAnalysisEngine: this.options.legacyJsAnalysisEngine ? "jelly" : "sparjs"
|
|
252619
252679
|
}, rootWorkingDirOverride, displaySubprojectPath);
|
|
252620
252680
|
result.push(...analysisResult.vulnerabilities);
|
|
252621
252681
|
this.sendProgress("REACHABILITY_ANALYSIS", false, subprojectPath, workspacePath);
|
|
@@ -252877,7 +252937,7 @@ async function writeAnalysisDebugInfo(outputFilePath, ecosystemToWorkspaceToVuln
|
|
|
252877
252937
|
handleNexeBinaryMode();
|
|
252878
252938
|
var program2 = new Command();
|
|
252879
252939
|
var run2 = new Command();
|
|
252880
|
-
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).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).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) => {
|
|
252940
|
+
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).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) => {
|
|
252881
252941
|
process.env.DOCKER_IMAGE_TAG ??= version3;
|
|
252882
252942
|
options.ecosystems = options.ecosystems?.map((e) => e.toUpperCase());
|
|
252883
252943
|
options.minSeverity = options.minSeverity?.toUpperCase();
|
package/package.json
CHANGED
|
@@ -112050,10 +112050,10 @@ var JSCodeAwareVulnerabilityScanner = class _JSCodeAwareVulnerabilityScanner {
|
|
|
112050
112050
|
this.options = options;
|
|
112051
112051
|
this.engineOverride = engineOverride;
|
|
112052
112052
|
}
|
|
112053
|
-
resolveEngine(
|
|
112054
|
-
if (this.engineOverride === "
|
|
112055
|
-
return this.
|
|
112056
|
-
return this.
|
|
112053
|
+
resolveEngine() {
|
|
112054
|
+
if (this.engineOverride === "jelly")
|
|
112055
|
+
return this.jellyEngine;
|
|
112056
|
+
return this.sparjsEngine;
|
|
112057
112057
|
}
|
|
112058
112058
|
async cleanup() {
|
|
112059
112059
|
await Promise.all([this.jellyEngine.cleanup(), this.sparjsEngine.cleanup()]);
|
|
@@ -112076,7 +112076,7 @@ var JSCodeAwareVulnerabilityScanner = class _JSCodeAwareVulnerabilityScanner {
|
|
|
112076
112076
|
const analysisOptionsFromHeuristic = heuristic.getOptions(vulnerabilities);
|
|
112077
112077
|
try {
|
|
112078
112078
|
analysisOptionsFromHeuristic.approx = process.env.JELLY_APPROX === "true" || experiment === "JELLY_APPROX";
|
|
112079
|
-
const analysisRes = await this.resolveEngine(
|
|
112079
|
+
const analysisRes = await this.resolveEngine().runAnalysis(this.mainProjectDir, this.projectDir, analysisOptionsFromHeuristic, this.options, timeoutInSeconds, vulnerabilities, experiment, telemetryHandler, analyzerTelemetryHandler);
|
|
112080
112080
|
const { analysisDiagnostics: diagnostics, matches } = analysisRes;
|
|
112081
112081
|
const terminatedEarly = diagnostics.rangeError ?? (diagnostics.aborted || diagnostics.timeout || diagnostics.lowmemory);
|
|
112082
112082
|
return {
|
|
@@ -114423,7 +114423,7 @@ var NpmAnalyzer = class {
|
|
|
114423
114423
|
constructor(state, projectDir) {
|
|
114424
114424
|
this.state = state;
|
|
114425
114425
|
this.projectDir = projectDir;
|
|
114426
|
-
this.engine = this.state.otherAnalysisOptions.jsAnalysisEngine === "
|
|
114426
|
+
this.engine = this.state.otherAnalysisOptions.jsAnalysisEngine === "jelly" ? new JellyJSAnalysisEngine() : new SparJSAnalysisEngine();
|
|
114427
114427
|
}
|
|
114428
114428
|
async runPhantomDependencyAnalysis() {
|
|
114429
114429
|
try {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|