@coana-tech/cli 14.9.16 → 14.9.18
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 +30 -11
- package/package.json +1 -1
package/cli.mjs
CHANGED
|
@@ -49667,7 +49667,7 @@ var require_cjs = __commonJS({
|
|
|
49667
49667
|
var require_lib3 = __commonJS({
|
|
49668
49668
|
"../../node_modules/.pnpm/write-file-atomic@5.0.1/node_modules/write-file-atomic/lib/index.js"(exports2, module2) {
|
|
49669
49669
|
"use strict";
|
|
49670
|
-
module2.exports =
|
|
49670
|
+
module2.exports = writeFile11;
|
|
49671
49671
|
module2.exports.sync = writeFileSync4;
|
|
49672
49672
|
module2.exports._getTmpname = getTmpname;
|
|
49673
49673
|
module2.exports._cleanupOnExit = cleanupOnExit;
|
|
@@ -49792,7 +49792,7 @@ var require_lib3 = __commonJS({
|
|
|
49792
49792
|
}
|
|
49793
49793
|
}
|
|
49794
49794
|
}
|
|
49795
|
-
async function
|
|
49795
|
+
async function writeFile11(filename, data2, options, callback) {
|
|
49796
49796
|
if (options instanceof Function) {
|
|
49797
49797
|
callback = options;
|
|
49798
49798
|
options = {};
|
|
@@ -73933,7 +73933,7 @@ var require_lockfile = __commonJS({
|
|
|
73933
73933
|
if (eol !== "\n") {
|
|
73934
73934
|
data2 = data2.replace(/\n/g, eol);
|
|
73935
73935
|
}
|
|
73936
|
-
yield
|
|
73936
|
+
yield writeFile11(path2, data2);
|
|
73937
73937
|
});
|
|
73938
73938
|
return function writeFilePreservingEol2(_x30, _x31) {
|
|
73939
73939
|
return _ref31.apply(this, arguments);
|
|
@@ -73945,7 +73945,7 @@ var require_lockfile = __commonJS({
|
|
|
73945
73945
|
const file = (_path || _load_path()).default.join(dir, filename);
|
|
73946
73946
|
const fileLink = (_path || _load_path()).default.join(dir, filename + "-link");
|
|
73947
73947
|
try {
|
|
73948
|
-
yield
|
|
73948
|
+
yield writeFile11(file, "test");
|
|
73949
73949
|
yield link(file, fileLink);
|
|
73950
73950
|
} catch (err) {
|
|
73951
73951
|
return false;
|
|
@@ -74095,7 +74095,7 @@ var require_lockfile = __commonJS({
|
|
|
74095
74095
|
const lockQueue = exports3.lockQueue = new (_blockingQueue || _load_blockingQueue()).default("fs lock");
|
|
74096
74096
|
const readFileBuffer = exports3.readFileBuffer = (0, (_promise2 || _load_promise2()).promisify)((_fs || _load_fs()).default.readFile);
|
|
74097
74097
|
const open = exports3.open = (0, (_promise2 || _load_promise2()).promisify)((_fs || _load_fs()).default.open);
|
|
74098
|
-
const
|
|
74098
|
+
const writeFile11 = exports3.writeFile = (0, (_promise2 || _load_promise2()).promisify)((_fs || _load_fs()).default.writeFile);
|
|
74099
74099
|
const readlink2 = exports3.readlink = (0, (_promise2 || _load_promise2()).promisify)((_fs || _load_fs()).default.readlink);
|
|
74100
74100
|
const realpath2 = exports3.realpath = (0, (_promise2 || _load_promise2()).promisify)((_fs || _load_fs()).default.realpath);
|
|
74101
74101
|
const readdir8 = exports3.readdir = (0, (_promise2 || _load_promise2()).promisify)((_fs || _load_fs()).default.readdir);
|
|
@@ -102092,7 +102092,7 @@ var require_summary = __commonJS({
|
|
|
102092
102092
|
exports2.summary = exports2.markdownSummary = exports2.SUMMARY_DOCS_URL = exports2.SUMMARY_ENV_VAR = void 0;
|
|
102093
102093
|
var os_1 = __require("os");
|
|
102094
102094
|
var fs_1 = __require("fs");
|
|
102095
|
-
var { access: access5, appendFile: appendFile2, writeFile:
|
|
102095
|
+
var { access: access5, appendFile: appendFile2, writeFile: writeFile11 } = fs_1.promises;
|
|
102096
102096
|
exports2.SUMMARY_ENV_VAR = "GITHUB_STEP_SUMMARY";
|
|
102097
102097
|
exports2.SUMMARY_DOCS_URL = "https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary";
|
|
102098
102098
|
var Summary = class {
|
|
@@ -102150,7 +102150,7 @@ var require_summary = __commonJS({
|
|
|
102150
102150
|
return __awaiter(this, void 0, void 0, function* () {
|
|
102151
102151
|
const overwrite = !!(options === null || options === void 0 ? void 0 : options.overwrite);
|
|
102152
102152
|
const filePath = yield this.filePath();
|
|
102153
|
-
const writeFunc = overwrite ?
|
|
102153
|
+
const writeFunc = overwrite ? writeFile11 : appendFile2;
|
|
102154
102154
|
yield writeFunc(filePath, this._buffer, { encoding: "utf8" });
|
|
102155
102155
|
return this.emptyBuffer();
|
|
102156
102156
|
});
|
|
@@ -197540,7 +197540,7 @@ function getVulnerabilitiesFromReport(report) {
|
|
|
197540
197540
|
|
|
197541
197541
|
// dist/cli-core.js
|
|
197542
197542
|
import { writeFileSync as writeFileSync3 } from "fs";
|
|
197543
|
-
import { mkdir as mkdir2, readFile as readFile16 } from "fs/promises";
|
|
197543
|
+
import { mkdir as mkdir2, readFile as readFile16, writeFile as writeFile10 } from "fs/promises";
|
|
197544
197544
|
|
|
197545
197545
|
// ../../node_modules/.pnpm/kleur@4.1.5/node_modules/kleur/index.mjs
|
|
197546
197546
|
var FORCE_COLOR;
|
|
@@ -213131,7 +213131,7 @@ async function onlineScan(dependencyTree, apiKey, timeout) {
|
|
|
213131
213131
|
}
|
|
213132
213132
|
|
|
213133
213133
|
// dist/version.js
|
|
213134
|
-
var version2 = "14.9.
|
|
213134
|
+
var version2 = "14.9.18";
|
|
213135
213135
|
|
|
213136
213136
|
// dist/cli-core.js
|
|
213137
213137
|
var { omit, partition, pick } = import_lodash15.default;
|
|
@@ -213144,6 +213144,7 @@ var CliCore = class {
|
|
|
213144
213144
|
coanaLogPath = "";
|
|
213145
213145
|
shareWithDashboard;
|
|
213146
213146
|
reportId;
|
|
213147
|
+
reportDependencyTrees;
|
|
213147
213148
|
apiKey = {
|
|
213148
213149
|
type: "missing"
|
|
213149
213150
|
};
|
|
@@ -213158,7 +213159,7 @@ var CliCore = class {
|
|
|
213158
213159
|
}
|
|
213159
213160
|
this.rootWorkingDirectory = resolve24(rootWorkingDirectory);
|
|
213160
213161
|
this.spinner = Spinner.instance({ text: "Running Coana CLI", isSilent: this.options.silent });
|
|
213161
|
-
this.shareWithDashboard = !!(this.options.apiKey && !this.options.disableReportSubmission && (this.options.repoUrl ?? this.options.projectName));
|
|
213162
|
+
this.shareWithDashboard = !this.options.socketMode && !!(this.options.apiKey && !this.options.disableReportSubmission && (this.options.repoUrl ?? this.options.projectName));
|
|
213162
213163
|
}
|
|
213163
213164
|
verifyApiKey(key) {
|
|
213164
213165
|
const checkIfApiKeyIsEmptyMessage = "You may be trying to provide the API key through an environment variable or CI secret which is either undefined or empty.";
|
|
@@ -213182,6 +213183,9 @@ var CliCore = class {
|
|
|
213182
213183
|
if (this.options.guardrailMode) {
|
|
213183
213184
|
this.options.disableReportSubmission = true;
|
|
213184
213185
|
}
|
|
213186
|
+
if (this.options.socketMode === "") {
|
|
213187
|
+
throw new Error("The argument for --socket-mode may not be the empty string");
|
|
213188
|
+
}
|
|
213185
213189
|
if (this.options.apiKey) {
|
|
213186
213190
|
try {
|
|
213187
213191
|
this.verifyApiKey(this.options.apiKey);
|
|
@@ -213260,6 +213264,19 @@ var CliCore = class {
|
|
|
213260
213264
|
}
|
|
213261
213265
|
async outputAndShareReport(report) {
|
|
213262
213266
|
const outputDir = this.options.outputDir;
|
|
213267
|
+
if (this.options.socketMode) {
|
|
213268
|
+
if (!this.reportDependencyTrees) {
|
|
213269
|
+
throw new Error("Dependency trees should be available when using --socket-mode");
|
|
213270
|
+
}
|
|
213271
|
+
const socketReport = {
|
|
213272
|
+
...report,
|
|
213273
|
+
dependencyTrees: this.reportDependencyTrees
|
|
213274
|
+
};
|
|
213275
|
+
const outputFile = resolve24(this.options.socketMode);
|
|
213276
|
+
await writeFile10(outputFile, JSON.stringify(socketReport, null, 2));
|
|
213277
|
+
logger.info(kleur_default.green(`Socket report written to: ${outputFile}`));
|
|
213278
|
+
return;
|
|
213279
|
+
}
|
|
213263
213280
|
if (outputDir) {
|
|
213264
213281
|
const jsonReportPath = resolve24(outputDir, `${DEFAULT_REPORT_FILENAME_BASE}.json`);
|
|
213265
213282
|
await mkdir2(outputDir, { recursive: true });
|
|
@@ -213481,6 +213498,8 @@ var CliCore = class {
|
|
|
213481
213498
|
workspacePath,
|
|
213482
213499
|
subprojectPath: relative10(rootWorkingDirectory, subprojectPath) || "."
|
|
213483
213500
|
}));
|
|
213501
|
+
if (this.options.socketMode)
|
|
213502
|
+
this.reportDependencyTrees = dependencyTrees;
|
|
213484
213503
|
if (this.shareWithDashboard)
|
|
213485
213504
|
sendDependencyTreesToDashboard(dependencyTrees, this.reportId, this.apiKey);
|
|
213486
213505
|
const workspaceToVulnerabilities = Object.fromEntries(await asyncMap(workspacePaths, async (workspacePath, idx) => this.spinner.wrap(`Scanning for vulnerabilities: (${subProjAndWsPath.packageManagerName}) (${idx + 1}/${workspacePaths.length}) ${workspacePath}`, async () => {
|
|
@@ -213644,7 +213663,7 @@ async function getGitDataToMetadataIfAvailable(rootWorkingDirectory) {
|
|
|
213644
213663
|
// dist/index.js
|
|
213645
213664
|
var program2 = new Command();
|
|
213646
213665
|
var run2 = new Command();
|
|
213647
|
-
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("-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.", "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 <dirs...>", "globs for directories to include from the detection of subprojects (space-separated). Notice, projects that are not included may still be scanned if they are referenced from included projects.").option("--exclude-dirs <dirs...>", "globs for directories to exclude from the detection of subprojects (space-separated). 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. Currently NPM, PIP, MAVEN and GO are supported. Default is all supported ecosystems.", (ecosystems) => ecosystems.split(" ").map((e) => e.toUpperCase())).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("--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.").
|
|
213666
|
+
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("-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.", "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 <dirs...>", "globs for directories to include from the detection of subprojects (space-separated). Notice, projects that are not included may still be scanned if they are referenced from included projects.").option("--exclude-dirs <dirs...>", "globs for directories to exclude from the detection of subprojects (space-separated). 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. Currently NPM, PIP, MAVEN and GO are supported. Default is all supported ecosystems.", (ecosystems) => ecosystems.split(" ").map((e) => e.toUpperCase())).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("--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.")).addOption(new Option("--socket-mode <output-file>", "Run Coana in socket mode and write report to <output-file>").hideHelp()).version(version2).configureHelp({ sortOptions: true }).action(async (path2, options) => {
|
|
213648
213667
|
process.env.DOCKER_IMAGE_TAG ??= version2;
|
|
213649
213668
|
await new CliCore(path2, options).main();
|
|
213650
213669
|
});
|