snyk 1.845.0 → 1.846.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) {
@@ -5303,24 +5303,25 @@ exports.codePlugin = {
5303
5303
  }
5304
5304
  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
5305
  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
5306
  const meta = output_format_1.getMeta(options, path);
5318
5307
  const prefix = output_format_1.getPrefix(path);
5319
- const readableResult = output_format_1.getCodeDisplayedOutput(sarifTypedResult, meta, prefix);
5308
+ let readableResult = output_format_1.getCodeDisplayedOutput(sarifTypedResult, meta, prefix);
5309
+ let sarifResult;
5310
+ if (numOfIssues > 0 && options['no-markdown']) {
5311
+ (_d = (_c = sarifTypedResult.runs) === null || _c === void 0 ? void 0 : _c[0].results) === null || _d === void 0 ? void 0 : _d.forEach(({ message }) => {
5312
+ delete message.markdown;
5313
+ });
5314
+ }
5315
+ if (options['sarif-file-output']) {
5316
+ sarifResult = json_1.jsonStringifyLargeObject(sarifTypedResult);
5317
+ }
5318
+ if (options.sarif || options.json) {
5319
+ readableResult = json_1.jsonStringifyLargeObject(sarifTypedResult);
5320
+ }
5320
5321
  if (numOfIssues > 0) {
5321
- hasIssues(readableResult);
5322
+ hasIssues(readableResult, sarifResult);
5322
5323
  }
5323
- return { readableResult };
5324
+ return sarifResult ? { readableResult, sarifResult } : { readableResult };
5324
5325
  }
5325
5326
  catch (error) {
5326
5327
  let err;
@@ -5353,9 +5354,12 @@ function isUnauthorizedError(error) {
5353
5354
  return ((error.statusCode >= 400 && error.statusCode < 500) ||
5354
5355
  (error.code >= 400 && error.code < 500));
5355
5356
  }
5356
- function hasIssues(readableResult) {
5357
+ function hasIssues(readableResult, sarifResult) {
5357
5358
  const err = new Error(readableResult);
5358
5359
  err.code = 'VULNS';
5360
+ if (sarifResult !== undefined) {
5361
+ err.sarifStringifiedResults = sarifResult;
5362
+ }
5359
5363
  throw err;
5360
5364
  }
5361
5365