@coana-tech/cli 15.0.9 → 15.0.10

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
@@ -252023,7 +252023,7 @@ async function onlineScan(dependencyTree, apiKey, timeout) {
252023
252023
  }
252024
252024
 
252025
252025
  // dist/version.js
252026
- var version3 = "15.0.9";
252026
+ var version3 = "15.0.10";
252027
252027
 
252028
252028
  // dist/cli-core.js
252029
252029
  var { mapValues, omit, partition, pickBy: pickBy2 } = import_lodash15.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coana-tech/cli",
3
- "version": "15.0.9",
3
+ "version": "15.0.10",
4
4
  "description": "Coana CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -35347,8 +35347,8 @@ var require_follow_redirects = __commonJS({
35347
35347
  }
35348
35348
  return parsed;
35349
35349
  }
35350
- function resolveUrl(relative13, base) {
35351
- return useNativeURL ? new URL3(relative13, base) : parseUrl(url2.resolve(base, relative13));
35350
+ function resolveUrl(relative14, base) {
35351
+ return useNativeURL ? new URL3(relative14, base) : parseUrl(url2.resolve(base, relative14));
35352
35352
  }
35353
35353
  function validateUrl(input) {
35354
35354
  if (/^\[/.test(input.hostname) && !/^\[[:0-9a-f]+\]$/i.test(input.hostname)) {
@@ -54787,7 +54787,7 @@ var require_old = __commonJS({
54787
54787
  if (cache) cache[original] = p;
54788
54788
  return p;
54789
54789
  };
54790
- exports.realpath = function realpath4(p, cache, cb) {
54790
+ exports.realpath = function realpath5(p, cache, cb) {
54791
54791
  if (typeof cb !== "function") {
54792
54792
  cb = maybeCallback(cache);
54793
54793
  cache = null;
@@ -54875,12 +54875,12 @@ var require_old = __commonJS({
54875
54875
  // ../../node_modules/.pnpm/fs.realpath@1.0.0/node_modules/fs.realpath/index.js
54876
54876
  var require_fs = __commonJS({
54877
54877
  "../../node_modules/.pnpm/fs.realpath@1.0.0/node_modules/fs.realpath/index.js"(exports, module) {
54878
- module.exports = realpath4;
54879
- realpath4.realpath = realpath4;
54880
- realpath4.sync = realpathSync2;
54881
- realpath4.realpathSync = realpathSync2;
54882
- realpath4.monkeypatch = monkeypatch;
54883
- realpath4.unmonkeypatch = unmonkeypatch;
54878
+ module.exports = realpath5;
54879
+ realpath5.realpath = realpath5;
54880
+ realpath5.sync = realpathSync2;
54881
+ realpath5.realpathSync = realpathSync2;
54882
+ realpath5.monkeypatch = monkeypatch;
54883
+ realpath5.unmonkeypatch = unmonkeypatch;
54884
54884
  var fs12 = __require("fs");
54885
54885
  var origRealpath = fs12.realpath;
54886
54886
  var origRealpathSync = fs12.realpathSync;
@@ -54890,7 +54890,7 @@ var require_fs = __commonJS({
54890
54890
  function newError(er) {
54891
54891
  return er && er.syscall === "realpath" && (er.code === "ELOOP" || er.code === "ENOMEM" || er.code === "ENAMETOOLONG");
54892
54892
  }
54893
- function realpath4(p, cache, cb) {
54893
+ function realpath5(p, cache, cb) {
54894
54894
  if (ok) {
54895
54895
  return origRealpath(p, cache, cb);
54896
54896
  }
@@ -54921,7 +54921,7 @@ var require_fs = __commonJS({
54921
54921
  }
54922
54922
  }
54923
54923
  function monkeypatch() {
54924
- fs12.realpath = realpath4;
54924
+ fs12.realpath = realpath5;
54925
54925
  fs12.realpathSync = realpathSync2;
54926
54926
  }
54927
54927
  function unmonkeypatch() {
@@ -79848,7 +79848,7 @@ function deserializeRustDependencyChainNode(s2) {
79848
79848
 
79849
79849
  // dist/main.js
79850
79850
  var import_lodash25 = __toESM(require_lodash(), 1);
79851
- import { relative as relative12, resolve as resolve27 } from "path";
79851
+ import { relative as relative13, resolve as resolve27 } from "path";
79852
79852
 
79853
79853
  // ../utils/src/dashboard-api/coana-api.ts
79854
79854
  import { writeFile } from "fs/promises";
@@ -86282,10 +86282,10 @@ var Ignore = class {
86282
86282
  ignored(p) {
86283
86283
  const fullpath = p.fullpath();
86284
86284
  const fullpaths = `${fullpath}/`;
86285
- const relative13 = p.relative() || ".";
86286
- const relatives = `${relative13}/`;
86285
+ const relative14 = p.relative() || ".";
86286
+ const relatives = `${relative14}/`;
86287
86287
  for (const m of this.relative) {
86288
- if (m.match(relative13) || m.match(relatives))
86288
+ if (m.match(relative14) || m.match(relatives))
86289
86289
  return true;
86290
86290
  }
86291
86291
  for (const m of this.absolute) {
@@ -86296,9 +86296,9 @@ var Ignore = class {
86296
86296
  }
86297
86297
  childrenIgnored(p) {
86298
86298
  const fullpath = p.fullpath() + "/";
86299
- const relative13 = (p.relative() || ".") + "/";
86299
+ const relative14 = (p.relative() || ".") + "/";
86300
86300
  for (const m of this.relativeChildren) {
86301
- if (m.match(relative13))
86301
+ if (m.match(relative14))
86302
86302
  return true;
86303
86303
  }
86304
86304
  for (const m of this.absoluteChildren) {
@@ -98250,10 +98250,10 @@ function compareDocumentPosition(nodeA, nodeB) {
98250
98250
  function uniqueSort(nodes) {
98251
98251
  nodes = nodes.filter((node, i4, arr) => !arr.includes(node, i4 + 1));
98252
98252
  nodes.sort((a2, b) => {
98253
- const relative13 = compareDocumentPosition(a2, b);
98254
- if (relative13 & DocumentPosition.PRECEDING) {
98253
+ const relative14 = compareDocumentPosition(a2, b);
98254
+ if (relative14 & DocumentPosition.PRECEDING) {
98255
98255
  return -1;
98256
- } else if (relative13 & DocumentPosition.FOLLOWING) {
98256
+ } else if (relative14 & DocumentPosition.FOLLOWING) {
98257
98257
  return 1;
98258
98258
  }
98259
98259
  return 0;
@@ -114423,8 +114423,8 @@ async function downloadAndExtractComposerPackage(namespace2, name2, version3, ve
114423
114423
 
114424
114424
  // dist/whole-program-code-aware-vulnerability-scanner/php/spar-php-runner.js
114425
114425
  import { createReadStream as createReadStream4, createWriteStream as createWriteStream6, existsSync as existsSync17 } from "fs";
114426
- import { readFile as readFile15, rm as rm9, writeFile as writeFile12 } from "fs/promises";
114427
- import { join as join20 } from "path";
114426
+ import { readFile as readFile15, realpath as realpath4, rm as rm9, writeFile as writeFile12 } from "fs/promises";
114427
+ import { join as join20, relative as relative10 } from "path";
114428
114428
  import { pipeline as pipeline4 } from "stream/promises";
114429
114429
  import zlib4 from "zlib";
114430
114430
  async function runSparPhpAnalysis(projectDir, vulns, includePackages, timeoutInSeconds, telemetryHandler, analyzerTelemetryHandler) {
@@ -114474,13 +114474,16 @@ async function runSparPhpAnalysis(projectDir, vulns, includePackages, timeoutInS
114474
114474
  logger.debug(`PHP code-aware analysis stderr
114475
114475
  ${stderr}`);
114476
114476
  const callstacksRaw = existsSync17(callstacksOutputFile) ? JSON.parse(await readFile15(callstacksOutputFile, "utf8")) : [];
114477
+ const realProjectRoot = await realpath4(projectDir);
114478
+ const vendorDir = join20(projectDir, "vendor");
114479
+ const realVendorRoot = existsSync17(vendorDir) ? await realpath4(vendorDir) : vendorDir;
114477
114480
  const matchesByUrl = {};
114478
114481
  for (const entry of callstacksRaw) {
114479
114482
  const url2 = entry.vulnerability;
114480
114483
  const stacks = entry.paths.map((path10) => path10.map((frame) => ({
114481
114484
  package: frame.package === "" ? ROOT_NODE_STR : frame.package,
114482
114485
  sourceLocation: {
114483
- filename: frame.file,
114486
+ filename: normalizeFilename(frame.file, frame.package, realProjectRoot, realVendorRoot),
114484
114487
  start: frame.start,
114485
114488
  end: frame.end
114486
114489
  },
@@ -114521,6 +114524,16 @@ ${stderr}`);
114521
114524
  await rm9(tmpDir, { recursive: true, force: true });
114522
114525
  }
114523
114526
  }
114527
+ function normalizeFilename(file, pkg, realProjectRoot, realVendorRoot) {
114528
+ if (pkg) {
114529
+ const relToVendor = relative10(realVendorRoot, file);
114530
+ const pkgPrefix = `${pkg}/`;
114531
+ if (!relToVendor.startsWith("..") && relToVendor.startsWith(pkgPrefix)) {
114532
+ return relToVendor.substring(pkgPrefix.length);
114533
+ }
114534
+ }
114535
+ return relative10(realProjectRoot, file);
114536
+ }
114524
114537
 
114525
114538
  // dist/whole-program-code-aware-vulnerability-scanner/php/php-code-aware-vulnerability-scanner.js
114526
114539
  var { uniqBy: uniqBy2 } = import_lodash19.default;
@@ -114892,7 +114905,7 @@ var import_lodash22 = __toESM(require_lodash(), 1);
114892
114905
  var import_picomatch4 = __toESM(require_picomatch2(), 1);
114893
114906
  import { existsSync as existsSync20 } from "fs";
114894
114907
  import { rm as rm11 } from "fs/promises";
114895
- import { relative as relative10, resolve as resolve25 } from "path";
114908
+ import { relative as relative11, resolve as resolve25 } from "path";
114896
114909
 
114897
114910
  // ../web-compat-utils/src/pluralize.ts
114898
114911
  function pluralize(count, word) {
@@ -114956,7 +114969,7 @@ var NpmAnalyzer = class {
114956
114969
  logger.info(`Running import reachability analysis for ${vulns.length} ${pluralize(vulns.length, "vulnerability")}`);
114957
114970
  let reachable;
114958
114971
  const ghsaIds = extractGhsaIdsFromVulnUrls(vulns.map((v) => v.url));
114959
- const importAnalysisMetadataId = COANA_REPORT_ID ? await dashboardAPI2.createAnalysisMetadata(COANA_REPORT_ID, relative10(this.state.rootWorkingDir, this.state.subprojectDir) || ".", this.state.workspacePath, "NPM", ghsaIds, heuristics.IMPORT_REACHABILITY.name) : void 0;
114972
+ const importAnalysisMetadataId = COANA_REPORT_ID ? await dashboardAPI2.createAnalysisMetadata(COANA_REPORT_ID, relative11(this.state.rootWorkingDir, this.state.subprojectDir) || ".", this.state.workspacePath, "NPM", ghsaIds, heuristics.IMPORT_REACHABILITY.name) : void 0;
114960
114973
  if (COANA_REPORT_ID && !importAnalysisMetadataId) {
114961
114974
  logger.debug("Failed to create analysis metadata for import analysis");
114962
114975
  }
@@ -115176,7 +115189,7 @@ import { resolve as resolve26 } from "path";
115176
115189
  var import_lodash23 = __toESM(require_lodash(), 1);
115177
115190
  import { createWriteStream as createWriteStream7, existsSync as existsSync21 } from "fs";
115178
115191
  import { mkdir as mkdir11, readdir as readdir8, readFile as readFile16, rm as rm12 } from "fs/promises";
115179
- import { join as join22, relative as relative11 } from "path";
115192
+ import { join as join22, relative as relative12 } from "path";
115180
115193
  import { pipeline as pipeline5 } from "stream/promises";
115181
115194
  var PRINT_ANALYSIS_COMMAND = false;
115182
115195
  var { uniqBy: uniqBy3, sortedUniq: sortedUniq2 } = import_lodash23.default;
@@ -115269,7 +115282,7 @@ var RubyCodeAwareVulnerabilityScanner = class {
115269
115282
  telemetryHandler
115270
115283
  });
115271
115284
  const result = JSON.parse(await readFile16(vulnsOutputFile, "utf-8"));
115272
- const relativeLoadPathsToPackageNames = new Map([...loadPathsToPackageNames.entries()].map(([k, v]) => [join22("vendor", relative11(this.vendorDir, k)), v]));
115285
+ const relativeLoadPathsToPackageNames = new Map([...loadPathsToPackageNames.entries()].map(([k, v]) => [join22("vendor", relative12(this.vendorDir, k)), v]));
115273
115286
  const { timedOut, ...diagnostics } = JSON.parse(await readFile16(diagnosticsOutputFile, "utf-8"));
115274
115287
  const reachedPackages = JSON.parse(await readFile16(reachedPackagesOutputFile, "utf-8"));
115275
115288
  logger.debug("Reached packages: %O", reachedPackages);
@@ -115573,7 +115586,7 @@ var dashboardAPI3 = new DashboardAPI(process.env.SOCKET_MODE === "true", process
115573
115586
  async function installDependenciesForAnalysis(state, preinstallDir) {
115574
115587
  const projectDir = resolve27(state.subprojectDir, state.workspacePath);
115575
115588
  const ecosystem = state.workspaceData.data.type;
115576
- logger.info(`Pre-installing dependencies for project at "${relative12(state.rootWorkingDir, projectDir) || "."}" (${ecosystem})`);
115589
+ logger.info(`Pre-installing dependencies for project at "${relative13(state.rootWorkingDir, projectDir) || "."}" (${ecosystem})`);
115577
115590
  const constructor = ecosystemAnalyzer[ecosystem];
115578
115591
  if (!constructor)
115579
115592
  throw Error(`No analyzer associated with ecosystem ${ecosystem}`);
@@ -115584,14 +115597,14 @@ async function installDependenciesForAnalysis(state, preinstallDir) {
115584
115597
  async function runReachabilityAnalysis(state) {
115585
115598
  const projectDir = resolve27(state.subprojectDir, state.workspacePath);
115586
115599
  const ecosystem = state.workspaceData.data.type;
115587
- logger.info(`Preparing to run reachability analysis for project at "${relative12(state.rootWorkingDir, projectDir) || "."}" (${ecosystem})`);
115600
+ logger.info(`Preparing to run reachability analysis for project at "${relative13(state.rootWorkingDir, projectDir) || "."}" (${ecosystem})`);
115588
115601
  const constructor = ecosystemAnalyzer[ecosystem];
115589
115602
  if (!constructor)
115590
115603
  throw Error(`No analyzer associated with ecosystem ${ecosystem}`);
115591
115604
  const analyzer = new constructor(state, projectDir);
115592
115605
  const [vulnerabilitiesWithPrecomputedResults, vulnerabilitiesWithoutPrecomputedResults] = partition4(state.vulnerabilities, (v) => "results" in v);
115593
115606
  const augmentedVulnerabilities = await runWholeProgramCodeAwareVulnerabilityScanner(analyzer, vulnerabilitiesWithoutPrecomputedResults, async (amd) => {
115594
- await dashboardAPI3.registerAnalysisMetadata(relative12(state.rootWorkingDir, state.subprojectDir) || ".", state.workspacePath, state.workspaceData.data.type, amd, COANA_REPORT_ID, apiKey2);
115607
+ await dashboardAPI3.registerAnalysisMetadata(relative13(state.rootWorkingDir, state.subprojectDir) || ".", state.workspacePath, state.workspaceData.data.type, amd, COANA_REPORT_ID, apiKey2);
115595
115608
  });
115596
115609
  const diagnostics = await analyzer.getWorkspaceDiagnostics();
115597
115610
  return {