@socketsecurity/cli-with-sentry 0.15.58 → 0.15.60

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.
@@ -212320,7 +212320,7 @@ async function onlineScan(dependencyTree, apiKey, timeout) {
212320
212320
  }
212321
212321
 
212322
212322
  // dist/version.js
212323
- var version2 = "14.9.22";
212323
+ var version2 = "14.9.24";
212324
212324
 
212325
212325
  // ../../node_modules/.pnpm/axios@1.9.0/node_modules/axios/lib/helpers/bind.js
212326
212326
  function bind2(fn2, thisArg) {
@@ -215646,14 +215646,20 @@ async function scanForVulnerabilitiesSocketMode(dependencyTree) {
215646
215646
  const data2 = {
215647
215647
  components: Object.keys(purlStringsToIdentifier).map((purl) => ({ purl }))
215648
215648
  };
215649
- const componentsString = (await axios_default2.post(url3, data2, {
215649
+ const componentsResponse = (await axios_default2.post(url3, data2, {
215650
215650
  headers: {
215651
215651
  "Content-Type": "application/json",
215652
215652
  Accept: "application/json",
215653
215653
  Authorization: `Basic ${btoa(`${process.env.SOCKET_CLI_API_TOKEN}:`)}`
215654
215654
  }
215655
215655
  })).data;
215656
- components = JSON.parse(`[${componentsString.trim().replace(/\n/g, ",")}]`);
215656
+ if (typeof componentsResponse === "object") {
215657
+ components = [componentsResponse];
215658
+ } else if (typeof componentsResponse === "string") {
215659
+ components = JSON.parse(`[${componentsResponse.trim().replace(/\n/g, ",")}]`);
215660
+ } else {
215661
+ throw new Error(`Unexpected response type from Socket API: ${typeof componentsResponse}`);
215662
+ }
215657
215663
  } catch (e) {
215658
215664
  logger.error("Failed to scan for vulnerabilities in socket mode");
215659
215665
  logger.error("error", e);
@@ -215812,11 +215818,11 @@ function getNamespaceAndName(ecosystem, packageName) {
215812
215818
  }
215813
215819
 
215814
215820
  // dist/internal/socket-report.js
215815
- function toSocketFacts(report, dependencyTrees) {
215821
+ function toSocketFacts(report, dependencyTrees, subPjToWsPathToDirectDependencies) {
215816
215822
  const components = [];
215817
215823
  const purlToIndex = /* @__PURE__ */ new Map();
215818
215824
  for (const dependencyTree of dependencyTrees) {
215819
- const depIdentifierToPurl = Object.fromEntries(Object.entries(dependencyTree.dependencyTree.transitiveDependencies).map(([depIdentifier, dep]) => {
215825
+ const depIdentifierToPurl = Object.fromEntries(Object.entries(dependencyTree.dependencyTree.transitiveDependencies).filter(([_depIdentifier, dep]) => dep.purlObj).map(([depIdentifier, dep]) => {
215820
215826
  const purl = dep.purlObj.purlString;
215821
215827
  if (purl && !purlToIndex.has(purl)) {
215822
215828
  purlToIndex.set(purl, components.length);
@@ -215831,8 +215837,10 @@ function toSocketFacts(report, dependencyTrees) {
215831
215837
  artifact_id: depTreeNode.purlObj.artifact_id,
215832
215838
  artifactId: depTreeNode.purlObj.artifactId,
215833
215839
  qualifiers: depTreeNode.purlObj.qualifiers,
215834
- // direct: false, // TODO: add direct flag
215835
- // dev: false, // TODO: add dev flag
215840
+ direct: false,
215841
+ // Use false as default, and set to true if actually direct
215842
+ dev: true,
215843
+ // Use true as default, and set to false if the artifact is found as prod, prod&dev or missing for any dependency chain.
215836
215844
  dependencies: []
215837
215845
  };
215838
215846
  }
@@ -215840,15 +215848,40 @@ function toSocketFacts(report, dependencyTrees) {
215840
215848
  }));
215841
215849
  for (const [depIdentifier, purl] of Object.entries(depIdentifierToPurl)) {
215842
215850
  const depTreeNode = dependencyTree.dependencyTree.transitiveDependencies[depIdentifier];
215851
+ if (!depTreeNode.purlObj) {
215852
+ continue;
215853
+ }
215843
215854
  const component = components[purlToIndex.get(purl)];
215844
215855
  depTreeNode.dependencies?.forEach((dep) => {
215845
215856
  const depPurl = depIdentifierToPurl[dep];
215846
215857
  const depIndex = purlToIndex.get(depPurl);
215847
- if (!component.dependencies?.includes(depIndex.toString())) {
215858
+ if (depIndex && !component.dependencies?.includes(depIndex.toString())) {
215848
215859
  component.dependencies.push(depIndex.toString());
215849
215860
  }
215850
215861
  });
215851
215862
  }
215863
+ for (const depIdentifier of dependencyTree.dependencyTree.dependencies ?? []) {
215864
+ const depTreeNode = dependencyTree.dependencyTree.transitiveDependencies[depIdentifier];
215865
+ const component = components[purlToIndex.get(depTreeNode.purlObj.purlString)];
215866
+ component.direct = true;
215867
+ }
215868
+ for (const depIdentifier of dependencyTree.dependencyTree.dependencies ?? []) {
215869
+ let updateDependencyType2 = function(id) {
215870
+ if (visitedIds.has(id.toString()))
215871
+ return;
215872
+ visitedIds.add(id.toString());
215873
+ const component = components[id];
215874
+ if (dependencyType !== "dev") {
215875
+ component.dev = false;
215876
+ }
215877
+ component.dependencies?.forEach((depId) => updateDependencyType2(parseInt(depId)));
215878
+ };
215879
+ var updateDependencyType = updateDependencyType2;
215880
+ const depTreeNode = dependencyTree.dependencyTree.transitiveDependencies[depIdentifier];
215881
+ const dependencyType = subPjToWsPathToDirectDependencies[dependencyTree.subprojectPath][dependencyTree.workspacePath][depTreeNode.packageName];
215882
+ const visitedIds = /* @__PURE__ */ new Set();
215883
+ updateDependencyType2(purlToIndex.get(depTreeNode.purlObj.purlString));
215884
+ }
215852
215885
  }
215853
215886
  for (const vulnerability of report.vulnerabilities) {
215854
215887
  const component = components[purlToIndex.get(vulnerability.purl)];
@@ -216015,9 +216048,9 @@ var CliCore = class {
216015
216048
  const gitData = await getGitDataToMetadataIfAvailable(this.rootWorkingDirectory);
216016
216049
  this.reportId = await createReport(this.options.repoUrl, this.options.projectName, version2, gitData?.sha, gitData?.branchName, omit(this.options, "apiKey", "print-report", "repoUrl", "projectName", "writeReportToFile"), this.apiKey, this.options.runEnv);
216017
216050
  }
216018
- const report = await this.computeReport();
216051
+ const { report, subPjToWsPathToDirectDependencies } = await this.computeReport();
216019
216052
  logger.info("Report computed successfully");
216020
- await this.outputAndShareReport(report);
216053
+ await this.outputAndShareReport(report, subPjToWsPathToDirectDependencies);
216021
216054
  this.spinner.stop();
216022
216055
  return report;
216023
216056
  } catch (e) {
@@ -216046,13 +216079,13 @@ var CliCore = class {
216046
216079
  if (this.reportId)
216047
216080
  await sendLogToDashboard(await this.getLogContent(), this.reportId, this.apiKey);
216048
216081
  }
216049
- async outputAndShareReport(report) {
216082
+ async outputAndShareReport(report, subPjToWsPathToDirectDependencies) {
216050
216083
  const outputDir = this.options.outputDir;
216051
216084
  if (this.options.socketMode) {
216052
216085
  if (!this.reportDependencyTrees) {
216053
216086
  throw new Error("Dependency trees should be available when using --socket-mode");
216054
216087
  }
216055
- const socketReport = toSocketFacts(report, this.reportDependencyTrees);
216088
+ const socketReport = toSocketFacts(report, this.reportDependencyTrees, subPjToWsPathToDirectDependencies);
216056
216089
  const outputFile = resolve24(this.options.socketMode);
216057
216090
  await writeFile10(outputFile, JSON.stringify(socketReport, null, 2));
216058
216091
  logger.info(kleur_default.green(`Socket report written to: ${outputFile}`));
@@ -216140,7 +216173,16 @@ var CliCore = class {
216140
216173
  vulnerabilities: allVulnerabilities,
216141
216174
  ...await this.createMetadataForReport(startTime)
216142
216175
  };
216143
- return report;
216176
+ const reportAndSubPjToWsPathToDirectDependencies = {
216177
+ report,
216178
+ subPjToWsPathToDirectDependencies: workspacesOutput.reduce((acc, { subprojectPath, workspacePath, directDependencies }) => {
216179
+ if (!acc[subprojectPath])
216180
+ acc[subprojectPath] = {};
216181
+ acc[subprojectPath][workspacePath] = directDependencies;
216182
+ return acc;
216183
+ }, {})
216184
+ };
216185
+ return reportAndSubPjToWsPathToDirectDependencies;
216144
216186
  }
216145
216187
  async updateSpinnerTextOnNewSubproject(subprojectAndWsPath, numberSubprojects, index2) {
216146
216188
  this.spinner.start();
@@ -216293,8 +216335,6 @@ var CliCore = class {
216293
216335
  ];
216294
216336
  } catch (e) {
216295
216337
  logger.error(`Scanning for vulnerabilities failed for subproject ${subprojectPath} in workspace ${workspacePath}`);
216296
- logger.error(JSON.stringify(dependencyTree, null, 2));
216297
- await new Promise((resolve25) => setTimeout(resolve25, 1e4));
216298
216338
  throw e;
216299
216339
  } finally {
216300
216340
  this.sendProgress("SCAN_FOR_VULNERABILITIES", false, subprojectPath, workspacePath);
@@ -196,18 +196,19 @@ function requireYoctoSpinner() {
196
196
  return _stripVTControlCharacters(string)
197
197
  }
198
198
  class YoctoSpinner {
199
- #frames
200
- #interval
201
- #currentFrame = -1
202
- #timer
203
- #text
204
- #stream
205
199
  #color
206
- #lines = 0
200
+ #currentFrame = -1
207
201
  #exitHandlerBound
202
+ #frames
203
+ #indention = ''
204
+ #interval
208
205
  #isInteractive
209
- #lastSpinnerFrameTime = 0
210
206
  #isSpinning = false
207
+ #lastSpinnerFrameTime = 0
208
+ #lines = 0
209
+ #stream
210
+ #text
211
+ #timer
211
212
  constructor(options = {}) {
212
213
  const opts = {
213
214
  __proto__: null,
@@ -223,58 +224,87 @@ function requireYoctoSpinner() {
223
224
  this.#isInteractive = !!stream.isTTY && isProcessInteractive()
224
225
  this.#exitHandlerBound = this.#exitHandler.bind(this)
225
226
  }
226
- start(text) {
227
- if (text) {
228
- this.#text = text
229
- }
227
+ #exitHandler(signal) {
230
228
  if (this.isSpinning) {
231
- return this
229
+ this.stop()
232
230
  }
233
- this.#isSpinning = true
234
- this.#hideCursor()
235
- this.#render()
236
- this.#subscribeToProcessEvents()
237
231
 
238
- // Only start the timer in interactive mode
232
+ // SIGINT: 128 + 2
233
+ // SIGTERM: 128 + 15
234
+ const exitCode =
235
+ signal === 'SIGINT' ? 130 : signal === 'SIGTERM' ? 143 : 1
236
+ // eslint-disable-next-line n/no-process-exit
237
+ process.exit(exitCode)
238
+ }
239
+ #hideCursor() {
239
240
  if (this.#isInteractive) {
240
- this.#timer = setInterval(() => {
241
- this.#render()
242
- }, this.#interval)
241
+ this.#write('\u001B[?25l')
243
242
  }
244
- return this
245
243
  }
246
- stop(finalText) {
247
- if (!this.isSpinning) {
248
- return this
244
+ #lineCount(text) {
245
+ const width = this.#stream.columns ?? defaultTtyColumns
246
+ const lines = stripVTControlCharacters(text).split('\n')
247
+ let lineCount = 0
248
+ for (const line of lines) {
249
+ lineCount += Math.max(1, Math.ceil(line.length / width))
249
250
  }
250
- this.#isSpinning = false
251
- if (this.#timer) {
252
- clearInterval(this.#timer)
253
- this.#timer = undefined
251
+ return lineCount
252
+ }
253
+ #render() {
254
+ // Ensure we only update the spinner frame at the wanted interval,
255
+ // even if the frame method is called more often.
256
+ const now = Date.now()
257
+ if (
258
+ this.#currentFrame === -1 ||
259
+ now - this.#lastSpinnerFrameTime >= this.#interval
260
+ ) {
261
+ this.#currentFrame = ++this.#currentFrame % this.#frames.length
262
+ this.#lastSpinnerFrameTime = now
263
+ }
264
+ const colors = getYoctocolors()
265
+ const applyColor = colors[this.#color] ?? colors.cyan
266
+ const frame = this.#frames[this.#currentFrame]
267
+ let string = `${applyColor(frame)} ${this.#text}`
268
+ if (string) {
269
+ if (this.#indention.length) {
270
+ string = `${this.#indention}${string}`
271
+ }
272
+ if (!this.#isInteractive) {
273
+ string += '\n'
274
+ }
254
275
  }
255
- this.#showCursor()
256
276
  this.clear()
257
- this.#unsubscribeFromProcessEvents()
258
- if (finalText) {
259
- this.#stream.write(`${finalText}\n`)
277
+ this.#write(string)
278
+ if (this.#isInteractive) {
279
+ this.#lines = this.#lineCount(string)
260
280
  }
261
- return this
281
+ }
282
+ #showCursor() {
283
+ if (this.#isInteractive) {
284
+ this.#write('\u001B[?25h')
285
+ }
286
+ }
287
+ #subscribeToProcessEvents() {
288
+ process.once('SIGINT', this.#exitHandlerBound)
289
+ process.once('SIGTERM', this.#exitHandlerBound)
262
290
  }
263
291
  #symbolStop(symbolType, text) {
264
292
  const symbols = getLogSymbols()
265
293
  return this.stop(`${symbols[symbolType]} ${text ?? this.#text}`)
266
294
  }
267
- success(text) {
268
- return this.#symbolStop('success', text)
295
+ #write(text) {
296
+ this.#stream.write(text)
269
297
  }
270
- error(text) {
271
- return this.#symbolStop('error', text)
298
+ #unsubscribeFromProcessEvents() {
299
+ process.off('SIGINT', this.#exitHandlerBound)
300
+ process.off('SIGTERM', this.#exitHandlerBound)
272
301
  }
273
- warning(text) {
274
- return this.#symbolStop('warning', text)
302
+ get color() {
303
+ return this.#color
275
304
  }
276
- info(text) {
277
- return this.#symbolStop('info', text)
305
+ set color(value) {
306
+ this.#color = value
307
+ this.#render()
278
308
  }
279
309
  get isSpinning() {
280
310
  return this.#isSpinning
@@ -286,13 +316,6 @@ function requireYoctoSpinner() {
286
316
  this.#text = value ?? ''
287
317
  this.#render()
288
318
  }
289
- get color() {
290
- return this.#color
291
- }
292
- set color(value) {
293
- this.#color = value
294
- this.#render()
295
- }
296
319
  clear() {
297
320
  if (!this.#isInteractive) {
298
321
  return this
@@ -307,71 +330,66 @@ function requireYoctoSpinner() {
307
330
  this.#lines = 0
308
331
  return this
309
332
  }
310
- #render() {
311
- // Ensure we only update the spinner frame at the wanted interval,
312
- // even if the frame method is called more often.
313
- const now = Date.now()
314
- if (
315
- this.#currentFrame === -1 ||
316
- now - this.#lastSpinnerFrameTime >= this.#interval
317
- ) {
318
- this.#currentFrame = ++this.#currentFrame % this.#frames.length
319
- this.#lastSpinnerFrameTime = now
333
+ dedent(spaces = 2) {
334
+ this.#indention = this.#indention.slice(0, -spaces)
335
+ return this
336
+ }
337
+ error(text) {
338
+ return this.#symbolStop('error', text)
339
+ }
340
+ indent(spaces = 2) {
341
+ this.#indention += ' '.repeat(spaces)
342
+ return this
343
+ }
344
+ info(text) {
345
+ return this.#symbolStop('info', text)
346
+ }
347
+ resetIndent() {
348
+ this.#indention = ''
349
+ return this
350
+ }
351
+ start(text) {
352
+ if (text) {
353
+ this.#text = text
320
354
  }
321
- const colors = getYoctocolors()
322
- const applyColor = colors[this.#color] ?? colors.cyan
323
- const frame = this.#frames[this.#currentFrame]
324
- let string = `${applyColor(frame)} ${this.#text}`
325
- if (!this.#isInteractive) {
326
- string += '\n'
355
+ if (this.isSpinning) {
356
+ return this
327
357
  }
328
- this.clear()
329
- this.#write(string)
358
+ this.#isSpinning = true
359
+ this.#hideCursor()
360
+ this.#render()
361
+ this.#subscribeToProcessEvents()
362
+
363
+ // Only start the timer in interactive mode
330
364
  if (this.#isInteractive) {
331
- this.#lines = this.#lineCount(string)
365
+ this.#timer = setInterval(() => {
366
+ this.#render()
367
+ }, this.#interval)
332
368
  }
369
+ return this
333
370
  }
334
- #write(text) {
335
- this.#stream.write(text)
336
- }
337
- #lineCount(text) {
338
- const width = this.#stream.columns ?? defaultTtyColumns
339
- const lines = stripVTControlCharacters(text).split('\n')
340
- let lineCount = 0
341
- for (const line of lines) {
342
- lineCount += Math.max(1, Math.ceil(line.length / width))
371
+ stop(finalText) {
372
+ if (!this.isSpinning) {
373
+ return this
343
374
  }
344
- return lineCount
345
- }
346
- #hideCursor() {
347
- if (this.#isInteractive) {
348
- this.#write('\u001B[?25l')
375
+ this.#isSpinning = false
376
+ if (this.#timer) {
377
+ clearInterval(this.#timer)
378
+ this.#timer = undefined
349
379
  }
350
- }
351
- #showCursor() {
352
- if (this.#isInteractive) {
353
- this.#write('\u001B[?25h')
380
+ this.#showCursor()
381
+ this.clear()
382
+ this.#unsubscribeFromProcessEvents()
383
+ if (finalText) {
384
+ this.#write(`${this.#indention}${finalText}\n`)
354
385
  }
386
+ return this
355
387
  }
356
- #subscribeToProcessEvents() {
357
- process.once('SIGINT', this.#exitHandlerBound)
358
- process.once('SIGTERM', this.#exitHandlerBound)
359
- }
360
- #unsubscribeFromProcessEvents() {
361
- process.off('SIGINT', this.#exitHandlerBound)
362
- process.off('SIGTERM', this.#exitHandlerBound)
388
+ success(text) {
389
+ return this.#symbolStop('success', text)
363
390
  }
364
- #exitHandler(signal) {
365
- if (this.isSpinning) {
366
- this.stop()
367
- }
368
-
369
- // SIGINT: 128 + 2
370
- // SIGTERM: 128 + 15
371
- const exitCode =
372
- signal === 'SIGINT' ? 130 : signal === 'SIGTERM' ? 143 : 1
373
- // eslint-disable-next-line n/no-process-exit
374
- process.exit(exitCode)
391
+ warning(text) {
392
+ return this.#symbolStop('warning', text)
375
393
  }
376
394
  }
377
395
  yoctoSpinner = function yoctoSpinner(options) {
@@ -1,5 +1,6 @@
1
1
  'use strict'
2
2
 
3
3
  const maintainedNodeVersions = /*@__PURE__*/ require('./maintained-node-versions')
4
+ const semver = /*@__PURE__*/ require('../../external/semver')
4
5
 
5
- module.exports = `>=${maintainedNodeVersions.last}`
6
+ module.exports = `>=${semver.parse(maintainedNodeVersions.last).major}`