@coana-tech/cli 14.12.103 → 14.12.105

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.103",
3
+ "version": "14.12.105",
4
4
  "description": "Coana CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -111651,7 +111651,7 @@ async function getCurrentCommitHash(project) {
111651
111651
  }
111652
111652
  function detectedOccurrencesFromAPMatches(matches, pathPrefixToRemove) {
111653
111653
  for (const match2 of Object.values(matches))
111654
- for (const stack of Array.isArray(match2) ? match2 : match2.stacks)
111654
+ for (const stack of match2.stacks)
111655
111655
  for (const cl of stack) {
111656
111656
  if (cl.package === "<app>")
111657
111657
  cl.package = ROOT_NODE_STR;
@@ -111661,8 +111661,8 @@ function detectedOccurrencesFromAPMatches(matches, pathPrefixToRemove) {
111661
111661
  return ({ vulnerabilityAccessPaths }) => getStacksFromAccPaths(matches, { vulnerabilityAccessPaths });
111662
111662
  }
111663
111663
  function detectedOccurrencesFromAPMatchesRuby(matches, pathPrefixToPackage) {
111664
- for (const match2 of Object.values(matches))
111665
- for (const stack of Array.isArray(match2) ? match2 : match2.stacks)
111664
+ for (const stacks of Object.values(matches))
111665
+ for (const stack of stacks)
111666
111666
  for (const cl of stack) {
111667
111667
  if (cl.package === "<app>")
111668
111668
  cl.package = ROOT_NODE_STR;
@@ -111694,9 +111694,11 @@ var { omit, once: once3, pick, sortedUniq, uniqBy } = import_lodash14.default;
111694
111694
  var memlimitWrapper = `import sys, runpy, resource
111695
111695
  if memory_limit := int(sys.argv.pop(1)):
111696
111696
  try:
111697
- resource.setrlimit(resource.RLIMIT_AS, (memory_limit * 1024 ** 2, -1))
111697
+ resource.setrlimit(resource.RLIMIT_AS, (memory_limit * 1024 ** 2, resource.RLIM_INFINITY))
111698
111698
  except ValueError as e:
111699
- print("ERROR: Failed to set memory limit", e, file=sys.stderr)
111699
+ # If we're running on PyPy, memory is bounded by PYPY_GC_MAX env var
111700
+ if sys.implementation.name != "pypy":
111701
+ print("ERROR: Failed to set memory limit", e, file=sys.stderr)
111700
111702
  runpy.run_module("mambalade", alter_sys=True)
111701
111703
  `;
111702
111704
  var PythonCodeAwareVulnerabilityScanner = class {
@@ -111739,7 +111741,11 @@ var PythonCodeAwareVulnerabilityScanner = class {
111739
111741
  reachedDependencies: false,
111740
111742
  terminatedEarly: false,
111741
111743
  diagnostics: { timeout: false, aborted: false },
111742
- computeDetectedOccurrences: () => []
111744
+ computeDetectedOccurrences: import_lodash14.default.constant({
111745
+ analysisLevel: "function-level",
111746
+ affectedPackages: [],
111747
+ stacks: []
111748
+ })
111743
111749
  };
111744
111750
  const packagesToExclude = heuristic.getPackagesToExcludeFromAnalysis?.(vulns);
111745
111751
  const vulnAccPaths = sortedUniq(vulns.flatMap((v) => v.vulnerabilityAccessPaths).sort());
@@ -111769,7 +111775,15 @@ ${vulnAccPaths.join("\n")}`);
111769
111775
  logger.debug(`With args: ${mambaladeArgs.slice(1).join(" ")}`);
111770
111776
  }
111771
111777
  try {
111772
- const { stderr } = await exec2(mambaladeArgs, this.projectDir, { stdin: memlimitWrapper });
111778
+ const { stderr } = await exec2(mambaladeArgs, this.projectDir, {
111779
+ stdin: memlimitWrapper,
111780
+ env: {
111781
+ ...process.env,
111782
+ PYPY_GC_MAX: `${reachabilityAnalysisOptions.memoryLimitInMB ?? 0}MB`
111783
+ },
111784
+ // Forcefully kill the process if the internal timeout mechanism fails
111785
+ timeout: (timeout * 1.5 + 15) * 1e3
111786
+ });
111773
111787
  logger.debug("Done running mambalade");
111774
111788
  const errors = stderr.split("\n").filter((line) => line.startsWith("ERROR:") && !/^ERROR: Excluded distribution/.test(line));
111775
111789
  if (errors.length > 0)
@@ -112667,7 +112681,7 @@ function augmentVulnsWithDetectedOccurrences(vulns, codeAwareScanner, heuristic,
112667
112681
  const packagesFailedToInstall = codeAwareScanner.getPackagesExcludedUnrelatedToHeuristic();
112668
112682
  for (const v of vulns) {
112669
112683
  const detectedOccurrences = result.computeDetectedOccurrences(v);
112670
- if (Array.isArray(detectedOccurrences) ? detectedOccurrences.length === 0 : detectedOccurrences.stacks.length === 0) {
112684
+ if (detectedOccurrences.stacks.length === 0) {
112671
112685
  if (SOCKET_MODE && result.terminatedEarly && !result.reachedDependencies && Object.keys(v.vulnChainDetails.transitiveDependencies).length > 1) {
112672
112686
  v.results = {
112673
112687
  type: "analysisError",
@@ -112745,16 +112759,15 @@ var GoAnalyzer = class {
112745
112759
  const res = otherVulns.length ? await analyzeWithHeuristics(this.state, otherVulns, [GoanaHeuristics.DEFAULT], false, new GoCodeAwareVulnerabilityScanner(this.projectDir, this.state.reachabilityAnalysisOptions), analysisMetadataCollector, statusUpdater) : [];
112746
112760
  if (unreachableVulns.length) {
112747
112761
  const heuristicName = GoanaHeuristics.IMPORT_REACHABILITY.name;
112748
- const detectedOccurrences = {
112749
- analysisLevel: "function-level",
112750
- affectedPackages: [],
112751
- stacks: []
112752
- };
112753
112762
  const scanResult = {
112754
112763
  type: "success",
112755
112764
  heuristicName,
112756
112765
  terminatedEarly: false,
112757
- detectedOccurrences
112766
+ detectedOccurrences: {
112767
+ analysisLevel: "function-level",
112768
+ affectedPackages: [],
112769
+ stacks: []
112770
+ }
112758
112771
  };
112759
112772
  analysisMetadataCollector?.({
112760
112773
  vulnUrls: unreachableVulns.map((v) => v.url),