snyk 1.1159.0 → 1.1161.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.
@@ -4936,10 +4936,8 @@ const chalk_1 = __webpack_require__(32589);
4936
4936
  const theme_1 = __webpack_require__(86988);
4937
4937
  const common_1 = __webpack_require__(53110);
4938
4938
  const right_pad_1 = __webpack_require__(80627);
4939
+ const utils_1 = __webpack_require__(33113);
4939
4940
  const debug = Debug('code-output');
4940
- function filterIgnoredIssues(analysisResults) {
4941
- return analysisResults.filter((rule) => { var _a, _b; return ((_b = (_a = rule.suppressions) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) === 0; });
4942
- }
4943
4941
  function getCodeDisplayedOutput(args) {
4944
4942
  let issues = {};
4945
4943
  const sarif = args.testResults.analysisResults.sarif;
@@ -4947,7 +4945,7 @@ function getCodeDisplayedOutput(args) {
4947
4945
  // Filter ignored issues (suppressions) from the sarif to display in the cli output
4948
4946
  // The sarif will remain unchanged and contain the suppressions
4949
4947
  const results = args.shouldFilterIgnored
4950
- ? filterIgnoredIssues(sarif.runs[0].results)
4948
+ ? utils_1.filterIgnoredIssues(sarif.runs[0].results)
4951
4949
  : sarif.runs[0].results;
4952
4950
  const rulesMap = getRulesMap(sarif.runs[0].tool.driver.rules || []);
4953
4951
  issues = getIssues(results, rulesMap);
@@ -5088,6 +5086,7 @@ const settings_1 = __webpack_require__(24930);
5088
5086
  const output_format_1 = __webpack_require__(75802);
5089
5087
  const errors_1 = __webpack_require__(55191);
5090
5088
  const errors_2 = __webpack_require__(61315);
5089
+ const utils_1 = __webpack_require__(33113);
5091
5090
  const json_1 = __webpack_require__(27019);
5092
5091
  const analytics = __webpack_require__(82744);
5093
5092
  const cloneDeep = __webpack_require__(83465);
@@ -5102,7 +5101,7 @@ exports.codePlugin = {
5102
5101
  return '';
5103
5102
  },
5104
5103
  async test(paths, options) {
5105
- var _a, _b, _c, _d, _e, _f;
5104
+ var _a, _b, _c, _d;
5106
5105
  const requestId = uuid_1.v4();
5107
5106
  debug(`Request ID: ${requestId}`);
5108
5107
  try {
@@ -5116,7 +5115,14 @@ exports.codePlugin = {
5116
5115
  }
5117
5116
  // cloneDeep is used so the sarif is not changed when using the testResults getting the displayed output
5118
5117
  const sarifTypedResult = cloneDeep((_a = testResults === null || testResults === void 0 ? void 0 : testResults.analysisResults) === null || _a === void 0 ? void 0 : _a.sarif);
5119
- const numOfIssues = ((_c = (_b = sarifTypedResult.runs) === null || _b === void 0 ? void 0 : _b[0].results) === null || _c === void 0 ? void 0 : _c.length) || 0;
5118
+ const sarifRunResults = (_c = (_b = sarifTypedResult.runs) === null || _b === void 0 ? void 0 : _b[0].results) !== null && _c !== void 0 ? _c : [];
5119
+ // Report flow includes ignored issues (suppressions) in the results.
5120
+ const hasIgnoredIssues = (_d = options['report']) !== null && _d !== void 0 ? _d : false;
5121
+ // If suppressions are included in results filter them out to get real issue count
5122
+ const foundIssues = hasIgnoredIssues
5123
+ ? utils_1.filterIgnoredIssues(sarifRunResults)
5124
+ : sarifRunResults;
5125
+ const numOfIssues = foundIssues.length || 0;
5120
5126
  analytics.add('sast-issues-found', numOfIssues);
5121
5127
  let newOrg = options.org;
5122
5128
  if (!newOrg && sastSettings.org) {
@@ -5128,23 +5134,30 @@ exports.codePlugin = {
5128
5134
  testResults,
5129
5135
  meta,
5130
5136
  prefix,
5131
- shouldFilterIgnored: (_d = options['report']) !== null && _d !== void 0 ? _d : false,
5137
+ shouldFilterIgnored: hasIgnoredIssues,
5132
5138
  });
5133
- if (numOfIssues > 0 && options['no-markdown']) {
5134
- (_f = (_e = sarifTypedResult.runs) === null || _e === void 0 ? void 0 : _e[0].results) === null || _f === void 0 ? void 0 : _f.forEach(({ message }) => {
5139
+ if (options['no-markdown']) {
5140
+ sarifRunResults.forEach(({ message }) => {
5135
5141
  delete message.markdown;
5136
5142
  });
5137
5143
  }
5144
+ const shouldStringifyResult = options['sarif-file-output'] ||
5145
+ options.sarif ||
5146
+ options['json-file-output'] ||
5147
+ options.json;
5148
+ const stringifiedResult = shouldStringifyResult
5149
+ ? json_1.jsonStringifyLargeObject(sarifTypedResult)
5150
+ : '';
5138
5151
  let sarifResult;
5139
5152
  if (options['sarif-file-output']) {
5140
- sarifResult = json_1.jsonStringifyLargeObject(sarifTypedResult);
5153
+ sarifResult = stringifiedResult;
5141
5154
  }
5142
5155
  let jsonResult;
5143
5156
  if (options['json-file-output']) {
5144
- jsonResult = json_1.jsonStringifyLargeObject(sarifTypedResult);
5157
+ jsonResult = stringifiedResult;
5145
5158
  }
5146
5159
  if (options.sarif || options.json) {
5147
- readableResult = json_1.jsonStringifyLargeObject(sarifTypedResult);
5160
+ readableResult = stringifiedResult;
5148
5161
  }
5149
5162
  if (numOfIssues > 0) {
5150
5163
  throwIssuesError({ readableResult, sarifResult, jsonResult });
@@ -5257,6 +5270,21 @@ async function getSastSettings(options) {
5257
5270
  exports.getSastSettings = getSastSettings;
5258
5271
 
5259
5272
 
5273
+ /***/ }),
5274
+
5275
+ /***/ 72290:
5276
+ /***/ ((__unused_webpack_module, exports) => {
5277
+
5278
+ "use strict";
5279
+
5280
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
5281
+ exports.filterIgnoredIssues = void 0;
5282
+ function filterIgnoredIssues(analysisResults) {
5283
+ return analysisResults.filter((rule) => { var _a, _b; return ((_b = (_a = rule.suppressions) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) === 0; });
5284
+ }
5285
+ exports.filterIgnoredIssues = filterIgnoredIssues;
5286
+
5287
+
5260
5288
  /***/ }),
5261
5289
 
5262
5290
  /***/ 33113:
@@ -5267,6 +5295,8 @@ exports.getSastSettings = getSastSettings;
5267
5295
  Object.defineProperty(exports, "__esModule", ({ value: true }));
5268
5296
  var testEmitter_1 = __webpack_require__(83901);
5269
5297
  Object.defineProperty(exports, "analysisProgressUpdate", ({ enumerable: true, get: function () { return testEmitter_1.analysisProgressUpdate; } }));
5298
+ var filter_1 = __webpack_require__(72290);
5299
+ Object.defineProperty(exports, "filterIgnoredIssues", ({ enumerable: true, get: function () { return filter_1.filterIgnoredIssues; } }));
5270
5300
 
5271
5301
 
5272
5302
  /***/ }),