snyk 1.844.0 → 1.848.0

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.
@@ -951,8 +951,8 @@ async function testEcosystem(ecosystem, paths, options) {
951
951
  // TODO: this is an intermediate step before consolidating ecosystem plugins
952
952
  // to accept flows that act differently in the testDependencies step
953
953
  if (plugin.test) {
954
- const { readableResult: res } = await plugin.test(paths, options);
955
- return types_1.TestCommandResult.createHumanReadableTestCommandResult(res, '');
954
+ const { readableResult: res, sarifResult: sarifRes } = await plugin.test(paths, options);
955
+ return types_1.TestCommandResult.createHumanReadableTestCommandResult(res, '', sarifRes);
956
956
  }
957
957
  const scanResultsByPath = {};
958
958
  for (const path of paths) {
@@ -5280,7 +5280,8 @@ const output_format_1 = __webpack_require__(75802);
5280
5280
  const errors_1 = __webpack_require__(55191);
5281
5281
  const json_1 = __webpack_require__(27019);
5282
5282
  const analytics = __webpack_require__(82744);
5283
- const debug = debugLib('snyk-code-test');
5283
+ debugLib.enable('snyk-code');
5284
+ const debug = debugLib('snyk-code');
5284
5285
  exports.codePlugin = {
5285
5286
  // We currently don't use scan/display. we will need to consolidate ecosystem plugins
5286
5287
  // to accept flows that act differently in the `testDependencies` step, as we have here
@@ -5303,24 +5304,25 @@ exports.codePlugin = {
5303
5304
  }
5304
5305
  const numOfIssues = ((_b = (_a = sarifTypedResult.runs) === null || _a === void 0 ? void 0 : _a[0].results) === null || _b === void 0 ? void 0 : _b.length) || 0;
5305
5306
  analytics.add('sast-issues-found', numOfIssues);
5306
- if (options.sarif || options.json) {
5307
- if (numOfIssues > 0) {
5308
- if (options['no-markdown']) {
5309
- (_d = (_c = sarifTypedResult.runs) === null || _c === void 0 ? void 0 : _c[0].results) === null || _d === void 0 ? void 0 : _d.forEach(({ message }) => {
5310
- delete message.markdown;
5311
- });
5312
- }
5313
- hasIssues(json_1.jsonStringifyLargeObject(sarifTypedResult));
5314
- }
5315
- return { readableResult: json_1.jsonStringifyLargeObject(sarifTypedResult) };
5316
- }
5317
5307
  const meta = output_format_1.getMeta(options, path);
5318
5308
  const prefix = output_format_1.getPrefix(path);
5319
- const readableResult = output_format_1.getCodeDisplayedOutput(sarifTypedResult, meta, prefix);
5309
+ let readableResult = output_format_1.getCodeDisplayedOutput(sarifTypedResult, meta, prefix);
5310
+ let sarifResult;
5311
+ if (numOfIssues > 0 && options['no-markdown']) {
5312
+ (_d = (_c = sarifTypedResult.runs) === null || _c === void 0 ? void 0 : _c[0].results) === null || _d === void 0 ? void 0 : _d.forEach(({ message }) => {
5313
+ delete message.markdown;
5314
+ });
5315
+ }
5316
+ if (options['sarif-file-output']) {
5317
+ sarifResult = json_1.jsonStringifyLargeObject(sarifTypedResult);
5318
+ }
5319
+ if (options.sarif || options.json) {
5320
+ readableResult = json_1.jsonStringifyLargeObject(sarifTypedResult);
5321
+ }
5320
5322
  if (numOfIssues > 0) {
5321
- hasIssues(readableResult);
5323
+ hasIssues(readableResult, sarifResult);
5322
5324
  }
5323
- return { readableResult };
5325
+ return sarifResult ? { readableResult, sarifResult } : { readableResult };
5324
5326
  }
5325
5327
  catch (error) {
5326
5328
  let err;
@@ -5339,7 +5341,8 @@ exports.codePlugin = {
5339
5341
  else {
5340
5342
  err = new Error(error);
5341
5343
  }
5342
- debug(chalk_1.default.bold.red(error.statusText || error.message));
5344
+ debug(chalk_1.default.bold.red(`statusCode:${error.code ||
5345
+ error.statusCode}, message: ${error.statusText || error.message}`));
5343
5346
  throw err;
5344
5347
  }
5345
5348
  },
@@ -5350,12 +5353,17 @@ function isCodeClientError(error) {
5350
5353
  error.hasOwnProperty('apiName'));
5351
5354
  }
5352
5355
  function isUnauthorizedError(error) {
5353
- return ((error.statusCode >= 400 && error.statusCode < 500) ||
5354
- (error.code >= 400 && error.code < 500));
5356
+ return (error.statusCode === 401 ||
5357
+ error.statusCode === 403 ||
5358
+ error.code === 403 ||
5359
+ error.code === 401);
5355
5360
  }
5356
- function hasIssues(readableResult) {
5361
+ function hasIssues(readableResult, sarifResult) {
5357
5362
  const err = new Error(readableResult);
5358
5363
  err.code = 'VULNS';
5364
+ if (sarifResult !== undefined) {
5365
+ err.sarifStringifiedResults = sarifResult;
5366
+ }
5359
5367
  throw err;
5360
5368
  }
5361
5369