@socketsecurity/cli-with-sentry 1.0.101 → 1.0.102

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.
@@ -190952,25 +190952,25 @@ var Spinner = class _Spinner {
190952
190952
  };
190953
190953
 
190954
190954
  // ../utils/src/command-utils.ts
190955
- async function execAndLogOnFailure(cmd, dir, options) {
190955
+ async function execAndLogOnFailure(cmd, dir, options, logLevel = "info") {
190956
190956
  const result = await execNeverFail(cmd, dir, options);
190957
- if (result.error) logCommandOutput(result, cmd, dir);
190957
+ if (result.error) logCommandOutput(result, cmd, dir, logLevel);
190958
190958
  return !result.error;
190959
190959
  }
190960
190960
  async function execPipeAndLogOnFailure(cmd, dir, options) {
190961
190961
  return execAndLogOnFailure(cmd, dir, { ...options, pipe: true });
190962
190962
  }
190963
- function logCommandOutput(cmdResult, cmd, dir) {
190963
+ function logCommandOutput(cmdResult, cmd, dir, logLevel = "info") {
190964
190964
  const { error, stdout, stderr } = cmdResult;
190965
- logger.info(error ? `Error running command: ${cmd}` : `Result of running command: ${cmd}`);
190966
- logger.info(`Directory: ${dir}`);
190965
+ logger[logLevel](error ? `Error running command: ${cmd}` : `Result of running command: ${cmd}`);
190966
+ logger[logLevel](`Directory: ${dir}`);
190967
190967
  if (error) {
190968
190968
  const em = error.message;
190969
- logger.info(`Error: ${em?.endsWith?.(`
190969
+ logger[logLevel](`Error: ${em?.endsWith?.(`
190970
190970
  ${stderr}`) ? em.slice(0, -stderr.length - 1) : em}`);
190971
190971
  }
190972
- logger.info(`stdout: ${stdout}`);
190973
- logger.info(`stderr: ${stderr}`);
190972
+ logger[logLevel](`stdout: ${stdout}`);
190973
+ logger[logLevel](`stderr: ${stderr}`);
190974
190974
  }
190975
190975
  async function execNeverFail(cmd, dir, options) {
190976
190976
  return new Promise((resolve24) => {
@@ -197761,6 +197761,14 @@ function parseSocketResponse(responseData) {
197761
197761
  throw new Error(`Unexpected response type from Socket API: ${typeof responseData}`);
197762
197762
  }
197763
197763
  }
197764
+ function parseComputeArtifactsResponse(responseData) {
197765
+ const response = parseSocketResponse(responseData);
197766
+ return {
197767
+ artifacts: response.filter((r2) => r2.type === "artifact").map((r2) => r2.value),
197768
+ metadata: response.filter((r2) => r2.type === "metadata").flatMap((r2) => r2.value)
197769
+ // There should always only be one metadata object
197770
+ };
197771
+ }
197764
197772
  async function createSocketTier1Scan(cliOptions, coanaCliVersion) {
197765
197773
  try {
197766
197774
  const url2 = getSocketApiUrl("tier1-reachability-scan");
@@ -197948,7 +197956,7 @@ async function fetchArtifactsFromManifestsTarHash(manifestsTarHash) {
197948
197956
  try {
197949
197957
  const url2 = getSocketApiUrl(`orgs/${process.env.SOCKET_ORG_SLUG}/compute-artifacts?tarHash=${manifestsTarHash}`);
197950
197958
  const responseData = (await axios2.post(url2, {}, { headers: getAuthHeaders() })).data;
197951
- return parseSocketResponse(responseData);
197959
+ return parseComputeArtifactsResponse(responseData);
197952
197960
  } catch (e) {
197953
197961
  if (e instanceof AxiosError2) {
197954
197962
  prettyPrintAxiosError(e);
@@ -197975,12 +197983,7 @@ async function computeSocketFactArtifacts(rootDir, relativeManifestFilePaths) {
197975
197983
  if (!uploadData.tarHash) {
197976
197984
  throw new Error("No tarHash received from upload-manifest-files response");
197977
197985
  }
197978
- const computeUrl = getSocketApiUrl(
197979
- `orgs/${process.env.SOCKET_ORG_SLUG}/compute-artifacts?tarHash=${uploadData.tarHash}`
197980
- );
197981
- const computeResponse = await axios2.post(computeUrl, {}, { headers: getAuthHeaders() });
197982
- const responseData = computeResponse.data;
197983
- return parseSocketResponse(responseData);
197986
+ return (await fetchArtifactsFromManifestsTarHash(uploadData.tarHash)).artifacts;
197984
197987
  } catch (error) {
197985
197988
  logger.warn("Failed to compute socket fact artifacts", error);
197986
197989
  return void 0;
@@ -205296,23 +205299,23 @@ var Spinner2 = class _Spinner {
205296
205299
  };
205297
205300
 
205298
205301
  // ../utils/dist/command-utils.js
205299
- async function execAndLogOnFailure2(cmd, dir, options) {
205302
+ async function execAndLogOnFailure2(cmd, dir, options, logLevel = "info") {
205300
205303
  const result = await execNeverFail2(cmd, dir, options);
205301
205304
  if (result.error)
205302
- logCommandOutput2(result, cmd, dir);
205305
+ logCommandOutput2(result, cmd, dir, logLevel);
205303
205306
  return !result.error;
205304
205307
  }
205305
- function logCommandOutput2(cmdResult, cmd, dir) {
205308
+ function logCommandOutput2(cmdResult, cmd, dir, logLevel = "info") {
205306
205309
  const { error, stdout, stderr } = cmdResult;
205307
- logger.info(error ? `Error running command: ${cmd}` : `Result of running command: ${cmd}`);
205308
- logger.info(`Directory: ${dir}`);
205310
+ logger[logLevel](error ? `Error running command: ${cmd}` : `Result of running command: ${cmd}`);
205311
+ logger[logLevel](`Directory: ${dir}`);
205309
205312
  if (error) {
205310
205313
  const em = error.message;
205311
- logger.info(`Error: ${em?.endsWith?.(`
205314
+ logger[logLevel](`Error: ${em?.endsWith?.(`
205312
205315
  ${stderr}`) ? em.slice(0, -stderr.length - 1) : em}`);
205313
205316
  }
205314
- logger.info(`stdout: ${stdout}`);
205315
- logger.info(`stderr: ${stderr}`);
205317
+ logger[logLevel](`stdout: ${stdout}`);
205318
+ logger[logLevel](`stderr: ${stderr}`);
205316
205319
  }
205317
205320
  async function execNeverFail2(cmd, dir, options) {
205318
205321
  return new Promise((resolve24) => {
@@ -206483,18 +206486,19 @@ import { access as access2, cp, readdir as readdir3, stat as stat2 } from "fs/pr
206483
206486
  import { basename as basename4, join as join11, relative as relative6, resolve as resolve13 } from "path";
206484
206487
  var { uniq } = import_lodash5.default;
206485
206488
  var { isMatch } = import_micromatch.default;
206486
- function findParent(dir, predicate, wholePath) {
206487
- let curr = dir;
206488
- let last2 = dir;
206489
+ function* parents(dir) {
206490
+ let [curr, last2] = [dir, dir];
206489
206491
  do {
206490
- const name = wholePath ? curr : basename4(curr);
206491
- if (predicate(name))
206492
- return curr;
206493
- last2 = curr;
206494
- curr = resolve13(curr, "..");
206492
+ yield curr;
206493
+ [last2, curr] = [curr, resolve13(curr, "..")];
206495
206494
  } while (curr !== last2);
206496
206495
  return void 0;
206497
206496
  }
206497
+ function findParent(dir, predicate, wholePath) {
206498
+ for (const parent2 of parents(dir))
206499
+ if (predicate(wholePath ? parent2 : basename4(parent2)))
206500
+ return parent2;
206501
+ }
206498
206502
 
206499
206503
  // ../utils/dist/constants.js
206500
206504
  var { once: once2 } = import_lodash6.default;
@@ -207378,17 +207382,18 @@ import { access as access3, cp as cp2, readdir as readdir4, stat as stat3 } from
207378
207382
  import { basename as basename5, join as join16, relative as relative7, resolve as resolve15 } from "path";
207379
207383
  var { uniq: uniq2 } = import_lodash8.default;
207380
207384
  var { isMatch: isMatch2 } = import_micromatch2.default;
207381
- function findParent2(dir, predicate, wholePath) {
207382
- let curr = dir;
207383
- let last2 = dir;
207385
+ function* parents2(dir) {
207386
+ let [curr, last2] = [dir, dir];
207384
207387
  do {
207385
- const name = wholePath ? curr : basename5(curr);
207386
- if (predicate(name)) return curr;
207387
- last2 = curr;
207388
- curr = resolve15(curr, "..");
207388
+ yield curr;
207389
+ [last2, curr] = [curr, resolve15(curr, "..")];
207389
207390
  } while (curr !== last2);
207390
207391
  return void 0;
207391
207392
  }
207393
+ function findParent2(dir, predicate, wholePath) {
207394
+ for (const parent2 of parents2(dir))
207395
+ if (predicate(wholePath ? parent2 : basename5(parent2))) return parent2;
207396
+ }
207392
207397
  async function getFilesRelative(dir, excludeDirs) {
207393
207398
  async function helper(subDir, arrayOfFiles) {
207394
207399
  for (const item of await readdir4(join16(dir, subDir), { withFileTypes: true })) {
@@ -209354,6 +209359,7 @@ import { join as join20, resolve as resolve18 } from "path";
209354
209359
  import util3 from "util";
209355
209360
  var { once: once7 } = import_lodash13.default;
209356
209361
  var systemPython = once7(() => execFileSync2("which", ["python"], { encoding: "utf8" }).trim());
209362
+ var hasPyenv = once7(async () => !(await execNeverFail("which pyenv")).error);
209357
209363
 
209358
209364
  // ../utils/src/pip-utils.ts
209359
209365
  async function isSetupPySetuptools(file) {
@@ -210102,8 +210108,8 @@ function getVulnerabilityDependencyType(vulnChainDetails, directDependencies, af
210102
210108
  finalDepType = depType;
210103
210109
  }
210104
210110
  }
210105
- const parents2 = vcd.parentsMap.get(devIdentifier);
210106
- for (const p3 of parents2 ?? []) {
210111
+ const parents4 = vcd.parentsMap.get(devIdentifier);
210112
+ for (const p3 of parents4 ?? []) {
210107
210113
  if (p3 === ROOT_NODE_STR) continue;
210108
210114
  const parentNode = vcd.transitiveDependencies[p3];
210109
210115
  if (afd && !afd.has(parentNode)) continue;
@@ -210225,17 +210231,17 @@ function computeVulnChainDetails(dependencyTree, dependencyIdentifier, parentsMa
210225
210231
  function addNode(currentIdentifier, childIdentifier, visited) {
210226
210232
  if (visited.has(currentIdentifier))
210227
210233
  return;
210228
- const parents2 = parentsMap.get(currentIdentifier);
210234
+ const parents4 = parentsMap.get(currentIdentifier);
210229
210235
  const newCurrentNode = transformToVulnChainNode(dependencyTree.transitiveDependencies[currentIdentifier]);
210230
210236
  res.transitiveDependencies[currentIdentifier] = newCurrentNode;
210231
210237
  if (childIdentifier && !newCurrentNode.children.includes(childIdentifier))
210232
210238
  newCurrentNode.children.push(childIdentifier);
210233
210239
  if (!childIdentifier)
210234
210240
  newCurrentNode.vulnerable = true;
210235
- if (!parents2)
210241
+ if (!parents4)
210236
210242
  return res;
210237
210243
  visited.add(currentIdentifier);
210238
- for (const parent2 of parents2) {
210244
+ for (const parent2 of parents4) {
210239
210245
  if (parent2 === ROOT_IDENTIFIER)
210240
210246
  res.children.push(currentIdentifier);
210241
210247
  else
@@ -210339,7 +210345,7 @@ function getAllToplevelAncestors(artifactMap, artifactId) {
210339
210345
  async function fetchArtifactsFromSocket(rootWorkingDirectory, manifestsTarHash) {
210340
210346
  logger.info("Fetching artifacts from Socket backend using manifests tar hash", manifestsTarHash);
210341
210347
  try {
210342
- const artifacts = await fetchArtifactsFromManifestsTarHash(manifestsTarHash);
210348
+ const { artifacts } = await fetchArtifactsFromManifestsTarHash(manifestsTarHash);
210343
210349
  const properPythonProjects = [];
210344
210350
  const venvExcludes = [
210345
210351
  "venv",
@@ -210493,7 +210499,7 @@ function computeVulnChainDetails2(artifacts, vulnerableArtifactId) {
210493
210499
  const currentArtifact = artifactMap.get(currentId);
210494
210500
  if (!currentArtifact)
210495
210501
  return;
210496
- const parents2 = parentsMap.get(currentId);
210502
+ const parents4 = parentsMap.get(currentId);
210497
210503
  const newCurrentNode = {
210498
210504
  packageName: getNameFromNamespaceAndName(currentArtifact.type, currentArtifact.namespace, currentArtifact.name),
210499
210505
  version: currentArtifact.version ?? void 0,
@@ -210512,8 +210518,8 @@ function computeVulnChainDetails2(artifacts, vulnerableArtifactId) {
210512
210518
  }
210513
210519
  }
210514
210520
  visited.add(currentId);
210515
- if (parents2) {
210516
- for (const parentId of parents2) {
210521
+ if (parents4) {
210522
+ for (const parentId of parents4) {
210517
210523
  addNode(parentId, currentId, visited);
210518
210524
  }
210519
210525
  }
@@ -213022,7 +213028,7 @@ __export(traversing_exports, {
213022
213028
  nextUntil: () => nextUntil,
213023
213029
  not: () => not,
213024
213030
  parent: () => parent,
213025
- parents: () => parents,
213031
+ parents: () => parents3,
213026
213032
  parentsUntil: () => parentsUntil,
213027
213033
  prev: () => prev,
213028
213034
  prevAll: () => prevAll,
@@ -214284,7 +214290,7 @@ function _removeDuplicates(elems) {
214284
214290
  return Array.from(new Set(elems));
214285
214291
  }
214286
214292
  var parent = _singleMatcher(({ parent: parent2 }) => parent2 && !isDocument(parent2) ? parent2 : null, _removeDuplicates);
214287
- var parents = _matcher((elem) => {
214293
+ var parents3 = _matcher((elem) => {
214288
214294
  const matched = [];
214289
214295
  while (elem.parent && !isDocument(elem.parent)) {
214290
214296
  matched.push(elem.parent);
@@ -225028,10 +225034,10 @@ var FixesTask = class {
225028
225034
  return;
225029
225035
  }
225030
225036
  }
225031
- const parents2 = this.getParents(pId, vulnChainDetails);
225037
+ const parents4 = this.getParents(pId, vulnChainDetails);
225032
225038
  let allowedVersionsForCId = potentialVersionsForFix[cId] ? [...potentialVersionsForFix[cId]] : await this.getSafeVersionsOfPackage(vulnChainDetails.transitiveDependencies[cId].packageName);
225033
- if (parents2.length !== 0) {
225034
- for (const parent2 of parents2) {
225039
+ if (parents4.length !== 0) {
225040
+ for (const parent2 of parents4) {
225035
225041
  await computeFix(parent2, pId, [key, ...visited]);
225036
225042
  if (res[pId])
225037
225043
  allowedVersionsForCId = await this.filterVersionsAllowedByParent(pId, res[pId], cId, allowedVersionsForCId);
@@ -225060,11 +225066,11 @@ var FixesTask = class {
225060
225066
  const deps = vulnChainDetails.transitiveDependencies;
225061
225067
  const vulnerablePackageIdentifiers = Object.entries(deps ?? []).filter(([_identifier, node]) => node.vulnerable).map(([identifier, _node]) => identifier);
225062
225068
  for (const pId of vulnerablePackageIdentifiers) {
225063
- const parents2 = this.getParents(pId, vulnChainDetails);
225064
- if (parents2.length === 0) {
225069
+ const parents4 = this.getParents(pId, vulnChainDetails);
225070
+ if (parents4.length === 0) {
225065
225071
  pickVersionWrapper(pId, [...potentialVersionsForFix[pId]]);
225066
225072
  } else {
225067
- for (const parent2 of parents2) {
225073
+ for (const parent2 of parents4) {
225068
225074
  await computeFix(parent2, pId, []);
225069
225075
  }
225070
225076
  }
@@ -225125,9 +225131,9 @@ var FixesTask = class {
225125
225131
  safeVersionsForC
225126
225132
  );
225127
225133
  const vs = await filterVersions(pId, versionsOfPAllowingSomeSafeVersions);
225128
- const parents2 = this.getParents(pId, vuln.vulnChainDetails);
225129
- if (parents2.length !== 0) {
225130
- for (const parent2 of parents2) {
225134
+ const parents4 = this.getParents(pId, vuln.vulnChainDetails);
225135
+ if (parents4.length !== 0) {
225136
+ for (const parent2 of parents4) {
225131
225137
  await computePotentialVersionsForFixWithCache(parent2, pId, vs);
225132
225138
  }
225133
225139
  } else {
@@ -225139,17 +225145,17 @@ var FixesTask = class {
225139
225145
  const deps = vuln.vulnChainDetails?.transitiveDependencies;
225140
225146
  const vulnerablePackageIdentifiers = Object.entries(deps ?? []).filter(([_identifier, node]) => node.vulnerable).map(([identifier, _node]) => identifier);
225141
225147
  for (const pId of vulnerablePackageIdentifiers) {
225142
- const parents2 = this.getParents(pId, vuln.vulnChainDetails);
225148
+ const parents4 = this.getParents(pId, vuln.vulnChainDetails);
225143
225149
  const safeVersionsForVulnerablePackage = await safeVersions(pId);
225144
225150
  const { upgrades, downgrades } = this.groupVersionsInUpgradesAndDowngrades(
225145
225151
  assertDefined(this.packageStructure.transitiveDependencies[pId].version),
225146
225152
  safeVersionsForVulnerablePackage
225147
225153
  );
225148
- if (parents2.length === 0) {
225154
+ if (parents4.length === 0) {
225149
225155
  if (upgrades.length > 0) res[pId] = upgrades;
225150
225156
  else if (downgrades.length > 0) res[pId] = downgrades;
225151
225157
  } else {
225152
- for (const parent2 of parents2) {
225158
+ for (const parent2 of parents4) {
225153
225159
  const resClone = { ...res };
225154
225160
  const alreadyComputedCacheClone = new Map(alreadyComputedCache);
225155
225161
  try {
@@ -225583,7 +225589,7 @@ async function onlineScan(dependencyTree, apiKey, timeout) {
225583
225589
  }
225584
225590
 
225585
225591
  // dist/version.js
225586
- var version2 = "14.12.3";
225592
+ var version2 = "14.12.5";
225587
225593
 
225588
225594
  // dist/cli-core.js
225589
225595
  var { mapValues, omit, partition, pick } = import_lodash15.default;