@socketsecurity/cli-with-sentry 1.0.96 → 1.0.98

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.
Files changed (56) hide show
  1. package/dist/cli.js +850 -493
  2. package/dist/cli.js.map +1 -1
  3. package/dist/constants.js +3 -3
  4. package/dist/constants.js.map +1 -1
  5. package/dist/shadow-npm-bin.js +3 -3
  6. package/dist/shadow-npm-bin.js.map +1 -1
  7. package/dist/shadow-npm-inject.js +29 -49
  8. package/dist/shadow-npm-inject.js.map +1 -1
  9. package/dist/tsconfig.dts.tsbuildinfo +1 -1
  10. package/dist/types/commands/fix/coana-fix.d.mts.map +1 -1
  11. package/dist/types/commands/fix/pull-request.d.mts +6 -1
  12. package/dist/types/commands/fix/pull-request.d.mts.map +1 -1
  13. package/dist/types/commands/fix/shared.d.mts +2 -1
  14. package/dist/types/commands/fix/shared.d.mts.map +1 -1
  15. package/dist/types/commands/patch/cmd-patch.d.mts +11 -0
  16. package/dist/types/commands/patch/cmd-patch.d.mts.map +1 -0
  17. package/dist/types/commands/patch/handle-patch.d.mts +10 -0
  18. package/dist/types/commands/patch/handle-patch.d.mts.map +1 -0
  19. package/dist/types/commands/patch/output-patch-result.d.mts +5 -0
  20. package/dist/types/commands/patch/output-patch-result.d.mts.map +1 -0
  21. package/dist/types/commands.d.mts +7 -0
  22. package/dist/types/commands.d.mts.map +1 -1
  23. package/dist/types/shadow/npm/arborist/lib/arborist/index.d.mts.map +1 -1
  24. package/dist/types/shadow/npm/arborist-helpers.d.mts +5 -5
  25. package/dist/types/shadow/npm/arborist-helpers.d.mts.map +1 -1
  26. package/dist/types/utils/alert/severity.d.mts.map +1 -1
  27. package/dist/types/utils/alerts-map.d.mts +4 -3
  28. package/dist/types/utils/alerts-map.d.mts.map +1 -1
  29. package/dist/types/utils/config.d.mts +5 -4
  30. package/dist/types/utils/config.d.mts.map +1 -1
  31. package/dist/types/utils/filter-config.d.mts +5 -0
  32. package/dist/types/utils/filter-config.d.mts.map +1 -0
  33. package/dist/types/utils/meow-with-subcommands.d.mts.map +1 -1
  34. package/dist/types/utils/sdk.d.mts +3 -3
  35. package/dist/types/utils/sdk.d.mts.map +1 -1
  36. package/dist/types/utils/socket-package-alert.d.mts +7 -5
  37. package/dist/types/utils/socket-package-alert.d.mts.map +1 -1
  38. package/dist/utils.js +246 -244
  39. package/dist/utils.js.map +1 -1
  40. package/dist/vendor.js +5124 -5114
  41. package/external/@coana-tech/cli/cli-wrapper.mjs +1 -0
  42. package/external/@coana-tech/cli/cli.mjs +302 -184
  43. package/external/@coana-tech/cli/reachability-analyzers-cli.mjs +134 -63
  44. package/external/@coana-tech/cli/repos/coana-tech/alucard/alucard.jar +0 -0
  45. package/external/@coana-tech/cli/repos/coana-tech/class-graph-analysis/dist/bundle/class-graph-analysis-cli.mjs +2337 -2821
  46. package/external/@coana-tech/cli/repos/coana-tech/cocoa/release/Coana.Cocoa.dll +0 -0
  47. package/external/@coana-tech/cli/repos/coana-tech/goana/bin/goana-darwin-amd64.gz +0 -0
  48. package/external/@coana-tech/cli/repos/coana-tech/goana/bin/goana-darwin-arm64.gz +0 -0
  49. package/external/@coana-tech/cli/repos/coana-tech/goana/bin/goana-linux-amd64.gz +0 -0
  50. package/external/@coana-tech/cli/repos/coana-tech/goana/bin/goana-linux-arm64.gz +0 -0
  51. package/external/@socketsecurity/registry/lib/objects.js +16 -0
  52. package/package.json +8 -8
  53. package/dist/types/commands/scan/suggest-repo-slug.d.mts +0 -9
  54. package/dist/types/commands/scan/suggest-repo-slug.d.mts.map +0 -1
  55. package/dist/types/utils/strings.d.mts +0 -2
  56. package/dist/types/utils/strings.d.mts.map +0 -1
@@ -6151,7 +6151,7 @@ var require_safe_stable_stringify = __commonJS({
6151
6151
  return circularValue;
6152
6152
  }
6153
6153
  let res = "";
6154
- let join26 = ",";
6154
+ let join28 = ",";
6155
6155
  const originalIndentation = indentation;
6156
6156
  if (Array.isArray(value)) {
6157
6157
  if (value.length === 0) {
@@ -6165,7 +6165,7 @@ var require_safe_stable_stringify = __commonJS({
6165
6165
  indentation += spacer;
6166
6166
  res += `
6167
6167
  ${indentation}`;
6168
- join26 = `,
6168
+ join28 = `,
6169
6169
  ${indentation}`;
6170
6170
  }
6171
6171
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -6173,13 +6173,13 @@ ${indentation}`;
6173
6173
  for (; i6 < maximumValuesToStringify - 1; i6++) {
6174
6174
  const tmp2 = stringifyFnReplacer(String(i6), value, stack2, replacer, spacer, indentation);
6175
6175
  res += tmp2 !== void 0 ? tmp2 : "null";
6176
- res += join26;
6176
+ res += join28;
6177
6177
  }
6178
6178
  const tmp = stringifyFnReplacer(String(i6), value, stack2, replacer, spacer, indentation);
6179
6179
  res += tmp !== void 0 ? tmp : "null";
6180
6180
  if (value.length - 1 > maximumBreadth) {
6181
6181
  const removedKeys = value.length - maximumBreadth - 1;
6182
- res += `${join26}"... ${getItemCount(removedKeys)} not stringified"`;
6182
+ res += `${join28}"... ${getItemCount(removedKeys)} not stringified"`;
6183
6183
  }
6184
6184
  if (spacer !== "") {
6185
6185
  res += `
@@ -6200,7 +6200,7 @@ ${originalIndentation}`;
6200
6200
  let separator = "";
6201
6201
  if (spacer !== "") {
6202
6202
  indentation += spacer;
6203
- join26 = `,
6203
+ join28 = `,
6204
6204
  ${indentation}`;
6205
6205
  whitespace2 = " ";
6206
6206
  }
@@ -6214,13 +6214,13 @@ ${indentation}`;
6214
6214
  const tmp = stringifyFnReplacer(key2, value, stack2, replacer, spacer, indentation);
6215
6215
  if (tmp !== void 0) {
6216
6216
  res += `${separator}${strEscape(key2)}:${whitespace2}${tmp}`;
6217
- separator = join26;
6217
+ separator = join28;
6218
6218
  }
6219
6219
  }
6220
6220
  if (keyLength > maximumBreadth) {
6221
6221
  const removedKeys = keyLength - maximumBreadth;
6222
6222
  res += `${separator}"...":${whitespace2}"${getItemCount(removedKeys)} not stringified"`;
6223
- separator = join26;
6223
+ separator = join28;
6224
6224
  }
6225
6225
  if (spacer !== "" && separator.length > 1) {
6226
6226
  res = `
@@ -6261,7 +6261,7 @@ ${originalIndentation}`;
6261
6261
  }
6262
6262
  const originalIndentation = indentation;
6263
6263
  let res = "";
6264
- let join26 = ",";
6264
+ let join28 = ",";
6265
6265
  if (Array.isArray(value)) {
6266
6266
  if (value.length === 0) {
6267
6267
  return "[]";
@@ -6274,7 +6274,7 @@ ${originalIndentation}`;
6274
6274
  indentation += spacer;
6275
6275
  res += `
6276
6276
  ${indentation}`;
6277
- join26 = `,
6277
+ join28 = `,
6278
6278
  ${indentation}`;
6279
6279
  }
6280
6280
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -6282,13 +6282,13 @@ ${indentation}`;
6282
6282
  for (; i6 < maximumValuesToStringify - 1; i6++) {
6283
6283
  const tmp2 = stringifyArrayReplacer(String(i6), value[i6], stack2, replacer, spacer, indentation);
6284
6284
  res += tmp2 !== void 0 ? tmp2 : "null";
6285
- res += join26;
6285
+ res += join28;
6286
6286
  }
6287
6287
  const tmp = stringifyArrayReplacer(String(i6), value[i6], stack2, replacer, spacer, indentation);
6288
6288
  res += tmp !== void 0 ? tmp : "null";
6289
6289
  if (value.length - 1 > maximumBreadth) {
6290
6290
  const removedKeys = value.length - maximumBreadth - 1;
6291
- res += `${join26}"... ${getItemCount(removedKeys)} not stringified"`;
6291
+ res += `${join28}"... ${getItemCount(removedKeys)} not stringified"`;
6292
6292
  }
6293
6293
  if (spacer !== "") {
6294
6294
  res += `
@@ -6301,7 +6301,7 @@ ${originalIndentation}`;
6301
6301
  let whitespace2 = "";
6302
6302
  if (spacer !== "") {
6303
6303
  indentation += spacer;
6304
- join26 = `,
6304
+ join28 = `,
6305
6305
  ${indentation}`;
6306
6306
  whitespace2 = " ";
6307
6307
  }
@@ -6310,7 +6310,7 @@ ${indentation}`;
6310
6310
  const tmp = stringifyArrayReplacer(key2, value[key2], stack2, replacer, spacer, indentation);
6311
6311
  if (tmp !== void 0) {
6312
6312
  res += `${separator}${strEscape(key2)}:${whitespace2}${tmp}`;
6313
- separator = join26;
6313
+ separator = join28;
6314
6314
  }
6315
6315
  }
6316
6316
  if (spacer !== "" && separator.length > 1) {
@@ -6368,20 +6368,20 @@ ${originalIndentation}`;
6368
6368
  indentation += spacer;
6369
6369
  let res2 = `
6370
6370
  ${indentation}`;
6371
- const join27 = `,
6371
+ const join29 = `,
6372
6372
  ${indentation}`;
6373
6373
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
6374
6374
  let i6 = 0;
6375
6375
  for (; i6 < maximumValuesToStringify - 1; i6++) {
6376
6376
  const tmp2 = stringifyIndent(String(i6), value[i6], stack2, spacer, indentation);
6377
6377
  res2 += tmp2 !== void 0 ? tmp2 : "null";
6378
- res2 += join27;
6378
+ res2 += join29;
6379
6379
  }
6380
6380
  const tmp = stringifyIndent(String(i6), value[i6], stack2, spacer, indentation);
6381
6381
  res2 += tmp !== void 0 ? tmp : "null";
6382
6382
  if (value.length - 1 > maximumBreadth) {
6383
6383
  const removedKeys = value.length - maximumBreadth - 1;
6384
- res2 += `${join27}"... ${getItemCount(removedKeys)} not stringified"`;
6384
+ res2 += `${join29}"... ${getItemCount(removedKeys)} not stringified"`;
6385
6385
  }
6386
6386
  res2 += `
6387
6387
  ${originalIndentation}`;
@@ -6397,16 +6397,16 @@ ${originalIndentation}`;
6397
6397
  return '"[Object]"';
6398
6398
  }
6399
6399
  indentation += spacer;
6400
- const join26 = `,
6400
+ const join28 = `,
6401
6401
  ${indentation}`;
6402
6402
  let res = "";
6403
6403
  let separator = "";
6404
6404
  let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
6405
6405
  if (isTypedArrayWithEntries(value)) {
6406
- res += stringifyTypedArray(value, join26, maximumBreadth);
6406
+ res += stringifyTypedArray(value, join28, maximumBreadth);
6407
6407
  keys = keys.slice(value.length);
6408
6408
  maximumPropertiesToStringify -= value.length;
6409
- separator = join26;
6409
+ separator = join28;
6410
6410
  }
6411
6411
  if (deterministic) {
6412
6412
  keys = insertSort(keys);
@@ -6417,13 +6417,13 @@ ${indentation}`;
6417
6417
  const tmp = stringifyIndent(key2, value[key2], stack2, spacer, indentation);
6418
6418
  if (tmp !== void 0) {
6419
6419
  res += `${separator}${strEscape(key2)}: ${tmp}`;
6420
- separator = join26;
6420
+ separator = join28;
6421
6421
  }
6422
6422
  }
6423
6423
  if (keyLength > maximumBreadth) {
6424
6424
  const removedKeys = keyLength - maximumBreadth;
6425
6425
  res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
6426
- separator = join26;
6426
+ separator = join28;
6427
6427
  }
6428
6428
  if (separator !== "") {
6429
6429
  res = `
@@ -7990,7 +7990,7 @@ var require_buffer_list = __commonJS({
7990
7990
  }
7991
7991
  }, {
7992
7992
  key: "join",
7993
- value: function join26(s4) {
7993
+ value: function join28(s4) {
7994
7994
  if (this.length === 0) return "";
7995
7995
  var p3 = this.head;
7996
7996
  var ret = "" + p3.data;
@@ -19073,7 +19073,7 @@ var require_lodash = __commonJS({
19073
19073
  }
19074
19074
  return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, undefined2, comparator) : [];
19075
19075
  });
19076
- function join26(array, separator) {
19076
+ function join28(array, separator) {
19077
19077
  return array == null ? "" : nativeJoin.call(array, separator);
19078
19078
  }
19079
19079
  function last2(array) {
@@ -20992,7 +20992,7 @@ var require_lodash = __commonJS({
20992
20992
  lodash16.isUndefined = isUndefined2;
20993
20993
  lodash16.isWeakMap = isWeakMap;
20994
20994
  lodash16.isWeakSet = isWeakSet;
20995
- lodash16.join = join26;
20995
+ lodash16.join = join28;
20996
20996
  lodash16.kebabCase = kebabCase;
20997
20997
  lodash16.last = last2;
20998
20998
  lodash16.lastIndexOf = lastIndexOf;
@@ -29988,7 +29988,7 @@ var require_builder = __commonJS({
29988
29988
  }
29989
29989
  };
29990
29990
  exports2.SeqBuilder = SeqBuilder;
29991
- function join26(first2, second, ...others) {
29991
+ function join28(first2, second, ...others) {
29992
29992
  const seq = new SeqBuilder(first2, second);
29993
29993
  if (!others.length) {
29994
29994
  return seq;
@@ -29997,7 +29997,7 @@ var require_builder = __commonJS({
29997
29997
  return res.join(query);
29998
29998
  }, seq);
29999
29999
  }
30000
- exports2.join = join26;
30000
+ exports2.join = join28;
30001
30001
  var SymBuilder = class extends AbstractBuilder {
30002
30002
  constructor(opts) {
30003
30003
  super();
@@ -83615,7 +83615,7 @@ var require_lockfile = __commonJS({
83615
83615
  }
83616
83616
  const file = _ref22;
83617
83617
  if (yield exists2(file)) {
83618
- return readFile25(file);
83618
+ return readFile26(file);
83619
83619
  }
83620
83620
  }
83621
83621
  return null;
@@ -83634,7 +83634,7 @@ var require_lockfile = __commonJS({
83634
83634
  })();
83635
83635
  let readJsonAndFile = exports3.readJsonAndFile = (() => {
83636
83636
  var _ref24 = (0, (_asyncToGenerator2 || _load_asyncToGenerator()).default)(function* (loc) {
83637
- const file = yield readFile25(loc);
83637
+ const file = yield readFile26(loc);
83638
83638
  try {
83639
83639
  return {
83640
83640
  object: (0, (_map || _load_map()).default)(JSON.parse(stripBOM2(file))),
@@ -83874,7 +83874,7 @@ var require_lockfile = __commonJS({
83874
83874
  };
83875
83875
  })();
83876
83876
  exports3.copy = copy;
83877
- exports3.readFile = readFile25;
83877
+ exports3.readFile = readFile26;
83878
83878
  exports3.readFileRaw = readFileRaw;
83879
83879
  exports3.normalizeOS = normalizeOS;
83880
83880
  var _fs;
@@ -83972,7 +83972,7 @@ var require_lockfile = __commonJS({
83972
83972
  });
83973
83973
  });
83974
83974
  }
83975
- function readFile25(loc) {
83975
+ function readFile26(loc) {
83976
83976
  return _readFile(loc, "utf8").then(normalizeOS);
83977
83977
  }
83978
83978
  function readFileRaw(loc) {
@@ -190082,7 +190082,7 @@ var {
190082
190082
  } = import_index.default;
190083
190083
 
190084
190084
  // dist/index.js
190085
- import { readFile as readFile24 } from "fs/promises";
190085
+ import { readFile as readFile25 } from "fs/promises";
190086
190086
 
190087
190087
  // ../../node_modules/.pnpm/remeda@2.21.2/node_modules/remeda/dist/chunk-ANXBDSUI.js
190088
190088
  var s = { done: false, hasNext: false };
@@ -190515,6 +190515,7 @@ function utilFormatter() {
190515
190515
  }
190516
190516
 
190517
190517
  // ../web-compat-utils/src/logger-singleton.ts
190518
+ import { readFile } from "fs/promises";
190518
190519
  var CLILogger = class {
190519
190520
  logger = console;
190520
190521
  writeStream;
@@ -190594,6 +190595,16 @@ var CLILogger = class {
190594
190595
  });
190595
190596
  });
190596
190597
  }
190598
+ async getLogContent(logFilePath) {
190599
+ await this.finish();
190600
+ let logContent;
190601
+ try {
190602
+ logContent = await readFile(logFilePath, "utf-8");
190603
+ } catch (e) {
190604
+ console.error("Error reading log file", e);
190605
+ }
190606
+ return logContent;
190607
+ }
190597
190608
  set silent(silent) {
190598
190609
  if (!(this.logger instanceof import_winston.Logger)) throw new Error("Cannot set silent mode on console logger");
190599
190610
  this.logger.silent = silent;
@@ -191130,12 +191141,12 @@ var GoFixingManager = class {
191130
191141
 
191131
191142
  // ../fixing-management/src/fixing-management/maven/gradle-fixing-manager.ts
191132
191143
  import { existsSync as existsSync3 } from "node:fs";
191133
- import { readFile as readFile4 } from "node:fs/promises";
191144
+ import { readFile as readFile5 } from "node:fs/promises";
191134
191145
  import { join as join2, resolve as resolve3 } from "node:path";
191135
191146
 
191136
191147
  // ../fixing-management/src/fixing-management/maven/patch-application.ts
191137
191148
  import { existsSync } from "node:fs";
191138
- import { readFile, writeFile } from "node:fs/promises";
191149
+ import { readFile as readFile2, writeFile } from "node:fs/promises";
191139
191150
 
191140
191151
  // ../utils/src/version-comparison/version-satisfies.ts
191141
191152
  var import_semver2 = __toESM(require_semver2(), 1);
@@ -192376,7 +192387,7 @@ async function applyPatchResults(patchResults, ecosystem) {
192376
192387
  if (!existsSync(filePath)) {
192377
192388
  await writeFile(filePath, "", "utf-8");
192378
192389
  }
192379
- let fileContent = await readFile(filePath, "utf-8");
192390
+ let fileContent = await readFile2(filePath, "utf-8");
192380
192391
  for (const patch of sortedPatches) {
192381
192392
  const [start, end2] = patch.range;
192382
192393
  fileContent = fileContent.substring(0, start) + patch.replacementText + fileContent.substring(end2);
@@ -192387,7 +192398,7 @@ async function applyPatchResults(patchResults, ecosystem) {
192387
192398
 
192388
192399
  // ../fixing-management/src/fixing-management/maven/gradle-build-file-helper.ts
192389
192400
  var import_good_enough_parser = __toESM(require_cjs(), 1);
192390
- import { readFile as readFile2 } from "node:fs/promises";
192401
+ import { readFile as readFile3 } from "node:fs/promises";
192391
192402
 
192392
192403
  // ../fixing-management/src/fixing-management/maven/utils.ts
192393
192404
  import { existsSync as existsSync2 } from "fs";
@@ -192633,7 +192644,7 @@ async function findDependencyDeclsAndCatalogFiles(filePath) {
192633
192644
  };
192634
192645
  }
192635
192646
  if (!buildFileCache[filePath]) {
192636
- const fileContent = await readFile2(filePath, "utf-8");
192647
+ const fileContent = await readFile3(filePath, "utf-8");
192637
192648
  buildFileCache[filePath] = helper(fileContent);
192638
192649
  }
192639
192650
  return buildFileCache[filePath];
@@ -192660,7 +192671,7 @@ ${getConstraintsBlockString(groupId, artifactId, classifier, version3, indentati
192660
192671
 
192661
192672
  // ../fixing-management/src/fixing-management/maven/gradle-version-catalog-helper.ts
192662
192673
  var import_toml_eslint_parser = __toESM(require_lib10(), 1);
192663
- import { readFile as readFile3 } from "node:fs/promises";
192674
+ import { readFile as readFile4 } from "node:fs/promises";
192664
192675
  var versionCatalogCache = {};
192665
192676
  function clearVersionCatalogCache() {
192666
192677
  Object.keys(versionCatalogCache).forEach((key) => {
@@ -192783,7 +192794,7 @@ async function findVersionCatalogDeclarations(filePath) {
192783
192794
  };
192784
192795
  }
192785
192796
  if (!versionCatalogCache[filePath]) {
192786
- const fileContent = await readFile3(filePath, "utf-8");
192797
+ const fileContent = await readFile4(filePath, "utf-8");
192787
192798
  versionCatalogCache[filePath] = helper(fileContent);
192788
192799
  }
192789
192800
  return versionCatalogCache[filePath];
@@ -192995,7 +193006,7 @@ var GradleFixingManager = class {
192995
193006
  replacementText: constraintStr + "\n"
192996
193007
  };
192997
193008
  } else {
192998
- const fileContent = await readFile4(targetBuildFile, "utf-8");
193009
+ const fileContent = await readFile5(targetBuildFile, "utf-8");
192999
193010
  const indentationSize = getIndentationSize(fileContent);
193000
193011
  const prependNewline = fileContent.split("\n").some((line) => !line.trim());
193001
193012
  const finalConstraintStr = getDependencyConstraintString(
@@ -193183,7 +193194,7 @@ var GradleFixingManager = class {
193183
193194
  async createConstraintsForFile(buildFile, fixes) {
193184
193195
  const { dependenciesBlocks, constraintsBlocks } = await findDependencyDeclsAndCatalogFiles(buildFile);
193185
193196
  const fileType = buildFile.endsWith(".kts") ? "kotlin" : "groovy";
193186
- const fileContent = existsSync3(buildFile) ? await readFile4(buildFile, "utf-8") : "";
193197
+ const fileContent = existsSync3(buildFile) ? await readFile5(buildFile, "utf-8") : "";
193187
193198
  const indentationSize = getIndentationSize(fileContent);
193188
193199
  const constraintDeclarations = fixes.map(({ dependencyDetails, fixedVersion }) => {
193189
193200
  const [groupId, artifactId] = dependencyDetails.packageName.split(":");
@@ -193290,7 +193301,7 @@ import { resolve as resolve5 } from "path";
193290
193301
 
193291
193302
  // ../fixing-management/src/fixing-management/maven/pom-utils.ts
193292
193303
  var import_parse_xml = __toESM(require_dist(), 1);
193293
- import { readFile as readFile5 } from "node:fs/promises";
193304
+ import { readFile as readFile6 } from "node:fs/promises";
193294
193305
  import { existsSync as existsSync4, statSync } from "node:fs";
193295
193306
  import { resolve as resolve4, dirname } from "node:path";
193296
193307
  var evaluatedCache = {};
@@ -193326,7 +193337,7 @@ async function loadAndEvaluatePomWithCache(pomPath) {
193326
193337
  return evaluatedCache[pomPath];
193327
193338
  }
193328
193339
  async function buildEffectivePom(pomPath) {
193329
- const pomData = await readFile5(pomPath, "utf-8");
193340
+ const pomData = await readFile6(pomPath, "utf-8");
193330
193341
  const pomXml = (0, import_parse_xml.parseXml)(pomData, { includeOffsets: true });
193331
193342
  const indentation = inferIndentationFromParsedXml(pomXml, pomData);
193332
193343
  const parentPomPath = getParentPomPath(pomPath, pomXml);
@@ -193936,7 +193947,7 @@ import { basename, join as join4, resolve as resolve6 } from "path";
193936
193947
 
193937
193948
  // ../fixing-management/src/fixing-management/maven/socket-patch-application.ts
193938
193949
  import { existsSync as existsSync5 } from "node:fs";
193939
- import { readFile as readFile6, writeFile as writeFile2 } from "node:fs/promises";
193950
+ import { readFile as readFile7, writeFile as writeFile2 } from "node:fs/promises";
193940
193951
  function detectSocketPatchConflicts(patchResults) {
193941
193952
  const patchesByFile = /* @__PURE__ */ new Map();
193942
193953
  for (const patchResult of patchResults) {
@@ -194034,7 +194045,7 @@ async function applySocketPatchResults(ecosystem, patchResults) {
194034
194045
  if (!existsSync5(filePath)) {
194035
194046
  await writeFile2(filePath, "", "utf-8");
194036
194047
  }
194037
- let fileContent = await readFile6(filePath, "utf-8");
194048
+ let fileContent = await readFile7(filePath, "utf-8");
194038
194049
  for (const patch of sortedPatches) {
194039
194050
  const [start, end2] = patch.range;
194040
194051
  fileContent = fileContent.substring(0, start) + patch.replacementText + fileContent.substring(end2);
@@ -194170,7 +194181,7 @@ import assert2 from "assert";
194170
194181
  import { existsSync as existsSync6 } from "fs";
194171
194182
 
194172
194183
  // ../fixing-management/src/fixing-management/maven/gradle-lockfile-utils.ts
194173
- import { readFile as readFile7 } from "fs/promises";
194184
+ import { readFile as readFile8 } from "fs/promises";
194174
194185
  var lockfileCache = {};
194175
194186
  function clearLockfileCache() {
194176
194187
  Object.keys(lockfileCache).forEach((key) => {
@@ -194179,7 +194190,7 @@ function clearLockfileCache() {
194179
194190
  }
194180
194191
  async function loadLockfileWithCache(lockfilePath) {
194181
194192
  if (!lockfileCache[lockfilePath]) {
194182
- lockfileCache[lockfilePath] = await readFile7(lockfilePath, "utf-8");
194193
+ lockfileCache[lockfilePath] = await readFile8(lockfilePath, "utf-8");
194183
194194
  }
194184
194195
  return lockfileCache[lockfilePath];
194185
194196
  }
@@ -197484,7 +197495,7 @@ var {
197484
197495
 
197485
197496
  // ../utils/src/dashboard-api/socket-api.ts
197486
197497
  var import_form_data2 = __toESM(require_form_data2(), 1);
197487
- import { readFile as readFile8 } from "fs/promises";
197498
+ import { readFile as readFile9 } from "fs/promises";
197488
197499
  import { join as join3 } from "path";
197489
197500
 
197490
197501
  // ../web-compat-utils/src/ghsa.ts
@@ -197905,10 +197916,11 @@ async function getLatestBucketsSocket(subprojectPath, workspacePath) {
197905
197916
  return void 0;
197906
197917
  }
197907
197918
  }
197908
- async function useSocketComputeFixEndpoint(artifacts, vulnerableArtifactIdsForGhsas) {
197919
+ async function useSocketComputeFixEndpoint(autofixRunId, artifacts, vulnerableArtifactIdsForGhsas) {
197909
197920
  try {
197910
197921
  const url2 = getSocketApiUrl("fixes/compute-fixes");
197911
197922
  const data2 = {
197923
+ autofixRunId,
197912
197924
  artifacts,
197913
197925
  vulnerableArtifactIndexes: vulnerableArtifactIdsForGhsas
197914
197926
  };
@@ -197947,7 +197959,7 @@ async function fetchArtifactsFromManifestsTarHash(manifestsTarHash) {
197947
197959
  async function computeSocketFactArtifacts(rootDir, relativeManifestFilePaths) {
197948
197960
  const formData = new import_form_data2.default();
197949
197961
  for (const relativeManifestFilePath of relativeManifestFilePaths) {
197950
- const manifestContent = await readFile8(join3(rootDir, relativeManifestFilePath), "utf-8");
197962
+ const manifestContent = await readFile9(join3(rootDir, relativeManifestFilePath), "utf-8");
197951
197963
  const manifestContentAsJson = JSON.stringify(manifestContent);
197952
197964
  formData.append(relativeManifestFilePath, manifestContentAsJson, {
197953
197965
  filename: relativeManifestFilePath,
@@ -197974,6 +197986,62 @@ async function computeSocketFactArtifacts(rootDir, relativeManifestFilePaths) {
197974
197986
  return void 0;
197975
197987
  }
197976
197988
  }
197989
+ async function registerAutofixOrUpgradePurlRun(manifestsTarHash, repositoryName, options, cliCommand) {
197990
+ try {
197991
+ const url2 = getSocketApiUrl(`orgs/${process.env.SOCKET_ORG_SLUG}/fixes/register-autofix-or-upgrade-cli-run`);
197992
+ const data2 = {
197993
+ manifestsTarHash,
197994
+ repositoryName,
197995
+ options,
197996
+ cliCommand
197997
+ };
197998
+ const response = await axios2.post(url2, data2, { headers: getAuthHeaders() });
197999
+ return response.data.id;
198000
+ } catch (error) {
198001
+ handleError(error, "Error registering autofix or upgrade purl run", false);
198002
+ }
198003
+ }
198004
+ async function finalizeAutofixRun(autofixRunId, status, stackTrace, logFileContent) {
198005
+ try {
198006
+ const url2 = getSocketApiUrl(`orgs/${process.env.SOCKET_ORG_SLUG}/fixes/finalize-autofix-run`);
198007
+ const data2 = {
198008
+ autofixRunId,
198009
+ status,
198010
+ stackTrace,
198011
+ logFileContent
198012
+ };
198013
+ await axios2.post(url2, data2, { headers: getAuthHeaders() });
198014
+ } catch (error) {
198015
+ handleError(error, "Error finalizing autofix run", false);
198016
+ }
198017
+ }
198018
+ async function registerUpgradePurlRun(autofixRunId, upgradeSpecs) {
198019
+ try {
198020
+ const url2 = getSocketApiUrl(`orgs/${process.env.SOCKET_ORG_SLUG}/fixes/register-upgrade-purl-run`);
198021
+ const data2 = {
198022
+ cliRunId: autofixRunId,
198023
+ upgradeSpecs
198024
+ };
198025
+ const response = await axios2.post(url2, data2, { headers: getAuthHeaders() });
198026
+ return response.data.id;
198027
+ } catch (error) {
198028
+ handleError(error, "Error registering upgrade purl run", false);
198029
+ }
198030
+ }
198031
+ async function finalizeUpgradePurlRun(upgradePurlRunId, status, stackTrace, logFileContent) {
198032
+ try {
198033
+ const url2 = getSocketApiUrl(`orgs/${process.env.SOCKET_ORG_SLUG}/fixes/finalize-upgrade-purl-run`);
198034
+ const data2 = {
198035
+ upgradePurlRunId,
198036
+ status,
198037
+ stackTrace,
198038
+ logFileContent
198039
+ };
198040
+ await axios2.post(url2, data2, { headers: getAuthHeaders() });
198041
+ } catch (error) {
198042
+ handleError(error, "Error finalizing upgrade purl run", false);
198043
+ }
198044
+ }
197977
198045
  function getSocketAPI() {
197978
198046
  return {
197979
198047
  createSocketTier1Scan,
@@ -197981,7 +198049,11 @@ function getSocketAPI() {
197981
198049
  registerSubprojectsSocket,
197982
198050
  registerCLIProgressSocket,
197983
198051
  registerAnalysisMetadataSocket,
197984
- getLatestBucketsSocket
198052
+ getLatestBucketsSocket,
198053
+ registerAutofixOrUpgradePurlRun,
198054
+ finalizeAutofixRun,
198055
+ registerUpgradePurlRun,
198056
+ finalizeUpgradePurlRun
197985
198057
  };
197986
198058
  }
197987
198059
 
@@ -198269,12 +198341,12 @@ var MavenSocketUpgradeManager = class {
198269
198341
 
198270
198342
  // ../fixing-management/src/fixing-management/maven/sbt-fixing-manager.ts
198271
198343
  import { existsSync as existsSync7 } from "node:fs";
198272
- import { readFile as readFile10 } from "node:fs/promises";
198344
+ import { readFile as readFile11 } from "node:fs/promises";
198273
198345
  import { join as join5 } from "node:path";
198274
198346
 
198275
198347
  // ../fixing-management/src/fixing-management/maven/sbt-fixing-helper.ts
198276
198348
  var import_good_enough_parser2 = __toESM(require_cjs(), 1);
198277
- import { readFile as readFile9 } from "node:fs/promises";
198349
+ import { readFile as readFile10 } from "node:fs/promises";
198278
198350
  var sbtFileCache = {};
198279
198351
  function clearSbtFileCache() {
198280
198352
  Object.keys(sbtFileCache).forEach((key) => {
@@ -198395,7 +198467,7 @@ async function findModuleIds(filePath) {
198395
198467
  return ctx?.moduleIds ?? [];
198396
198468
  }
198397
198469
  if (!sbtFileCache[filePath]) {
198398
- const fileContent = await readFile9(filePath, "utf-8");
198470
+ const fileContent = await readFile10(filePath, "utf-8");
198399
198471
  sbtFileCache[filePath] = helper(fileContent);
198400
198472
  }
198401
198473
  return sbtFileCache[filePath];
@@ -198612,7 +198684,7 @@ var SbtFixingManager = class {
198612
198684
  `
198613
198685
  };
198614
198686
  } else {
198615
- const fileContent = await readFile10(workspaceBuildSbtPath, "utf-8");
198687
+ const fileContent = await readFile11(workspaceBuildSbtPath, "utf-8");
198616
198688
  const prependNewline = fileContent.split("\n").some((line) => !line.trim());
198617
198689
  return {
198618
198690
  manifestFilePath: workspaceBuildSbtPath,
@@ -198691,7 +198763,7 @@ ${indent(1, indentationSize)}`)}
198691
198763
  replacementText: overrideText
198692
198764
  };
198693
198765
  } else {
198694
- const fileContent = await readFile10(workspaceBuildSbtPath, "utf-8");
198766
+ const fileContent = await readFile11(workspaceBuildSbtPath, "utf-8");
198695
198767
  const indentationSize = getIndentationSize(fileContent);
198696
198768
  const prependNewline = fileContent.length > 0 && !fileContent.endsWith("\n\n");
198697
198769
  const overrideText = `dependencyOverrides ++= Seq(
@@ -198709,7 +198781,7 @@ ${indent(1, indentationSize)}`)}
198709
198781
  };
198710
198782
 
198711
198783
  // ../fixing-management/src/fixing-management/npm/npm-fixing-manager.ts
198712
- import { readFile as readFile11, writeFile as writeFile3 } from "fs/promises";
198784
+ import { readFile as readFile12, writeFile as writeFile3 } from "fs/promises";
198713
198785
  import { resolve as resolve9 } from "path";
198714
198786
 
198715
198787
  // ../utils/src/npm-utils.ts
@@ -205459,7 +205531,7 @@ var NpmFixingManager = class extends NpmEcosystemFixingManager {
205459
205531
  }
205460
205532
  async applySecurityFixesSpecificPackageManager(fixes) {
205461
205533
  const pkgLockLocation = resolve9(this.rootDir, this.subprojectPath, "package-lock.json");
205462
- const packageLockContent = await readFile11(pkgLockLocation, "utf-8");
205534
+ const packageLockContent = await readFile12(pkgLockLocation, "utf-8");
205463
205535
  const getPackageName = (pkgPath) => {
205464
205536
  const strings = pkgPath.split("node_modules/");
205465
205537
  return strings[strings.length - 1];
@@ -205488,7 +205560,7 @@ var NpmFixingManager = class extends NpmEcosystemFixingManager {
205488
205560
  };
205489
205561
 
205490
205562
  // ../fixing-management/src/fixing-management/npm/pnpm-fixing-manager.ts
205491
- import { readFile as readFile12, writeFile as writeFile4 } from "fs/promises";
205563
+ import { readFile as readFile13, writeFile as writeFile4 } from "fs/promises";
205492
205564
  import { resolve as resolve10 } from "path";
205493
205565
  var import_yaml = __toESM(require_dist10(), 1);
205494
205566
  var import_lockfile_file2 = __toESM(require_lib25(), 1);
@@ -205630,7 +205702,7 @@ function getVersionNumber(version3) {
205630
205702
  return match2 ? `${match2[1]}` : version3;
205631
205703
  }
205632
205704
  async function readYamlFile(workspaceYamlFile) {
205633
- const workspaceYamlString = await readFile12(workspaceYamlFile, "utf8");
205705
+ const workspaceYamlString = await readFile13(workspaceYamlFile, "utf8");
205634
205706
  const parser = new import_yaml.Parser();
205635
205707
  const [ast] = parser.parse(workspaceYamlString);
205636
205708
  return ast;
@@ -205668,7 +205740,7 @@ function updateCatalog(update2, map2) {
205668
205740
 
205669
205741
  // ../fixing-management/src/fixing-management/npm/yarn-fixing-manager.ts
205670
205742
  import { readFileSync as readFileSync3 } from "fs";
205671
- import { readFile as readFile13, writeFile as writeFile5 } from "fs/promises";
205743
+ import { readFile as readFile14, writeFile as writeFile5 } from "fs/promises";
205672
205744
  import { resolve as resolve12 } from "path";
205673
205745
 
205674
205746
  // ../utils/src/package-utils.ts
@@ -205829,7 +205901,7 @@ var YarnFixingManager = class extends NpmEcosystemFixingManager {
205829
205901
  logger.info("Installation completed.");
205830
205902
  }
205831
205903
  async getYarnLockObj(filePath) {
205832
- const fileString = await readFile13(filePath, "utf8");
205904
+ const fileString = await readFile14(filePath, "utf8");
205833
205905
  return this.yarnType === "classic" ? (0, import_yarnlock_parse_raw.parseYarnLockRawV1)(fileString) : (0, import_yarnlock_parse_raw.parseYarnLockRawV2)(fileString);
205834
205906
  }
205835
205907
  async writeYarnObj(yarnObj, filepath) {
@@ -206038,7 +206110,7 @@ var RushFixingManager = class {
206038
206110
  };
206039
206111
 
206040
206112
  // ../fixing-management/src/fixing-management/nuget/nuget-fixing-manager.ts
206041
- import { readFile as readFile14, writeFile as writeFile6 } from "fs/promises";
206113
+ import { readFile as readFile15, writeFile as writeFile6 } from "fs/promises";
206042
206114
  import { join as join9 } from "path";
206043
206115
 
206044
206116
  // ../utils/src/nuget-utils.ts
@@ -206141,14 +206213,14 @@ var NugetFixingManager = class {
206141
206213
  if (projectFiles.length !== 1)
206142
206214
  throw new Error("Applying fixes to workspaces with more than 1 project file currently not supported");
206143
206215
  const projectFilePath = join9(this.getAbsWsPath(wsPath), projectFiles[0]);
206144
- const initialProjectFile = await readFile14(projectFilePath, "utf-8");
206216
+ const initialProjectFile = await readFile15(projectFilePath, "utf-8");
206145
206217
  const initialLockFile = await this.restoreWorkspaceAndParseLockFile(wsPath);
206146
206218
  await applySeries(fixesWithId, async ({ fixId, vulnerabilityFixes }) => {
206147
206219
  await this.applySecurityFixesForWorkspace(wsPath, projectFilePath, vulnerabilityFixes, dependencyTree);
206148
206220
  signalFixApplied2?.(fixId, this.subprojectPath, wsPath, vulnerabilityFixes);
206149
206221
  });
206150
- const finalProjectFile = await readFile14(projectFilePath, "utf-8");
206151
- const finalLockFile = JSON.parse(await readFile14(this.getLockFilePath(wsPath), "utf-8"));
206222
+ const finalProjectFile = await readFile15(projectFilePath, "utf-8");
206223
+ const finalLockFile = JSON.parse(await readFile15(this.getLockFilePath(wsPath), "utf-8"));
206152
206224
  await writeFile6(projectFilePath, initialProjectFile);
206153
206225
  await writeFile6(this.getLockFilePath(wsPath), JSON.stringify(initialLockFile, null, 2));
206154
206226
  return { projectFile: finalProjectFile, lockFile: finalLockFile };
@@ -206180,7 +206252,7 @@ var NugetFixingManager = class {
206180
206252
  }
206181
206253
  }
206182
206254
  async applySecurityFixesForWorkspace(wsPath, projectFilePath, vulnFixes, dependencyTree) {
206183
- const initialProjectFile = await readFile14(projectFilePath, "utf-8");
206255
+ const initialProjectFile = await readFile15(projectFilePath, "utf-8");
206184
206256
  const initialLockFile = await this.restoreWorkspaceAndParseLockFile(wsPath);
206185
206257
  const typeCache = new Cache();
206186
206258
  const requestedCache = new Cache();
@@ -206270,7 +206342,7 @@ var NugetFixingManager = class {
206270
206342
  async restoreWorkspaceAndParseLockFile(wsPath) {
206271
206343
  const succeeded = await execAndLogOnFailure("dotnet restore --use-lock-file", this.getAbsWsPath(wsPath));
206272
206344
  if (!succeeded) throw new Error(`Error applying fix - could not restore project ${this.subprojectPath}/${wsPath}`);
206273
- return JSON.parse(await readFile14(this.getLockFilePath(wsPath), "utf-8"));
206345
+ return JSON.parse(await readFile15(this.getLockFilePath(wsPath), "utf-8"));
206274
206346
  }
206275
206347
  getLockFilePath(wsPath, lockFileName = "packages.lock.json") {
206276
206348
  return join9(this.getAbsWsPath(wsPath), lockFileName);
@@ -207027,6 +207099,7 @@ function utilFormatter2() {
207027
207099
  }
207028
207100
 
207029
207101
  // ../web-compat-utils/dist/logger-singleton.js
207102
+ import { readFile as readFile16 } from "fs/promises";
207030
207103
  var CLILogger2 = class {
207031
207104
  logger = console;
207032
207105
  writeStream;
@@ -207102,6 +207175,16 @@ var CLILogger2 = class {
207102
207175
  });
207103
207176
  });
207104
207177
  }
207178
+ async getLogContent(logFilePath) {
207179
+ await this.finish();
207180
+ let logContent;
207181
+ try {
207182
+ logContent = await readFile16(logFilePath, "utf-8");
207183
+ } catch (e) {
207184
+ console.error("Error reading log file", e);
207185
+ }
207186
+ return logContent;
207187
+ }
207105
207188
  set silent(silent) {
207106
207189
  if (!(this.logger instanceof import_winston2.Logger))
207107
207190
  throw new Error("Cannot set silent mode on console logger");
@@ -207141,13 +207224,13 @@ async function detectVariantMaven(projectDir) {
207141
207224
  // ../docker-management/src/maven/gradle-version-detector.ts
207142
207225
  import { existsSync as existsSync13 } from "fs";
207143
207226
  import { join as join14 } from "path";
207144
- import { readFile as readFile15 } from "fs/promises";
207227
+ import { readFile as readFile17 } from "fs/promises";
207145
207228
  async function detectVariantGradle(projectDir) {
207146
207229
  return sanitizeJvmVariant("GRADLE", projectDir, await detect(projectDir));
207147
207230
  }
207148
207231
  async function detect(projectDir) {
207149
207232
  const gradleWrapperPropertiesPath = join14(projectDir, "gradle", "wrapper", "gradle-wrapper.properties");
207150
- const gradleWrapperProperties = existsSync13(gradleWrapperPropertiesPath) ? (await readFile15(gradleWrapperPropertiesPath, "utf-8")).split("\n").map((line) => line.trim()).filter((line) => !line.startsWith("#")).filter((line) => line) : void 0;
207233
+ const gradleWrapperProperties = existsSync13(gradleWrapperPropertiesPath) ? (await readFile17(gradleWrapperPropertiesPath, "utf-8")).split("\n").map((line) => line.trim()).filter((line) => !line.startsWith("#")).filter((line) => line) : void 0;
207151
207234
  if (!gradleWrapperProperties) return void 0;
207152
207235
  const distributionUrlRegex = /.*gradle-(\d+(\.\d+(\.\d+)?)?)/;
207153
207236
  for (const prop2 of gradleWrapperProperties) {
@@ -207163,13 +207246,13 @@ async function detect(projectDir) {
207163
207246
  // ../docker-management/src/maven/sbt-version-detector.ts
207164
207247
  import { existsSync as existsSync14 } from "fs";
207165
207248
  import { join as join15 } from "path";
207166
- import { readFile as readFile16 } from "fs/promises";
207249
+ import { readFile as readFile18 } from "fs/promises";
207167
207250
  async function detectVariantSbt(projectDir) {
207168
207251
  return sanitizeJvmVariant("SBT", projectDir, await detect2(projectDir));
207169
207252
  }
207170
207253
  async function detect2(projectDir) {
207171
207254
  const sbtBuildPropertiesPath = join15(projectDir, "project", "build.properties");
207172
- const sbtBuildProperties = existsSync14(sbtBuildPropertiesPath) ? (await readFile16(sbtBuildPropertiesPath, "utf-8")).split("\n").map((line) => line.trim()).filter((line) => !line.startsWith("#")).filter((line) => line) : void 0;
207255
+ const sbtBuildProperties = existsSync14(sbtBuildPropertiesPath) ? (await readFile18(sbtBuildPropertiesPath, "utf-8")).split("\n").map((line) => line.trim()).filter((line) => !line.startsWith("#")).filter((line) => line) : void 0;
207173
207256
  if (!sbtBuildProperties) return void 0;
207174
207257
  for (const prop2 of sbtBuildProperties) {
207175
207258
  const [key, value] = prop2.split("=");
@@ -207283,7 +207366,7 @@ async function findReachabilityAnalyzersDockerImage(ecosystem) {
207283
207366
  // ../other-modules-communicator/src/other-modules-communicator.ts
207284
207367
  var import_lodash11 = __toESM(require_lodash(), 1);
207285
207368
  import { rmSync } from "fs";
207286
- import { mkdir, readFile as readFile17, writeFile as writeFile7 } from "fs/promises";
207369
+ import { mkdir, readFile as readFile19, writeFile as writeFile7 } from "fs/promises";
207287
207370
  import { platform } from "os";
207288
207371
  import { join as join19, posix as posix2, relative as relative8, sep as sep3 } from "path";
207289
207372
 
@@ -207342,6 +207425,18 @@ async function createTmpDirectory(prefix) {
207342
207425
  throw err;
207343
207426
  }
207344
207427
  }
207428
+ async function withTmpDirectory(prefix, fn2, deleteTmpDir = true) {
207429
+ const tmpDir = await createTmpDirectory(prefix);
207430
+ try {
207431
+ return await fn2(tmpDir);
207432
+ } finally {
207433
+ if (deleteTmpDir) {
207434
+ await rm(tmpDir, { recursive: true, force: true });
207435
+ } else {
207436
+ console.log("Not deleting tmp dir", tmpDir);
207437
+ }
207438
+ }
207439
+ }
207345
207440
 
207346
207441
  // ../../node_modules/.pnpm/uuid@9.0.1/node_modules/uuid/dist/esm-node/rng.js
207347
207442
  import crypto2 from "crypto";
@@ -207721,7 +207816,7 @@ var OtherModulesCommunicator = class {
207721
207816
  COANA_API_KEY: this.apiKey.type === "present" ? this.apiKey.value : ""
207722
207817
  }
207723
207818
  );
207724
- return JSON.parse(await readFile17(outputFilePathThisProcess, "utf-8")).result;
207819
+ return JSON.parse(await readFile19(outputFilePathThisProcess, "utf-8")).result;
207725
207820
  }
207726
207821
  async runReachabilityAnalyzerCommand(commandName, ecosystem, subprojectPath, workspacePath, args2, env) {
207727
207822
  const tmpDir = await this.getTmpDirForSubproject(subprojectPath);
@@ -207782,7 +207877,7 @@ var OtherModulesCommunicator = class {
207782
207877
  [...args2, "-o", outputFilePathOtherProcess],
207783
207878
  env
207784
207879
  );
207785
- return JSON.parse(await readFile17(outputFilePathThisProcess, "utf-8")).result;
207880
+ return JSON.parse(await readFile19(outputFilePathThisProcess, "utf-8")).result;
207786
207881
  }
207787
207882
  async runInDocker(ecosystem, image, entryPoint, commandName, args2, subprojectPath, tmpDir, env = process.env) {
207788
207883
  if (!await pullDockerImage(image)) return false;
@@ -209240,12 +209335,12 @@ import { join as join22, relative as relative9, resolve as resolve20 } from "pat
209240
209335
 
209241
209336
  // ../project-management/src/project-management/ecosystem-management/ecosystem-specs.ts
209242
209337
  import { existsSync as existsSync18 } from "fs";
209243
- import { readdir as readdir5, readFile as readFile20 } from "fs/promises";
209338
+ import { readdir as readdir5, readFile as readFile22 } from "fs/promises";
209244
209339
  import { join as join21, sep as sep4 } from "path";
209245
209340
 
209246
209341
  // ../utils/src/pip-utils.ts
209247
209342
  import { existsSync as existsSync17 } from "fs";
209248
- import { readFile as readFile19 } from "fs/promises";
209343
+ import { readFile as readFile21 } from "fs/promises";
209249
209344
  import { resolve as resolve19 } from "path";
209250
209345
  import util4 from "util";
209251
209346
 
@@ -209254,7 +209349,7 @@ var import_lodash13 = __toESM(require_lodash(), 1);
209254
209349
  var import_semver4 = __toESM(require_semver2(), 1);
209255
209350
  import { execFileSync as execFileSync2 } from "child_process";
209256
209351
  import { constants as constants2 } from "fs";
209257
- import { access as access4, readFile as readFile18 } from "fs/promises";
209352
+ import { access as access4, readFile as readFile20 } from "fs/promises";
209258
209353
  import { join as join20, resolve as resolve18 } from "path";
209259
209354
  import util3 from "util";
209260
209355
  var { once: once7 } = import_lodash13.default;
@@ -209262,7 +209357,7 @@ var systemPython = once7(() => execFileSync2("which", ["python"], { encoding: "u
209262
209357
 
209263
209358
  // ../utils/src/pip-utils.ts
209264
209359
  async function isSetupPySetuptools(file) {
209265
- const content = await readFile19(file, "utf-8");
209360
+ const content = await readFile21(file, "utf-8");
209266
209361
  return content.includes("setup(") && (/^\s*from\s+(?:setuptools|distutils\.core)\s+import\s+.*setup/m.test(content) || /^\s*import\s+(?:setuptools|distutils\.core)/m.test(content));
209267
209362
  }
209268
209363
 
@@ -209344,7 +209439,7 @@ function packageManagerIfPackageJSONExistsAndValid(packageManager) {
209344
209439
  if (!existsSync18(join21(projectDir, "package.json"))) return void 0;
209345
209440
  const packageJSONPath = join21(projectDir, "package.json");
209346
209441
  try {
209347
- JSON.parse(await readFile20(packageJSONPath, "utf-8"));
209442
+ JSON.parse(await readFile22(packageJSONPath, "utf-8"));
209348
209443
  return packageManager;
209349
209444
  } catch (e) {
209350
209445
  throw new InvalidProjectFileError(projectDir, "package.json");
@@ -209605,7 +209700,7 @@ ${detailsString}` : ""}`;
209605
209700
 
209606
209701
  // dist/cli-core.js
209607
209702
  import { writeFileSync as writeFileSync3 } from "fs";
209608
- import { mkdir as mkdir2, readFile as readFile23, writeFile as writeFile9 } from "fs/promises";
209703
+ import { mkdir as mkdir2, writeFile as writeFile9 } from "fs/promises";
209609
209704
 
209610
209705
  // ../../node_modules/.pnpm/kleur@4.1.5/node_modules/kleur/index.mjs
209611
209706
  var FORCE_COLOR;
@@ -209710,7 +209805,7 @@ var kleur_default = $;
209710
209805
  // dist/cli-core.js
209711
209806
  var import_lodash15 = __toESM(require_lodash(), 1);
209712
209807
  import os from "os";
209713
- import { join as join24, relative as relative11, resolve as resolve23 } from "path";
209808
+ import { join as join25, relative as relative11, resolve as resolve23 } from "path";
209714
209809
 
209715
209810
  // ../utils/src/dashboard-api/shared-api.ts
209716
209811
  var DashboardAPI = class {
@@ -210030,7 +210125,7 @@ var DEFAULT_REPORT_FILENAME_BASE = "coana-report";
210030
210125
 
210031
210126
  // dist/internal/exclude-dirs-from-configuration-files.js
210032
210127
  import { existsSync as existsSync19 } from "fs";
210033
- import { readFile as readFile21 } from "fs/promises";
210128
+ import { readFile as readFile23 } from "fs/promises";
210034
210129
  import { basename as basename6, resolve as resolve22 } from "path";
210035
210130
  var import_yaml2 = __toESM(require_dist11(), 1);
210036
210131
  async function inferExcludeDirsFromConfigurationFiles(rootWorkingDir) {
@@ -210044,7 +210139,7 @@ async function inferExcludeDirsFromConfigurationFiles(rootWorkingDir) {
210044
210139
  }
210045
210140
  async function inferExcludeDirsFromSocketConfig(socketConfigFile) {
210046
210141
  try {
210047
- const config3 = (0, import_yaml2.parse)(await readFile21(socketConfigFile, "utf8"));
210142
+ const config3 = (0, import_yaml2.parse)(await readFile23(socketConfigFile, "utf8"));
210048
210143
  const version3 = config3.version;
210049
210144
  const ignorePaths = config3[version3 === 1 ? "ignore" : "projectIgnorePaths"];
210050
210145
  if (!ignorePaths)
@@ -210158,9 +210253,9 @@ function transformToVulnChainNode(dependencyTree) {
210158
210253
  }
210159
210254
 
210160
210255
  // dist/internal/socket-mode-helpers-socket-dependency-trees.js
210161
- var import_picomatch2 = __toESM(require_picomatch2(), 1);
210162
- import { basename as basename7, dirname as dirname8, sep as sep5 } from "path";
210163
210256
  var import_packageurl_js = __toESM(require_packageurl_js(), 1);
210257
+ var import_picomatch2 = __toESM(require_picomatch2(), 1);
210258
+ import { basename as basename7, dirname as dirname8, join as join23, sep as sep5 } from "path";
210164
210259
  var REQUIREMENTS_FILES_SEARCH_DEPTH2 = 3;
210165
210260
  function inferWorkspaceFromManifestPath(ecosystem, manifestPath, properPythonProjects) {
210166
210261
  switch (ecosystem) {
@@ -210183,7 +210278,7 @@ function inferWorkspaceFromManifestPath(ecosystem, manifestPath, properPythonPro
210183
210278
  return workspaceDir;
210184
210279
  }
210185
210280
  if (base.endsWith(".txt")) {
210186
- const isWithinProperProject = properPythonProjects.some((properProjectDir) => workspaceDir.startsWith(properProjectDir) && workspaceDir.replace(properProjectDir, "").split(sep5).length <= REQUIREMENTS_FILES_SEARCH_DEPTH2);
210281
+ const isWithinProperProject = properPythonProjects.some((properProjectDir) => (workspaceDir === "." || workspaceDir.startsWith(properProjectDir)) && workspaceDir.replace(properProjectDir, "").split(sep5).length <= REQUIREMENTS_FILES_SEARCH_DEPTH2);
210187
210282
  if (isWithinProperProject) {
210188
210283
  return void 0;
210189
210284
  }
@@ -210273,10 +210368,9 @@ async function fetchArtifactsFromSocket(rootWorkingDirectory, manifestsTarHash)
210273
210368
  for (const file of allFiles) {
210274
210369
  const base = basename7(file);
210275
210370
  const workspaceDir = dirname8(file) || ".";
210276
- if (base === "pyproject.toml" || base === "setup.py" && await isSetupPySetuptools(file)) {
210277
- const normalizedDir = workspaceDir === "." ? "." : workspaceDir;
210278
- if (!properPythonProjects.includes(normalizedDir)) {
210279
- properPythonProjects.push(normalizedDir);
210371
+ if (base === "pyproject.toml" || base === "setup.py" && await isSetupPySetuptools(join23(rootWorkingDirectory, file))) {
210372
+ if (!properPythonProjects.includes(workspaceDir)) {
210373
+ properPythonProjects.push(workspaceDir);
210280
210374
  }
210281
210375
  }
210282
210376
  }
@@ -210288,14 +210382,23 @@ async function fetchArtifactsFromSocket(rootWorkingDirectory, manifestsTarHash)
210288
210382
  const ecosystem = getAdvisoryEcosystemFromPurlType(artifact.type);
210289
210383
  if (!ecosystem)
210290
210384
  continue;
210291
- const manifestFiles = artifact.manifestFiles?.map((ref) => ref.file) ?? [];
210292
- const allAncestorIds = getAllToplevelAncestors(artifactMap, artifact.id);
210293
- allAncestorIds.forEach((ancestorId) => {
210294
- const ancestor = artifactMap.get(ancestorId);
210295
- if (ancestor?.manifestFiles) {
210296
- manifestFiles.push(...ancestor.manifestFiles.map((ref) => ref.file));
210385
+ const manifestFiles = [];
210386
+ switch (ecosystem) {
210387
+ case "MAVEN": {
210388
+ manifestFiles.push(...(await getFilesRelative(rootWorkingDirectory)).filter((file) => (0, import_picomatch2.default)("{{*-*.,}pom{.xml,},gradle.lockfile}")(basename7(file))));
210389
+ break;
210297
210390
  }
210298
- });
210391
+ case "NUGET": {
210392
+ manifestFiles.push(...(await getFilesRelative(rootWorkingDirectory)).filter((file) => (0, import_picomatch2.default)("{*.csproj,packages.lock.json}")(basename7(file))));
210393
+ break;
210394
+ }
210395
+ default: {
210396
+ artifact.manifestFiles?.forEach((ref) => manifestFiles.push(ref.file));
210397
+ const allAncestorIds = getAllToplevelAncestors(artifactMap, artifact.id);
210398
+ allAncestorIds.forEach((ancestorId) => artifactMap.get(ancestorId)?.manifestFiles?.forEach((ref) => manifestFiles.push(ref.file)));
210399
+ break;
210400
+ }
210401
+ }
210299
210402
  let manifestAndWorkspace = manifestFiles.map((manifestFile) => [
210300
210403
  manifestFile,
210301
210404
  inferWorkspaceFromManifestPath(ecosystem, manifestFile, properPythonProjects)
@@ -210323,33 +210426,14 @@ async function fetchArtifactsFromSocket(rootWorkingDirectory, manifestsTarHash)
210323
210426
  }
210324
210427
  const workspaceData = ecosystemToWorkspaceToAnalysisData[ecosystem][workspace];
210325
210428
  if (workspaceData.type === "socket") {
210326
- switch (ecosystem) {
210327
- case "MAVEN": {
210328
- if (!workspaceData.data.manifestFiles.length) {
210329
- const allFiles2 = await getFilesRelative(rootWorkingDirectory);
210330
- const manifestFiles2 = allFiles2.filter((file) => (0, import_picomatch2.default)("{{*-*.,}pom{.xml,},gradle.lockfile}")(basename7(file)));
210331
- workspaceData.data.manifestFiles.push(...manifestFiles2);
210332
- }
210333
- break;
210334
- }
210335
- case "NUGET": {
210336
- if (!workspaceData.data.manifestFiles.length) {
210337
- const allFiles2 = await getFilesRelative(rootWorkingDirectory);
210338
- const manifestFiles2 = allFiles2.filter((file) => (0, import_picomatch2.default)("{*.csproj,packages.lock.json}")(basename7(file)));
210339
- workspaceData.data.manifestFiles.push(...manifestFiles2);
210340
- }
210341
- break;
210342
- }
210343
- default: {
210344
- if (!workspaceData.data.manifestFiles.includes(manifestFile)) {
210345
- workspaceData.data.manifestFiles.push(manifestFile);
210346
- }
210347
- break;
210348
- }
210429
+ if (!workspaceData.data.manifestFiles.includes(manifestFile)) {
210430
+ workspaceData.data.manifestFiles.push(manifestFile);
210349
210431
  }
210350
210432
  workspaceData.data.artifacts.push(artifact);
210351
210433
  }
210352
- if (artifact.vulnerabilities && artifact.vulnerabilities.length > 0) {
210434
+ }
210435
+ if (artifact.vulnerabilities && artifact.vulnerabilities.length > 0) {
210436
+ for (const workspace of i5(manifestAndWorkspace.map(([, workspace2]) => workspace2))) {
210353
210437
  for (const vuln of artifact.vulnerabilities) {
210354
210438
  const vulnerability = {
210355
210439
  url: vuln.ghsaId,
@@ -210358,7 +210442,7 @@ async function fetchArtifactsFromSocket(rootWorkingDirectory, manifestsTarHash)
210358
210442
  name: artifact.name ?? "",
210359
210443
  dependency: artifact.name ?? "",
210360
210444
  vulnChainDetails: computeVulnChainDetails2(artifacts, artifact.id),
210361
- vulnerabilityAccessPaths: vuln.reachabilityData?.pattern ?? null,
210445
+ vulnerabilityAccessPaths: vuln.reachabilityData?.undeterminableReachability ? vuln.reachabilityData.publicComment ?? "" : vuln.reachabilityData?.pattern ?? null,
210362
210446
  ecosystem,
210363
210447
  artifactId: artifact.id
210364
210448
  };
@@ -210612,7 +210696,7 @@ function toSocketFactsSocketDependencyTree(artifacts, vulnerabilities, tier1Reac
210612
210696
  }
210613
210697
 
210614
210698
  // dist/internal/vulnerability-scanning.js
210615
- import { readFile as readFile22 } from "fs/promises";
210699
+ import { readFile as readFile24 } from "fs/promises";
210616
210700
 
210617
210701
  // ../security-auditor/security-auditor-builder/src/mongo-connection.ts
210618
210702
  var import_mongodb = __toESM(require_lib30(), 1);
@@ -224128,7 +224212,7 @@ var { root: root2 } = static_exports;
224128
224212
  // ../utils/src/maven-utils.ts
224129
224213
  var import_lodash14 = __toESM(require_lodash(), 1);
224130
224214
  import { existsSync as existsSync20, readdirSync as readdirSync4, statSync as statSync4 } from "fs";
224131
- import { join as join23 } from "path";
224215
+ import { join as join24 } from "path";
224132
224216
  var { memoize: memoize3 } = import_lodash14.default;
224133
224217
  var memoizedParseShellArgs = memoize3(parseShellArgs);
224134
224218
  var MAVEN_PUBLIC_REPOSITORIES = [
@@ -225481,7 +225565,7 @@ async function scanForVulnerabilities(dependencyTree, offlineVulnerabilityScanne
225481
225565
  }
225482
225566
  async function offlineScan(dependencyTree, offlineVulnerabilityScannerDBPath) {
225483
225567
  logger.info("using offline vulnerability scanner db");
225484
- const offlineVulnerabilityScannerDB = JSON.parse(await readFile22(offlineVulnerabilityScannerDBPath, "utf-8"));
225568
+ const offlineVulnerabilityScannerDB = JSON.parse(await readFile24(offlineVulnerabilityScannerDBPath, "utf-8"));
225485
225569
  const { ecosystemToUrlToVulnerabilityDetails, vulnerabilityDatabase } = offlineVulnerabilityScannerDB;
225486
225570
  const coanaSupportedVulnerabilitiesLoader = CoanaSupportedVulnerabilitiesLoader.create(ecosystemToUrlToVulnerabilityDetails);
225487
225571
  const vulnerabilityAccessPathLoader = CoanaSupportedVulnerabilitiesLoader.create(ecosystemToUrlToVulnerabilityDetails);
@@ -225499,7 +225583,7 @@ async function onlineScan(dependencyTree, apiKey, timeout) {
225499
225583
  }
225500
225584
 
225501
225585
  // dist/version.js
225502
- var version2 = "14.11.18";
225586
+ var version2 = "14.12.3";
225503
225587
 
225504
225588
  // dist/cli-core.js
225505
225589
  var { mapValues, omit, partition, pick } = import_lodash15.default;
@@ -225601,7 +225685,7 @@ var CliCore = class {
225601
225685
  }
225602
225686
  }
225603
225687
  async main() {
225604
- this.coanaLogPath = join24(await createTmpDirectory("coana-cli-"), "coana-log.txt");
225688
+ this.coanaLogPath = join25(await createTmpDirectory("coana-cli-"), "coana-log.txt");
225605
225689
  logger.initWinstonLogger(this.options.debug, this.coanaLogPath);
225606
225690
  logger.silent = this.options.silent;
225607
225691
  try {
@@ -225688,24 +225772,12 @@ var CliCore = class {
225688
225772
  await writeFile9(outputFile, JSON.stringify(socketReport, null, 2));
225689
225773
  logger.info(kleur_default.green(`Socket report written to: ${outputFile}`));
225690
225774
  }
225691
- async getLogContent() {
225692
- await logger.finish();
225693
- let logContent;
225694
- try {
225695
- logContent = await readFile23(this.coanaLogPath, "utf-8");
225696
- } catch (e) {
225697
- this.spinner.suspend(() => {
225698
- console.error("Error reading log file", e);
225699
- });
225700
- }
225701
- return logContent;
225702
- }
225703
225775
  async shareErrorLogWithBackend(e, shouldLogSharing) {
225704
- await this.dashboardAPI.sendErrorReport(this.apiKey, e.stack ?? e.message ?? "Unknown stack trace", shouldLogSharing, this.reportId, this.options.repoUrl, this.options.projectName, await this.getLogContent());
225776
+ await this.dashboardAPI.sendErrorReport(this.apiKey, e.stack ?? e.message ?? "Unknown stack trace", shouldLogSharing, this.reportId, this.options.repoUrl, this.options.projectName, await logger.getLogContent(this.coanaLogPath));
225705
225777
  }
225706
225778
  async shareLogWithDashboard() {
225707
225779
  if (this.reportId)
225708
- await sendLogToDashboard(await this.getLogContent(), this.reportId, this.apiKey);
225780
+ await sendLogToDashboard(await logger.getLogContent(this.coanaLogPath), this.reportId, this.apiKey);
225709
225781
  }
225710
225782
  async outputAndShareReport(report, subPjToWsPathToDirectDependencies) {
225711
225783
  const outputDir = this.options.outputDir;
@@ -226194,43 +226266,73 @@ async function getGitDataToMetadataIfAvailable(rootWorkingDirectory) {
226194
226266
  }
226195
226267
 
226196
226268
  // dist/cli-upgrade-purl.js
226197
- import { join as join25, relative as relative12 } from "node:path";
226269
+ import { join as join26, relative as relative12 } from "node:path";
226198
226270
  var import_packageurl_js2 = __toESM(require_packageurl_js(), 1);
226199
- async function upgradePurl(path2, upgrades, options) {
226271
+ var ECOSYSTEMS_WITH_SOCKET_UPGRADES = ["NPM", "MAVEN"];
226272
+ async function upgradePurl(path2, upgrades, options, logFile, cliFixRunId) {
226200
226273
  logger.initWinstonLogger(options.debug);
226201
226274
  logger.silent = options.silent;
226275
+ let cliRunId = cliFixRunId;
226276
+ if (!cliRunId && options.manifestsTarHash) {
226277
+ cliRunId = await getSocketAPI().registerAutofixOrUpgradePurlRun(options.manifestsTarHash, path2, options, "upgrade-purls");
226278
+ }
226279
+ const upgradePurlRunId = cliRunId && await getSocketAPI().registerUpgradePurlRun(cliRunId, upgrades);
226202
226280
  Spinner.instance({ text: "Running Coana Upgrade Purl CLI", isSilent: options.silent }).start();
226203
226281
  try {
226204
226282
  logger.info(`Upgrading purls for ${path2}:
226205
226283
  ${upgrades.map((upgrade) => ` ${upgrade.purl} -> ${upgrade.upgradeVersion}`).join("\n")}`);
226206
226284
  if (options.manifestsTarHash) {
226207
- const purlToUpgradeVersion = new Map(upgrades.map((upgrade) => [upgrade.purl, upgrade.upgradeVersion]));
226208
- const { artifacts } = await fetchArtifactsFromSocket(path2, options.manifestsTarHash);
226209
- const ecosystemToSocketArtifactUpgrades = {};
226210
- artifacts.forEach((artifact, idx) => {
226211
- if (!artifact.name)
226212
- return;
226213
- const purl = new import_packageurl_js2.PackageURL(artifact.type, artifact.namespace, artifact.name, artifact.version, artifact.qualifiers).toString();
226214
- const upgradeVersion = purlToUpgradeVersion.get(purl);
226215
- if (!upgradeVersion)
226216
- return;
226217
- const ecosystem = getAdvisoryEcosystemFromPurlType(artifact.type);
226218
- if (!ecosystem)
226219
- return;
226220
- ecosystemToSocketArtifactUpgrades[ecosystem] ??= [];
226221
- ecosystemToSocketArtifactUpgrades[ecosystem].push({
226222
- idx,
226223
- upgradeVersion
226285
+ const { supportedUpgrades, unsupportedUpgrades } = upgrades.reduce((acc, upgrade) => {
226286
+ const ecosystem = getAdvisoryEcosystemFromPurl(upgrade.purl);
226287
+ const target = ECOSYSTEMS_WITH_SOCKET_UPGRADES.includes(ecosystem) ? "supportedUpgrades" : "unsupportedUpgrades";
226288
+ acc[target].push(upgrade);
226289
+ return acc;
226290
+ }, { supportedUpgrades: [], unsupportedUpgrades: [] });
226291
+ if (unsupportedUpgrades.length > 0) {
226292
+ logger.warn(`The following upgrades are not supported due to missing support for upgrading their ecosystem: ${unsupportedUpgrades.map((upgrade) => ` ${upgrade.purl} -> ${upgrade.upgradeVersion}`).join("\n")}`);
226293
+ }
226294
+ if (supportedUpgrades.length === 0) {
226295
+ return "fixed-none";
226296
+ }
226297
+ try {
226298
+ const purlToUpgradeVersion = new Map(supportedUpgrades.map((upgrade) => [upgrade.purl, upgrade.upgradeVersion]));
226299
+ const { artifacts } = await fetchArtifactsFromSocket(path2, options.manifestsTarHash);
226300
+ const ecosystemToSocketArtifactUpgrades = {};
226301
+ artifacts.forEach((artifact, idx) => {
226302
+ if (!artifact.name)
226303
+ return;
226304
+ const purl = new import_packageurl_js2.PackageURL(artifact.type, artifact.namespace, artifact.name, artifact.version, artifact.qualifiers).toString();
226305
+ const upgradeVersion = purlToUpgradeVersion.get(purl);
226306
+ if (!upgradeVersion)
226307
+ return;
226308
+ const ecosystem = getAdvisoryEcosystemFromPurlType(artifact.type);
226309
+ if (!ecosystem)
226310
+ return;
226311
+ ecosystemToSocketArtifactUpgrades[ecosystem] ??= [];
226312
+ ecosystemToSocketArtifactUpgrades[ecosystem].push({
226313
+ idx,
226314
+ upgradeVersion
226315
+ });
226224
226316
  });
226225
- });
226226
- for (const [ecosystem, upgrades2] of Object.entries(ecosystemToSocketArtifactUpgrades)) {
226227
- if (["NPM", "MAVEN"].includes(ecosystem)) {
226317
+ for (const [ecosystem, upgrades2] of Object.entries(ecosystemToSocketArtifactUpgrades)) {
226228
226318
  await applySocketUpgrades(ecosystem, path2, upgrades2, artifacts);
226229
- } else {
226230
- logger.warn(`Unsupported ecosystem ${ecosystem} for socket upgrades`);
226231
226319
  }
226320
+ if (upgradePurlRunId) {
226321
+ await getSocketAPI().finalizeUpgradePurlRun(upgradePurlRunId, "success");
226322
+ }
226323
+ return unsupportedUpgrades.length === 0 ? "fixed-all" : "fixed-some";
226324
+ } catch (error) {
226325
+ if (upgradePurlRunId) {
226326
+ await getSocketAPI().finalizeUpgradePurlRun(
226327
+ upgradePurlRunId,
226328
+ "error",
226329
+ !cliFixRunId ? error.stack : void 0,
226330
+ // do not send stack trace and logContent for computeFixes runs, as that will be handled by that command.
226331
+ !cliFixRunId && logFile ? await logger.getLogContent(logFile) : void 0
226332
+ );
226333
+ }
226334
+ throw error;
226232
226335
  }
226233
- return;
226234
226336
  }
226235
226337
  const otherModulesCommunicator = new OtherModulesCommunicator(path2, options, {
226236
226338
  type: "missing"
@@ -226245,7 +226347,7 @@ ${upgrades.map((upgrade) => ` ${upgrade.purl} -> ${upgrade.upgradeVersion}`).joi
226245
226347
  const subprojectPromiseQueue = new PromiseQueue(Number(options.concurrency));
226246
226348
  supportedSubprojects.forEach((subproject) => {
226247
226349
  subprojectPromiseQueue.enqueueTask(async () => {
226248
- const workspacePathsMatchingGlob = subproject.workspacePaths.filter((wsPath) => minimatch(join25(subproject.subprojectPath, wsPath), options.globPattern ?? "**"));
226350
+ const workspacePathsMatchingGlob = subproject.workspacePaths.filter((wsPath) => minimatch(join26(subproject.subprojectPath, wsPath), options.globPattern ?? "**"));
226249
226351
  if (workspacePathsMatchingGlob.length === 0)
226250
226352
  return;
226251
226353
  logger.info(`Found workspaces for subproject ${subproject.subprojectPath}${options.globPattern ? `matching glob ${options.globPattern}` : ""}:
@@ -226274,7 +226376,7 @@ ${workspacePathsMatchingGlob.map((wsPath) => ` ${wsPath}`).join("\n")}`);
226274
226376
  });
226275
226377
  if (vulnerabilityFixes.length === 0)
226276
226378
  return;
226277
- logger.info(`Found ${vulnerabilityFixes.length} ${vulnerabilityFixes.length === 1 ? "dependency" : "dependencies"} matching upgrade specs for ${join25(subproject.subprojectPath, wsPath)}`);
226379
+ logger.info(`Found ${vulnerabilityFixes.length} ${vulnerabilityFixes.length === 1 ? "dependency" : "dependencies"} matching upgrade specs for ${join26(subproject.subprojectPath, wsPath)}`);
226278
226380
  workspaceToFixes[wsPath] = [
226279
226381
  {
226280
226382
  fixId: "dummy",
@@ -226295,13 +226397,14 @@ ${workspacePathsMatchingGlob.map((wsPath) => ` ${wsPath}`).join("\n")}`);
226295
226397
  }
226296
226398
  }
226297
226399
  var signalFixApplied = (_fixId, subprojectPath, workspacePath, vulnerabilityFixes) => {
226298
- logger.info(`Successfully upgraded purls for: ${join25(subprojectPath, workspacePath)}`);
226400
+ logger.info(`Successfully upgraded purls for: ${join26(subprojectPath, workspacePath)}`);
226299
226401
  logger.info(`Upgraded:
226300
226402
  ${vulnerabilityFixes.map((fix) => ` ${fix.dependencyName} from ${fix.currentVersion} to ${fix.fixedVersion}`).join("\n")}`);
226301
226403
  };
226302
226404
 
226303
226405
  // dist/cli-compute-fixes-and-upgrade-purls.js
226304
- async function computeFixesAndUpgradePurls(path2, options) {
226406
+ async function computeFixesAndUpgradePurls(path2, options, logFile) {
226407
+ const autofixRunId = options.manifestsTarHash && await getSocketAPI().registerAutofixOrUpgradePurlRun(options.manifestsTarHash, path2, options, "autofix");
226305
226408
  const { artifacts, ghsaToVulnerableArtifactIds } = await computeInputForComputingFixes(path2, options);
226306
226409
  if (Object.keys(ghsaToVulnerableArtifactIds).length === 0) {
226307
226410
  logger.info("No vulnerabilities to compute fixes for");
@@ -226313,7 +226416,7 @@ async function computeFixesAndUpgradePurls(path2, options) {
226313
226416
  return;
226314
226417
  }
226315
226418
  const ghsaToVulnerableArtifactIdsToApply = options.applyFixesTo.includes("all") ? ghsaToVulnerableArtifactIds : Object.fromEntries(Object.entries(ghsaToVulnerableArtifactIds).filter(([ghsa]) => options.applyFixesTo.includes(ghsa)));
226316
- const computedFix = await useSocketComputeFixEndpoint(artifacts, ghsaToVulnerableArtifactIdsToApply);
226419
+ const computedFix = await useSocketComputeFixEndpoint(autofixRunId, artifacts, ghsaToVulnerableArtifactIdsToApply);
226317
226420
  if (computedFix.type !== "success") {
226318
226421
  throw new Error(`No fix found for the given vulnerabilities`);
226319
226422
  }
@@ -226339,15 +226442,21 @@ async function computeFixesAndUpgradePurls(path2, options) {
226339
226442
  return;
226340
226443
  }
226341
226444
  try {
226342
- await upgradePurl(path2, combinedFixes.map((fix) => ({ purl: fix.purl, upgradeVersion: fix.fixedVersion })), {
226445
+ const applyFixesStatus = await upgradePurl(path2, combinedFixes.map((fix) => ({ purl: fix.purl, upgradeVersion: fix.fixedVersion })), {
226343
226446
  debug: options.debug,
226344
226447
  silent: options.silent,
226345
226448
  runWithoutDocker: options.runWithoutDocker,
226346
226449
  manifestsTarHash: options.manifestsTarHash,
226347
226450
  concurrency: "1",
226348
226451
  globPattern: options.globPattern
226349
- });
226452
+ }, autofixRunId) ?? "fixed-all";
226453
+ if (autofixRunId) {
226454
+ await getSocketAPI().finalizeAutofixRun(autofixRunId, ghsasFailedToFix.length === 0 && applyFixesStatus === "fixed-all" ? "fixed-all" : ghsasFailedToFix.length === Object.keys(ghsaToVulnerableArtifactIdsToApply).length || applyFixesStatus === "fixed-none" ? "fixed-none" : "fixed-some");
226455
+ }
226350
226456
  } catch (error) {
226457
+ if (autofixRunId) {
226458
+ await getSocketAPI().finalizeAutofixRun(autofixRunId, "error", error.stack, await logger.getLogContent(logFile));
226459
+ }
226351
226460
  logger.error("Error applying fixes:", error);
226352
226461
  throw error;
226353
226462
  }
@@ -226445,6 +226554,7 @@ function computeSBOMTaskArtifacts(dependencyTrees) {
226445
226554
  }
226446
226555
 
226447
226556
  // dist/index.js
226557
+ import { join as join27 } from "path";
226448
226558
  var program2 = new Command();
226449
226559
  var run2 = new Command();
226450
226560
  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 <relativeDirs...>", "globs for directories to include from the detection of subprojects (space-separated)(use relative paths from the project root). Notice, projects that are not included may still be scanned if they are referenced from included projects.").option("--exclude-dirs <relativeDirs...>", "globs for directories to exclude from the detection of subprojects (space-separated)(use relative paths from the project root). 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 (space-separated). Currently NPM, PIP, MAVEN, NUGET and GO are supported. Default is all supported ecosystems.").addOption(new Option("--purl-types <purlTypes...>", "List of PURL types to analyze (space-separated). Currently npm, pypi, maven, nuget, golang and cargo are supported. Default is all supported purl types.").hideHelp()).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("--disable-analytics-sharing", "Disable analytics sharing.", 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.")).option("--ignore-failing-workspaces", "Continue processing when a workspace fails instead of exiting. Failed workspaces will be logged at termination.", false).addOption(new Option("--socket-mode <output-file>", "Run Coana in socket mode and write report to <output-file>").hideHelp()).addOption(new Option("--manifests-tar-hash <hash>", "Hash of the tarball containing all manifest files already uploaded to Socket. If provided, Socket will be used for computing dependency trees.").hideHelp()).version(version2).configureHelp({ sortOptions: true }).action(async (path2, options) => {
@@ -226461,26 +226571,34 @@ applyFixes.name("apply-fixes").argument("<path>", "File system path to the folde
226461
226571
  var upgradePurls = new Command();
226462
226572
  upgradePurls.name("upgrade-purls").argument("<path>", "File system path to the folder containing the project").argument("<specs...>", "Package upgrade specifications in the format 'purl -> newVersion' (e.g., 'pkg:maven/io.micrometer/micrometer-core@1.10.9 -> 1.15.0')").option("-g, --glob <pattern>", "Glob pattern to filter workspaces by absolute file path").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("-d, --debug", "Enable debug logging", false).option("-s, --silent", "Silence all debug/warning output", false).addOption(new Option("--run-without-docker", "Run package managers without using docker").default(process.env.RUN_WITHOUT_DOCKER === "true").hideHelp()).addOption(new Option("--socket-mode", "Use Socket for computing dependency trees").default(process.env.SOCKET_MODE === "true").hideHelp()).version(version2).action(async (path2, specs2, options) => {
226463
226573
  process.env.DOCKER_IMAGE_TAG ??= version2;
226464
- const upgradeSpecs = specs2.map((spec) => {
226465
- const [purl, upgradeVersion] = spec.split("->").map((s4) => s4.trim());
226466
- if (!upgradeVersion)
226467
- throw Error("Upgrade version not specified");
226468
- return {
226469
- purl,
226470
- upgradeVersion
226471
- };
226574
+ await withTmpDirectory("upgrade-purls", async (tmpDir) => {
226575
+ const logFile = join27(tmpDir, "upgrade-purls.log");
226576
+ logger.initWinstonLogger(options.debug, logFile);
226577
+ const upgradeSpecs = specs2.map((spec) => {
226578
+ const [purl, upgradeVersion] = spec.split("->").map((s4) => s4.trim());
226579
+ if (!upgradeVersion)
226580
+ throw Error("Upgrade version not specified");
226581
+ return {
226582
+ purl,
226583
+ upgradeVersion
226584
+ };
226585
+ });
226586
+ await upgradePurl(path2, upgradeSpecs, options, logFile);
226472
226587
  });
226473
- await upgradePurl(path2, upgradeSpecs, options);
226474
226588
  }).configureHelp({ sortOptions: true });
226475
226589
  var computeFixesAndUpgradePurlsCmd = new Command();
226476
226590
  computeFixesAndUpgradePurlsCmd.name("compute-fixes-and-upgrade-purls").argument("<path>", "File system path to the folder containing the project").option("-a, --apply-fixes-to <ghsas...>", 'GHSA IDs to compute fixes for. Use "all" to compute fixes for all vulnerabilities.', []).option("--dry-run", "Show what changes would be made without actually making them", false).option("-g, --glob <pattern>", "Glob pattern to filter workspaces by absolute file path").option("-d, --debug", "Enable debug logging", false).option("-s, --silent", "Silence all debug/warning output", false).addOption(new Option("--run-without-docker", "Run package managers without using docker").default(process.env.RUN_WITHOUT_DOCKER === "true").hideHelp()).addOption(new Option("--manifests-tar-hash <hash>", "Hash of the tarball containing all manifest files already uploaded to Socket. If provided, Socket will be used for computing dependency trees.").hideHelp()).version(version2).action(async (path2, options) => {
226477
226591
  process.env.DOCKER_IMAGE_TAG ??= version2;
226478
- await computeFixesAndUpgradePurls(path2, options);
226592
+ await withTmpDirectory("compute-fixes-and-upgrade-purls", async (tmpDir) => {
226593
+ const logFile = join27(tmpDir, "compute-fixes-and-upgrade-purls.log");
226594
+ logger.initWinstonLogger(options.debug, logFile);
226595
+ await computeFixesAndUpgradePurls(path2, options, logFile);
226596
+ });
226479
226597
  }).configureHelp({ sortOptions: true });
226480
226598
  var compareReportsCommand = new Command();
226481
226599
  compareReportsCommand.name("compare-reports").argument("<baselineReportPath>", "Path to the baseline report").argument("<newReportPath>", "Path to the new report").option("--api-key <key>", "Set the Coana dashboard API key.").option("-d, --debug", "Enable debug logging", false).option("--no-pr-comment", "Disable pull request comments (only relevant when run from a PR)", true).option("--no-block", "Do not fail with a non-zero exit code when new reachable vulnerabilities are detected", true).option("--ignore-undeterminable-reachability", "Ignore vulnerabilities with undeterminable reachability", false).action(async (baselineReportPath, newReportPath, options) => {
226482
226600
  async function readReport(reportPath) {
226483
- return JSON.parse(await readFile24(reportPath, "utf-8"));
226601
+ return JSON.parse(await readFile25(reportPath, "utf-8"));
226484
226602
  }
226485
226603
  const baselineReport = await readReport(baselineReportPath);
226486
226604
  const newReport = await readReport(newReportPath);