@coana-tech/cli 14.11.7 → 14.11.8

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 CHANGED
@@ -225338,7 +225338,7 @@ async function onlineScan(dependencyTree, apiKey, timeout) {
225338
225338
  }
225339
225339
 
225340
225340
  // dist/version.js
225341
- var version2 = "14.11.7";
225341
+ var version2 = "14.11.8";
225342
225342
 
225343
225343
  // dist/cli-core.js
225344
225344
  var { mapValues, omit, partition, pick } = import_lodash15.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coana-tech/cli",
3
- "version": "14.11.7",
3
+ "version": "14.11.8",
4
4
  "description": "Coana CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -64950,7 +64950,7 @@ var require_comparator = __commonJS({
64950
64950
  var require_satisfies = __commonJS({
64951
64951
  "../../node_modules/.pnpm/semver@7.7.1/node_modules/semver/functions/satisfies.js"(exports, module) {
64952
64952
  var Range = require_range2();
64953
- var satisfies2 = (version3, range, options) => {
64953
+ var satisfies3 = (version3, range, options) => {
64954
64954
  try {
64955
64955
  range = new Range(range, options);
64956
64956
  } catch (er) {
@@ -64958,7 +64958,7 @@ var require_satisfies = __commonJS({
64958
64958
  }
64959
64959
  return range.test(version3);
64960
64960
  };
64961
- module.exports = satisfies2;
64961
+ module.exports = satisfies3;
64962
64962
  }
64963
64963
  });
64964
64964
 
@@ -65107,7 +65107,7 @@ var require_outside = __commonJS({
65107
65107
  var Comparator = require_comparator();
65108
65108
  var { ANY } = Comparator;
65109
65109
  var Range = require_range2();
65110
- var satisfies2 = require_satisfies();
65110
+ var satisfies3 = require_satisfies();
65111
65111
  var gt = require_gt();
65112
65112
  var lt2 = require_lt();
65113
65113
  var lte = require_lte();
@@ -65134,7 +65134,7 @@ var require_outside = __commonJS({
65134
65134
  default:
65135
65135
  throw new TypeError('Must provide a hilo val of "<" or ">"');
65136
65136
  }
65137
- if (satisfies2(version3, range, options)) {
65137
+ if (satisfies3(version3, range, options)) {
65138
65138
  return false;
65139
65139
  }
65140
65140
  for (let i2 = 0; i2 < range.set.length; ++i2) {
@@ -65202,7 +65202,7 @@ var require_intersects = __commonJS({
65202
65202
  // ../../node_modules/.pnpm/semver@7.7.1/node_modules/semver/ranges/simplify.js
65203
65203
  var require_simplify = __commonJS({
65204
65204
  "../../node_modules/.pnpm/semver@7.7.1/node_modules/semver/ranges/simplify.js"(exports, module) {
65205
- var satisfies2 = require_satisfies();
65205
+ var satisfies3 = require_satisfies();
65206
65206
  var compare = require_compare();
65207
65207
  module.exports = (versions, range, options) => {
65208
65208
  const set = [];
@@ -65210,7 +65210,7 @@ var require_simplify = __commonJS({
65210
65210
  let prev2 = null;
65211
65211
  const v = versions.sort((a2, b) => compare(a2, b, options));
65212
65212
  for (const version3 of v) {
65213
- const included = satisfies2(version3, range, options);
65213
+ const included = satisfies3(version3, range, options);
65214
65214
  if (included) {
65215
65215
  prev2 = version3;
65216
65216
  if (!first2) {
@@ -65254,7 +65254,7 @@ var require_subset = __commonJS({
65254
65254
  var Range = require_range2();
65255
65255
  var Comparator = require_comparator();
65256
65256
  var { ANY } = Comparator;
65257
- var satisfies2 = require_satisfies();
65257
+ var satisfies3 = require_satisfies();
65258
65258
  var compare = require_compare();
65259
65259
  var subset = (sub, dom, options = {}) => {
65260
65260
  if (sub === dom) {
@@ -65323,14 +65323,14 @@ var require_subset = __commonJS({
65323
65323
  }
65324
65324
  }
65325
65325
  for (const eq2 of eqSet) {
65326
- if (gt && !satisfies2(eq2, String(gt), options)) {
65326
+ if (gt && !satisfies3(eq2, String(gt), options)) {
65327
65327
  return null;
65328
65328
  }
65329
- if (lt2 && !satisfies2(eq2, String(lt2), options)) {
65329
+ if (lt2 && !satisfies3(eq2, String(lt2), options)) {
65330
65330
  return null;
65331
65331
  }
65332
65332
  for (const c of dom) {
65333
- if (!satisfies2(eq2, String(c), options)) {
65333
+ if (!satisfies3(eq2, String(c), options)) {
65334
65334
  return false;
65335
65335
  }
65336
65336
  }
@@ -65357,7 +65357,7 @@ var require_subset = __commonJS({
65357
65357
  if (higher === c && higher !== gt) {
65358
65358
  return false;
65359
65359
  }
65360
- } else if (gt.operator === ">=" && !satisfies2(gt.semver, String(c), options)) {
65360
+ } else if (gt.operator === ">=" && !satisfies3(gt.semver, String(c), options)) {
65361
65361
  return false;
65362
65362
  }
65363
65363
  }
@@ -65372,7 +65372,7 @@ var require_subset = __commonJS({
65372
65372
  if (lower === c && lower !== lt2) {
65373
65373
  return false;
65374
65374
  }
65375
- } else if (lt2.operator === "<=" && !satisfies2(lt2.semver, String(c), options)) {
65375
+ } else if (lt2.operator === "<=" && !satisfies3(lt2.semver, String(c), options)) {
65376
65376
  return false;
65377
65377
  }
65378
65378
  }
@@ -65441,7 +65441,7 @@ var require_semver2 = __commonJS({
65441
65441
  var coerce = require_coerce();
65442
65442
  var Comparator = require_comparator();
65443
65443
  var Range = require_range2();
65444
- var satisfies2 = require_satisfies();
65444
+ var satisfies3 = require_satisfies();
65445
65445
  var toComparators = require_to_comparators();
65446
65446
  var maxSatisfying = require_max_satisfying();
65447
65447
  var minSatisfying = require_min_satisfying();
@@ -65479,7 +65479,7 @@ var require_semver2 = __commonJS({
65479
65479
  coerce,
65480
65480
  Comparator,
65481
65481
  Range,
65482
- satisfies: satisfies2,
65482
+ satisfies: satisfies3,
65483
65483
  toComparators,
65484
65484
  maxSatisfying,
65485
65485
  minSatisfying,
@@ -73697,7 +73697,7 @@ ${error.message}`);
73697
73697
 
73698
73698
  // dist/whole-program-code-aware-vulnerability-scanner/analyze-in-buckets.js
73699
73699
  var import_lodash17 = __toESM(require_lodash(), 1);
73700
- var import_semver2 = __toESM(require_semver2(), 1);
73700
+ var import_semver3 = __toESM(require_semver2(), 1);
73701
73701
  import assert8 from "assert";
73702
73702
  import { relative as relative5 } from "path";
73703
73703
 
@@ -96268,6 +96268,7 @@ async function getVersion(analysisName) {
96268
96268
  }
96269
96269
 
96270
96270
  // dist/whole-program-code-aware-vulnerability-scanner/python/python-code-aware-vulnerability-scanner.js
96271
+ var import_semver2 = __toESM(require_semver2(), 1);
96271
96272
  var { omit, once: once3, pick, sortedUniq, uniqBy } = import_lodash14.default;
96272
96273
  var PythonCodeAwareVulnerabilityScanner = class _PythonCodeAwareVulnerabilityScanner {
96273
96274
  state;
@@ -96276,6 +96277,7 @@ var PythonCodeAwareVulnerabilityScanner = class _PythonCodeAwareVulnerabilitySca
96276
96277
  numberAnalysesRun = 0;
96277
96278
  virtualEnvInfo;
96278
96279
  vm;
96280
+ mambaladeVenvPath;
96279
96281
  constructor(state, projectDir, _statusUpdater) {
96280
96282
  this.state = state;
96281
96283
  this.projectDir = projectDir;
@@ -96293,6 +96295,9 @@ var PythonCodeAwareVulnerabilityScanner = class _PythonCodeAwareVulnerabilitySca
96293
96295
  async runAnalysis(vulns, heuristic, analyzesAllVulns) {
96294
96296
  if (!this.virtualEnvInfo)
96295
96297
  throw new Error("Virtual environment not set up");
96298
+ if (!this.mambaladeVenvPath) {
96299
+ await this.setupMambalade();
96300
+ }
96296
96301
  logger.info("Started instantiating Python code-aware analysis");
96297
96302
  logger.debug(`Trying to find files to analyze from projectDir: ${this.projectDir}`);
96298
96303
  const { rootWorkingDir, reachabilityAnalysisOptions } = this.state;
@@ -96326,7 +96331,7 @@ runpy.run_module("mambalade", alter_sys=True)
96326
96331
  const excludeDistributionsOption = packagesToExclude?.size ? ["--exclude-distributions", ...packagesToExclude] : [];
96327
96332
  const timeout = reachabilityAnalysisOptions.timeoutInSeconds ?? // 10 minutes for the first analysis, 1 minute for subsequent analyses
96328
96333
  (analyzesAllVulns ? 60 * 10 : 60);
96329
- const pythonExecutable = resolve12(COANA_REPOS_PATH(), "mambalade", ".venv", "bin", "python");
96334
+ const pythonExecutable = join15(this.mambaladeVenvPath, "bin", "python");
96330
96335
  const mambaladeArgs = [
96331
96336
  pythonExecutable,
96332
96337
  wrapperPath,
@@ -96603,12 +96608,34 @@ ${msg}`;
96603
96608
  getVirtualEnvInfo() {
96604
96609
  return this.virtualEnvInfo;
96605
96610
  }
96611
+ async setupMambalade() {
96612
+ const venvDir = await createTmpDirectory("mambalade-venv");
96613
+ logger.info("Creating Mambalade virtual environment");
96614
+ const pythonInterpreter = await getPythonInterpreter();
96615
+ await exec(cmdt`${pythonInterpreter} -SIm venv ${venvDir}`);
96616
+ const mambaladeWheelsPath = join15(COANA_REPOS_PATH(), "mambalade", "dist");
96617
+ const wheelFiles = await readdir3(mambaladeWheelsPath);
96618
+ const mambaladeWheels = wheelFiles.filter((f2) => f2.endsWith(".whl")).map((f2) => join15(mambaladeWheelsPath, f2));
96619
+ if (mambaladeWheels.length === 0) {
96620
+ throw new Error(`No mambalade wheel files found in ${mambaladeWheelsPath}`);
96621
+ }
96622
+ logger.info(`Installing mambalade wheels: ${mambaladeWheels.join(", ")}`);
96623
+ await exec(cmdt`${venvDir}/bin/pip install --no-deps ${mambaladeWheels}`);
96624
+ this.mambaladeVenvPath = venvDir;
96625
+ logger.info("Mambalade virtual environment setup complete");
96626
+ }
96606
96627
  // async [Symbol.asyncDispose]() {
96607
96628
  async cleanup() {
96608
96629
  if (this.virtualEnvInfo?.temporary) {
96609
- await rm5(this.virtualEnvInfo.virtualEnvFolder, { recursive: true, force: true });
96630
+ await rm5(this.virtualEnvInfo.virtualEnvFolder, { recursive: true, force: true }).catch(() => {
96631
+ });
96610
96632
  this.virtualEnvInfo = void 0;
96611
96633
  }
96634
+ if (this.mambaladeVenvPath) {
96635
+ await rm5(this.mambaladeVenvPath, { recursive: true, force: true }).catch(() => {
96636
+ });
96637
+ this.mambaladeVenvPath = void 0;
96638
+ }
96612
96639
  }
96613
96640
  };
96614
96641
  async function findFilesToAnalyze(projectDir) {
@@ -96647,6 +96674,16 @@ function transformSourceLocations2(appPath, fileMappings, detectedOccurrences) {
96647
96674
  }
96648
96675
  return detectedOccurrences;
96649
96676
  }
96677
+ async function getPythonInterpreter() {
96678
+ const pythonVersionRequired = ">=3.11.0";
96679
+ const pypyVersion = await getPythonVersion("pypy3").catch(() => void 0);
96680
+ if (pypyVersion && (0, import_semver2.satisfies)(pypyVersion, pythonVersionRequired))
96681
+ return "pypy3";
96682
+ const pythonVersion = await getPythonVersion("python3").catch(() => void 0);
96683
+ if (pythonVersion && (0, import_semver2.satisfies)(pythonVersion, pythonVersionRequired))
96684
+ return "python3";
96685
+ throw new Error(`No Python ${pythonVersionRequired} interpreter found`);
96686
+ }
96650
96687
 
96651
96688
  // dist/whole-program-code-aware-vulnerability-scanner/python/phantom-deps.js
96652
96689
  var { uniq: uniq8 } = import_lodash15.default;
@@ -96890,7 +96927,7 @@ async function analyzeWithHeuristics(state, vulns, heuristicsInOrder, doNotRecom
96890
96927
  if (bucketsFromLastAnalysis.some((b) => b.heuristicName === heuristics.IGNORE_DEPENDENCIES_AND_MAX_ROUNDS_3.name))
96891
96928
  return;
96892
96929
  try {
96893
- if ((0, import_semver2.lt)(cliVersion, CLI_VERSION_TO_USE_CACHING_FROM[ecosystem] ?? CLI_VERSION_TO_USE_CACHING_FROM_DEFAULT))
96930
+ if ((0, import_semver3.lt)(cliVersion, CLI_VERSION_TO_USE_CACHING_FROM[ecosystem] ?? CLI_VERSION_TO_USE_CACHING_FROM_DEFAULT))
96894
96931
  return void 0;
96895
96932
  } catch (e) {
96896
96933
  return void 0;