snyk 1.1288.0 → 1.1289.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.
@@ -2376,7 +2376,7 @@ exports.formatLegalInstructions = formatLegalInstructions;
2376
2376
  "use strict";
2377
2377
 
2378
2378
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2379
- exports.formatIssue = exports.printPath = exports.formatIssuesWithRemediation = void 0;
2379
+ exports.printPath = exports.formatIssuesWithRemediation = void 0;
2380
2380
  const chalk_1 = __webpack_require__(32589);
2381
2381
  const theme_1 = __webpack_require__(86988);
2382
2382
  const common_1 = __webpack_require__(53110);
@@ -2400,6 +2400,7 @@ function formatIssuesWithRemediation(vulns, remediationInfo, options) {
2400
2400
  note: vuln.note,
2401
2401
  legalInstructions: vuln.legalInstructionsArray,
2402
2402
  paths: vuln.list.map((v) => v.from),
2403
+ appliedPolicyRules: vuln.appliedPolicyRules,
2403
2404
  };
2404
2405
  if (vulnData.type === 'license') {
2405
2406
  basicLicenseInfo[vuln.metadata.id] = vulnData;
@@ -2456,13 +2457,25 @@ function constructLicenseText(basicLicenseInfo, testOptions) {
2456
2457
  }
2457
2458
  const licenseTextArray = [chalk_1.default.bold.green('\nLicense issues:')];
2458
2459
  for (const id of Object.keys(basicLicenseInfo)) {
2459
- const licenseText = formatIssue(id, basicLicenseInfo[id].title, basicLicenseInfo[id].severity, basicLicenseInfo[id].isNew, `${basicLicenseInfo[id].name}@${basicLicenseInfo[id].version}`, basicLicenseInfo[id].paths, testOptions, basicLicenseInfo[id].note, undefined, // We can never override license rules, so no originalSeverity here
2460
- basicLicenseInfo[id].legalInstructions);
2460
+ const licenseText = formatIssue({
2461
+ id,
2462
+ title: basicLicenseInfo[id].title,
2463
+ severity: basicLicenseInfo[id].severity,
2464
+ isNew: basicLicenseInfo[id].isNew,
2465
+ vulnerableModule: `${basicLicenseInfo[id].name}@${basicLicenseInfo[id].version}`,
2466
+ paths: basicLicenseInfo[id].paths,
2467
+ testOptions,
2468
+ note: basicLicenseInfo[id].note,
2469
+ originalSeverity: undefined,
2470
+ legalInstructions: basicLicenseInfo[id].legalInstructions,
2471
+ appliedPolicyRules: basicLicenseInfo[id].appliedPolicyRules,
2472
+ });
2461
2473
  licenseTextArray.push('\n' + licenseText);
2462
2474
  }
2463
2475
  return licenseTextArray;
2464
2476
  }
2465
2477
  function constructPatchesText(patches, basicVulnInfo, testOptions) {
2478
+ var _a;
2466
2479
  if (!(Object.keys(patches).length > 0)) {
2467
2480
  return [];
2468
2481
  }
@@ -2477,7 +2490,19 @@ function constructPatchesText(patches, basicVulnInfo, testOptions) {
2477
2490
  // todo: add vulnToPatch package name
2478
2491
  const packageAtVersion = `${basicVulnInfo[id].name}@${basicVulnInfo[id].version}`;
2479
2492
  const patchedText = `\n Patch available for ${chalk_1.default.bold.whiteBright(packageAtVersion)}\n`;
2480
- const thisPatchFixes = formatIssue(id, basicVulnInfo[id].title, basicVulnInfo[id].severity, basicVulnInfo[id].isNew, `${basicVulnInfo[id].name}@${basicVulnInfo[id].version}`, basicVulnInfo[id].paths, testOptions, basicVulnInfo[id].note, basicVulnInfo[id].originalSeverity);
2493
+ const thisPatchFixes = formatIssue({
2494
+ id,
2495
+ title: basicVulnInfo[id].title,
2496
+ severity: basicVulnInfo[id].severity,
2497
+ isNew: basicVulnInfo[id].isNew,
2498
+ vulnerableModule: `${basicVulnInfo[id].name}@${basicVulnInfo[id].version}`,
2499
+ paths: basicVulnInfo[id].paths,
2500
+ testOptions,
2501
+ note: basicVulnInfo[id].note,
2502
+ originalSeverity: basicVulnInfo[id].originalSeverity,
2503
+ legalInstructions: [],
2504
+ appliedPolicyRules: (_a = basicVulnInfo[id]) === null || _a === void 0 ? void 0 : _a.appliedPolicyRules,
2505
+ });
2481
2506
  patchedTextArray.push(patchedText + thisPatchFixes);
2482
2507
  }
2483
2508
  return patchedTextArray;
@@ -2488,7 +2513,22 @@ function thisUpgradeFixes(vulnIds, basicVulnInfo, testOptions) {
2488
2513
  .sort((a, b) => (0, get_severity_value_1.getSeverityValue)(basicVulnInfo[a].severity) -
2489
2514
  (0, get_severity_value_1.getSeverityValue)(basicVulnInfo[b].severity))
2490
2515
  .filter((id) => basicVulnInfo[id].type !== 'license')
2491
- .map((id) => formatIssue(id, basicVulnInfo[id].title, basicVulnInfo[id].severity, basicVulnInfo[id].isNew, `${basicVulnInfo[id].name}@${basicVulnInfo[id].version}`, basicVulnInfo[id].paths, testOptions, basicVulnInfo[id].note, basicVulnInfo[id].originalSeverity, []))
2516
+ .map((id) => {
2517
+ var _a;
2518
+ return formatIssue({
2519
+ id,
2520
+ title: basicVulnInfo[id].title,
2521
+ severity: basicVulnInfo[id].severity,
2522
+ isNew: basicVulnInfo[id].isNew,
2523
+ vulnerableModule: `${basicVulnInfo[id].name}@${basicVulnInfo[id].version}`,
2524
+ paths: basicVulnInfo[id].paths,
2525
+ testOptions,
2526
+ note: basicVulnInfo[id].note,
2527
+ originalSeverity: basicVulnInfo[id].originalSeverity,
2528
+ legalInstructions: [],
2529
+ appliedPolicyRules: (_a = basicVulnInfo[id]) === null || _a === void 0 ? void 0 : _a.appliedPolicyRules,
2530
+ });
2531
+ })
2492
2532
  .join('\n');
2493
2533
  }
2494
2534
  function processUpgrades(sink, upgradesByDep, deps, basicVulnInfo, testOptions) {
@@ -2562,7 +2602,19 @@ function constructUnfixableText(unresolved, basicVulnInfo, testOptions) {
2562
2602
  const extraInfo = issue.fixedIn && issue.fixedIn.length
2563
2603
  ? `\n This issue was fixed in versions: ${chalk_1.default.bold(issue.fixedIn.join(', '))}`
2564
2604
  : '\n No upgrade or patch available';
2565
- unfixableIssuesTextArray.push(formatIssue(issue.id, issue.title, issue.severity, issue.isNew, `${issue.packageName}@${issue.version}`, issueInfo.paths, testOptions, issueInfo.note, issueInfo.originalSeverity, []) + `${extraInfo}`);
2605
+ unfixableIssuesTextArray.push(formatIssue({
2606
+ id: issue.id,
2607
+ title: issue.title,
2608
+ severity: issue.severity,
2609
+ isNew: issue.isNew,
2610
+ vulnerableModule: `${issue.packageName}@${issue.version}`,
2611
+ paths: issueInfo.paths,
2612
+ testOptions,
2613
+ note: issueInfo.note,
2614
+ originalSeverity: issueInfo.originalSeverity,
2615
+ legalInstructions: [],
2616
+ appliedPolicyRules: issueInfo === null || issueInfo === void 0 ? void 0 : issueInfo.appliedPolicyRules,
2617
+ }) + `${extraInfo}`);
2566
2618
  }
2567
2619
  if (unfixableIssuesTextArray.length === 1) {
2568
2620
  // seems we still only have
@@ -2575,7 +2627,8 @@ function printPath(path, slice = 1) {
2575
2627
  return path.slice(slice).join(constants_1.PATH_SEPARATOR);
2576
2628
  }
2577
2629
  exports.printPath = printPath;
2578
- function formatIssue(id, title, severity, isNew, vulnerableModule, paths, testOptions, note, originalSeverity, legalInstructions) {
2630
+ function formatIssue(issue) {
2631
+ const { id, title, severity, isNew, vulnerableModule, paths, testOptions, note, originalSeverity, legalInstructions, appliedPolicyRules, } = issue;
2579
2632
  const newBadge = isNew ? ' (new)' : '';
2580
2633
  const name = vulnerableModule ? ` in ${chalk_1.default.bold(vulnerableModule)}` : '';
2581
2634
  let legalLicenseInstructionsText;
@@ -2608,6 +2661,8 @@ function formatIssue(id, title, severity, isNew, vulnerableModule, paths, testOp
2608
2661
  if (originalSeverity && originalSeverity !== severity) {
2609
2662
  originalSeverityStr = ` (originally ${titleCaseText(originalSeverity)})`;
2610
2663
  }
2664
+ const { value: userNote, reason: userNoteReason } = (appliedPolicyRules === null || appliedPolicyRules === void 0 ? void 0 : appliedPolicyRules.annotation) || {};
2665
+ const { reason: severityReason } = (appliedPolicyRules === null || appliedPolicyRules === void 0 ? void 0 : appliedPolicyRules.severityChange) || {};
2611
2666
  return ((0, common_1.colorTextBySeverity)(severity, ` ${theme_1.icon.ISSUE} ${chalk_1.default.bold(title)}${newBadge} [${titleCaseText(severity)} Severity${originalSeverityStr}]`) +
2612
2667
  `[${(0, get_vuln_url_1.getVulnerabilityUrl)(id)}]` +
2613
2668
  name +
@@ -2615,9 +2670,11 @@ function formatIssue(id, title, severity, isNew, vulnerableModule, paths, testOp
2615
2670
  (legalLicenseInstructionsText
2616
2671
  ? `${chalk_1.default.bold('\n Legal instructions')}:\n ${legalLicenseInstructionsText}`
2617
2672
  : '') +
2618
- (note ? `${chalk_1.default.bold('\n Note')}:\n ${note}` : ''));
2673
+ (note ? `${chalk_1.default.bold('\n Note')}:\n ${note}` : '') +
2674
+ (severityReason ? '\n Severity reason: ' + severityReason : '') +
2675
+ (userNote ? '\n User note: ' + userNote : '') +
2676
+ (userNoteReason ? '\n Note reason: ' + userNoteReason : ''));
2619
2677
  }
2620
- exports.formatIssue = formatIssue;
2621
2678
  function titleCaseText(text) {
2622
2679
  return text[0].toUpperCase() + text.slice(1);
2623
2680
  }