@coana-tech/cli 14.12.48 → 14.12.49

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coana-tech/cli",
3
- "version": "14.12.48",
3
+ "version": "14.12.49",
4
4
  "description": "Coana CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -54009,7 +54009,7 @@ var require_summary = __commonJS({
54009
54009
  exports.summary = exports.markdownSummary = exports.SUMMARY_DOCS_URL = exports.SUMMARY_ENV_VAR = void 0;
54010
54010
  var os_1 = __require("os");
54011
54011
  var fs_1 = __require("fs");
54012
- var { access: access3, appendFile, writeFile: writeFile10 } = fs_1.promises;
54012
+ var { access: access3, appendFile, writeFile: writeFile9 } = fs_1.promises;
54013
54013
  exports.SUMMARY_ENV_VAR = "GITHUB_STEP_SUMMARY";
54014
54014
  exports.SUMMARY_DOCS_URL = "https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary";
54015
54015
  var Summary = class {
@@ -54067,7 +54067,7 @@ var require_summary = __commonJS({
54067
54067
  return __awaiter(this, void 0, void 0, function* () {
54068
54068
  const overwrite = !!(options === null || options === void 0 ? void 0 : options.overwrite);
54069
54069
  const filePath = yield this.filePath();
54070
- const writeFunc = overwrite ? writeFile10 : appendFile;
54070
+ const writeFunc = overwrite ? writeFile9 : appendFile;
54071
54071
  yield writeFunc(filePath, this._buffer, { encoding: "utf8" });
54072
54072
  return this.emptyBuffer();
54073
54073
  });
@@ -69249,7 +69249,7 @@ var {
69249
69249
  } = import_index.default;
69250
69250
 
69251
69251
  // dist/reachability-analyzers-cli.js
69252
- import { readFile as readFile12, writeFile as writeFile9 } from "fs/promises";
69252
+ import { readFile as readFile12, writeFile as writeFile8 } from "fs/promises";
69253
69253
 
69254
69254
  // ../web-compat-utils/src/logger-singleton.ts
69255
69255
  var import_winston = __toESM(require_winston(), 1);
@@ -74698,7 +74698,7 @@ function addPathToTrie(root3, vulnPath) {
74698
74698
  var import_lodash14 = __toESM(require_lodash(), 1);
74699
74699
  import assert5 from "assert";
74700
74700
  import { existsSync as existsSync11 } from "fs";
74701
- import { cp as cp5, readdir as readdir3, readFile as readFile10, rm as rm5, writeFile as writeFile8 } from "fs/promises";
74701
+ import { cp as cp5, readdir as readdir3, readFile as readFile10, rm as rm5 } from "fs/promises";
74702
74702
  import { basename as basename9, dirname as dirname12, join as join17, resolve as resolve15, sep as sep3 } from "path";
74703
74703
  import util5 from "util";
74704
74704
 
@@ -97175,6 +97175,14 @@ async function getVersion(analysisName) {
97175
97175
  // dist/whole-program-code-aware-vulnerability-scanner/python/python-code-aware-vulnerability-scanner.js
97176
97176
  var import_semver2 = __toESM(require_semver2(), 1);
97177
97177
  var { omit, once: once3, pick, sortedUniq, uniqBy } = import_lodash14.default;
97178
+ var memlimitWrapper = `import sys, runpy, resource
97179
+ if memory_limit := int(sys.argv.pop(1)):
97180
+ try:
97181
+ resource.setrlimit(resource.RLIMIT_AS, (memory_limit * 1024 ** 2, -1))
97182
+ except ValueError as e:
97183
+ print("ERROR: Failed to set memory limit", e, file=sys.stderr)
97184
+ runpy.run_module("mambalade", alter_sys=True)
97185
+ `;
97178
97186
  var PythonCodeAwareVulnerabilityScanner = class {
97179
97187
  state;
97180
97188
  projectDir;
@@ -97220,15 +97228,6 @@ var PythonCodeAwareVulnerabilityScanner = class {
97220
97228
  const packagesToExclude = heuristic.getPackagesToExcludeFromAnalysis?.(vulns);
97221
97229
  const vulnAccPaths = sortedUniq(vulns.flatMap((v) => v.vulnerabilityAccessPaths).sort());
97222
97230
  const tmpDir = await createTmpDirectory("coana-mambalade-output");
97223
- const wrapperPath = join17(tmpDir, "wrapper.py");
97224
- await writeFile8(wrapperPath, `import sys, runpy, resource
97225
- if memory_limit := int(sys.argv.pop(1)):
97226
- try:
97227
- resource.setrlimit(resource.RLIMIT_AS, (memory_limit * 1024 ** 2, -1))
97228
- except ValueError as e:
97229
- print("ERROR: Failed to set memory limit", e, file=sys.stderr)
97230
- runpy.run_module("mambalade", alter_sys=True)
97231
- `);
97232
97231
  const vulnsOutputFile = join17(tmpDir, "vulns.json");
97233
97232
  const diagnosticsOutputFile = join17(tmpDir, "diagnostics.json");
97234
97233
  const excludeDistributionsOption = packagesToExclude?.size ? ["--exclude-distributions", ...packagesToExclude] : [];
@@ -97237,7 +97236,7 @@ runpy.run_module("mambalade", alter_sys=True)
97237
97236
  const pythonExecutable = join17(this.mambaladeVenvPath, "bin", "python");
97238
97237
  const mambaladeArgs = [
97239
97238
  pythonExecutable,
97240
- wrapperPath,
97239
+ "-",
97241
97240
  `${reachabilityAnalysisOptions.memoryLimitInMB ?? 0}`,
97242
97241
  "--vulnerabilities",
97243
97242
  ...vulnAccPaths,
@@ -97261,7 +97260,7 @@ ${vulnAccPaths.join("\n")}`);
97261
97260
  logger.debug(`Running python executable: ${pythonExecutable}`);
97262
97261
  logger.debug(`With args: ${mambaladeArgs.slice(1).join(" ")}`);
97263
97262
  try {
97264
- const { stderr } = await exec(mambaladeArgs, this.projectDir);
97263
+ const { stderr } = await exec(mambaladeArgs, this.projectDir, { stdin: memlimitWrapper });
97265
97264
  logger.debug("Done running mambalade");
97266
97265
  const errors = stderr.split("\n").filter((line) => line.startsWith("ERROR:") && !/^ERROR: Excluded distribution/.test(line));
97267
97266
  if (errors.length > 0)
@@ -98311,7 +98310,7 @@ var runReachabilityAnalysisCmd = new Command().name("runReachabilityAnalysis").a
98311
98310
  const result = await runReachabilityAnalysis(state);
98312
98311
  if (options.outputFile) {
98313
98312
  logger.debug("Writing result to file", options.outputFile);
98314
- await writeFile9(options.outputFile, JSON.stringify({ result }));
98313
+ await writeFile8(options.outputFile, JSON.stringify({ result }));
98315
98314
  } else {
98316
98315
  logger.info("Result:", JSON.stringify(result, null, 2));
98317
98316
  }
@@ -98321,7 +98320,7 @@ var runOnDependencyChainCmd = new Command().name("runOnDependencyChain").option(
98321
98320
  const result = await analyzePackages(ecosystem, deserializeDependencyChain(ecosystem, dependencyChain), vulnerability);
98322
98321
  if (options.outputFile) {
98323
98322
  logger.debug("Writing result to file", options.outputFile);
98324
- await writeFile9(options.outputFile, JSON.stringify({ result }));
98323
+ await writeFile8(options.outputFile, JSON.stringify({ result }));
98325
98324
  } else {
98326
98325
  logger.info("Result:", JSON.stringify(result, null, 2));
98327
98326
  }
@@ -98349,7 +98348,7 @@ var runOnPackageRegistryPackageCmd = new Command().name("runOnPackageRegistryPac
98349
98348
  const result = isFile3 ? await analyzeAlreadyInstalledPackages(options.ecosystem, [mainPackage, ...options.dependencies].map((p) => p.replace("file://", "")), vulnerability, { timeoutInSeconds: +options.analysisTimeout, memoryLimitInMB: +options.memoryLimit }) : await analyzePackages(options.ecosystem, deserializeDependencyChain(options.ecosystem, `${mainPackage}${options.dependencies.length > 0 ? ` > ${options.dependencies.join(" > ")}` : ""}`), vulnerability, { timeoutInSeconds: +options.analysisTimeout, memoryLimitInMB: +options.memoryLimit });
98350
98349
  if (options.outputFile) {
98351
98350
  logger.info("Writing result to file", options.outputFile);
98352
- await writeFile9(options.outputFile, JSON.stringify(result, null, 2));
98351
+ await writeFile8(options.outputFile, JSON.stringify(result, null, 2));
98353
98352
  } else {
98354
98353
  logger.info("Result:", JSON.stringify(result, null, 2));
98355
98354
  }