snyk 1.897.0 → 1.898.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.
@@ -518,15 +518,14 @@ const detect_1 = __webpack_require__(45318);
518
518
  const types_1 = __webpack_require__(42258);
519
519
  const analytics_1 = __webpack_require__(22716);
520
520
  const usage_tracking_1 = __webpack_require__(43156);
521
- const policy_1 = __webpack_require__(25476);
522
521
  const measurable_methods_1 = __webpack_require__(78272);
523
522
  const unsupported_entitlement_error_1 = __webpack_require__(78673);
524
523
  const config_1 = __webpack_require__(22541);
525
- const policy_2 = __webpack_require__(32615);
524
+ const policy_1 = __webpack_require__(32615);
526
525
  const feature_flags_1 = __webpack_require__(63011);
527
526
  const rules_1 = __webpack_require__(98895);
528
527
  const file_loader_1 = __webpack_require__(13552);
529
- const share_results_1 = __webpack_require__(3558);
528
+ const process_results_1 = __webpack_require__(59964);
530
529
  const monitor_1 = __webpack_require__(3708);
531
530
  const directory_loader_1 = __webpack_require__(71484);
532
531
  // this method executes the local processing engine and then formats the results to adapt with the CLI output.
@@ -544,7 +543,7 @@ async function test(pathToScan, options) {
544
543
  const tags = parseTags(options);
545
544
  const attributes = parseAttributes(options);
546
545
  const rulesOrigin = await rules_1.initRules(iacOrgSettings, options);
547
- const policy = await policy_2.findAndLoadPolicy(pathToScan, 'iac', options);
546
+ const policy = await policy_1.findAndLoadPolicy(pathToScan, 'iac', options);
548
547
  const isTFVarSupportEnabled = (await feature_flags_1.isFeatureFlagSupportedForOrg('iacTerraformVarSupport', iacOrgSettings.meta.org)).ok;
549
548
  let allParsedFiles = [], allFailedFiles = [];
550
549
  const allDirectories = directory_loader_1.getAllDirectoriesForPath(pathToScan, options.detectionDepth);
@@ -574,22 +573,10 @@ async function test(pathToScan, options) {
574
573
  engineType: types_1.EngineType.Custom,
575
574
  })));
576
575
  }
576
+ // TODO: decide if this should go into scanFiles or stay here
577
577
  const scannedFiles = await measurable_methods_1.scanFiles(allParsedFiles);
578
578
  const resultsWithCustomSeverities = await measurable_methods_1.applyCustomSeverities(scannedFiles, iacOrgSettings.customPolicies);
579
- let projectPublicIds = {};
580
- let gitRemoteUrl;
581
- if (options.report) {
582
- ({ projectPublicIds, gitRemoteUrl } = await share_results_1.formatAndShareResults({
583
- results: resultsWithCustomSeverities,
584
- options,
585
- orgPublicId,
586
- policy,
587
- tags,
588
- attributes,
589
- }));
590
- }
591
- const formattedResults = measurable_methods_1.formatScanResults(resultsWithCustomSeverities, options, iacOrgSettings.meta, projectPublicIds, gitRemoteUrl);
592
- const { filteredIssues, ignoreCount } = policy_1.filterIgnoredIssues(policy, formattedResults);
579
+ const { filteredIssues, ignoreCount } = await process_results_1.processResults(resultsWithCustomSeverities, orgPublicId, iacOrgSettings, policy, tags, attributes, options);
593
580
  try {
594
581
  await measurable_methods_1.trackUsage(filteredIssues);
595
582
  }
@@ -650,7 +637,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
650
637
  exports.pull = exports.localTest = exports.cleanLocalCache = exports.trackUsage = exports.formatScanResults = exports.applyCustomSeverities = exports.getIacOrgSettings = exports.scanFiles = exports.parseFiles = exports.loadContentForFiles = exports.initLocalCache = exports.performanceAnalyticsDecorator = exports.asyncPerformanceAnalyticsDecorator = void 0;
651
638
  const file_parser_1 = __webpack_require__(2314);
652
639
  const file_scanner_1 = __webpack_require__(16879);
653
- const results_formatter_1 = __webpack_require__(98425);
640
+ const results_formatter_1 = __webpack_require__(95067);
654
641
  const usage_tracking_1 = __webpack_require__(43156);
655
642
  const local_cache_1 = __webpack_require__(6255);
656
643
  const apply_custom_severities_1 = __webpack_require__(91470);
@@ -1013,7 +1000,38 @@ exports.FailedToExtractResourcesInTerraformPlanError = FailedToExtractResourcesI
1013
1000
 
1014
1001
  /***/ }),
1015
1002
 
1016
- /***/ 25476:
1003
+ /***/ 59964:
1004
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1005
+
1006
+ "use strict";
1007
+
1008
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
1009
+ exports.processResults = void 0;
1010
+ const policy_1 = __webpack_require__(37457);
1011
+ const share_results_1 = __webpack_require__(45888);
1012
+ const measurable_methods_1 = __webpack_require__(78272);
1013
+ async function processResults(resultsWithCustomSeverities, orgPublicId, iacOrgSettings, policy, tags, attributes, options) {
1014
+ let projectPublicIds = {};
1015
+ let gitRemoteUrl;
1016
+ if (options.report) {
1017
+ ({ projectPublicIds, gitRemoteUrl } = await share_results_1.formatAndShareResults({
1018
+ results: resultsWithCustomSeverities,
1019
+ options,
1020
+ orgPublicId,
1021
+ policy,
1022
+ tags,
1023
+ attributes,
1024
+ }));
1025
+ }
1026
+ const formattedResults = measurable_methods_1.formatScanResults(resultsWithCustomSeverities, options, iacOrgSettings.meta, projectPublicIds, gitRemoteUrl);
1027
+ return policy_1.filterIgnoredIssues(policy, formattedResults);
1028
+ }
1029
+ exports.processResults = processResults;
1030
+
1031
+
1032
+ /***/ }),
1033
+
1034
+ /***/ 37457:
1017
1035
  /***/ ((__unused_webpack_module, exports) => {
1018
1036
 
1019
1037
  "use strict";
@@ -1079,7 +1097,7 @@ function toFormattedResult(adapter) {
1079
1097
 
1080
1098
  /***/ }),
1081
1099
 
1082
- /***/ 98425:
1100
+ /***/ 95067:
1083
1101
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1084
1102
 
1085
1103
  "use strict";
@@ -1211,6 +1229,78 @@ class FailedToFormatResults extends errors_1.CustomError {
1211
1229
  exports.FailedToFormatResults = FailedToFormatResults;
1212
1230
 
1213
1231
 
1232
+ /***/ }),
1233
+
1234
+ /***/ 44554:
1235
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1236
+
1237
+ "use strict";
1238
+
1239
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
1240
+ exports.formatShareResults = void 0;
1241
+ const file_utils_1 = __webpack_require__(58486);
1242
+ function formatShareResults(scanResults, options) {
1243
+ const resultsGroupedByFilePath = groupByFilePath(scanResults);
1244
+ return resultsGroupedByFilePath.map((result) => {
1245
+ const { projectName, targetFile } = file_utils_1.computePaths(result.filePath, options.path);
1246
+ return {
1247
+ projectName,
1248
+ targetFile,
1249
+ filePath: result.filePath,
1250
+ fileType: result.fileType,
1251
+ projectType: result.projectType,
1252
+ violatedPolicies: result.violatedPolicies,
1253
+ };
1254
+ });
1255
+ }
1256
+ exports.formatShareResults = formatShareResults;
1257
+ function groupByFilePath(scanResults) {
1258
+ const groupedByFilePath = scanResults.reduce((memo, scanResult) => {
1259
+ scanResult.violatedPolicies.forEach((violatedPolicy) => {
1260
+ violatedPolicy.docId = scanResult.docId;
1261
+ });
1262
+ if (memo[scanResult.filePath]) {
1263
+ memo[scanResult.filePath].violatedPolicies.push(...scanResult.violatedPolicies);
1264
+ }
1265
+ else {
1266
+ memo[scanResult.filePath] = scanResult;
1267
+ }
1268
+ return memo;
1269
+ }, {});
1270
+ return Object.values(groupedByFilePath);
1271
+ }
1272
+
1273
+
1274
+ /***/ }),
1275
+
1276
+ /***/ 45888:
1277
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1278
+
1279
+ "use strict";
1280
+
1281
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
1282
+ exports.formatAndShareResults = void 0;
1283
+ const feature_flags_1 = __webpack_require__(63011);
1284
+ const cli_share_results_1 = __webpack_require__(24016);
1285
+ const assert_iac_options_flag_1 = __webpack_require__(68590);
1286
+ const share_results_formatter_1 = __webpack_require__(44554);
1287
+ async function formatAndShareResults({ results, options, orgPublicId, policy, tags, attributes, }) {
1288
+ const isCliReportEnabled = await feature_flags_1.isFeatureFlagSupportedForOrg('iacCliShareResults', orgPublicId);
1289
+ if (!isCliReportEnabled.ok) {
1290
+ throw new assert_iac_options_flag_1.FeatureFlagError('report', 'iacCliShareResults');
1291
+ }
1292
+ const formattedResults = share_results_formatter_1.formatShareResults(results, options);
1293
+ return await cli_share_results_1.shareResults({
1294
+ results: formattedResults,
1295
+ policy,
1296
+ tags,
1297
+ attributes,
1298
+ options,
1299
+ });
1300
+ }
1301
+ exports.formatAndShareResults = formatAndShareResults;
1302
+
1303
+
1214
1304
  /***/ }),
1215
1305
 
1216
1306
  /***/ 98895:
@@ -1375,78 +1465,6 @@ class FailedToExecuteCustomRulesError extends errors_1.CustomError {
1375
1465
  exports.FailedToExecuteCustomRulesError = FailedToExecuteCustomRulesError;
1376
1466
 
1377
1467
 
1378
- /***/ }),
1379
-
1380
- /***/ 37324:
1381
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1382
-
1383
- "use strict";
1384
-
1385
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1386
- exports.formatShareResults = void 0;
1387
- const file_utils_1 = __webpack_require__(58486);
1388
- function formatShareResults(scanResults, options) {
1389
- const resultsGroupedByFilePath = groupByFilePath(scanResults);
1390
- return resultsGroupedByFilePath.map((result) => {
1391
- const { projectName, targetFile } = file_utils_1.computePaths(result.filePath, options.path);
1392
- return {
1393
- projectName,
1394
- targetFile,
1395
- filePath: result.filePath,
1396
- fileType: result.fileType,
1397
- projectType: result.projectType,
1398
- violatedPolicies: result.violatedPolicies,
1399
- };
1400
- });
1401
- }
1402
- exports.formatShareResults = formatShareResults;
1403
- function groupByFilePath(scanResults) {
1404
- const groupedByFilePath = scanResults.reduce((memo, scanResult) => {
1405
- scanResult.violatedPolicies.forEach((violatedPolicy) => {
1406
- violatedPolicy.docId = scanResult.docId;
1407
- });
1408
- if (memo[scanResult.filePath]) {
1409
- memo[scanResult.filePath].violatedPolicies.push(...scanResult.violatedPolicies);
1410
- }
1411
- else {
1412
- memo[scanResult.filePath] = scanResult;
1413
- }
1414
- return memo;
1415
- }, {});
1416
- return Object.values(groupedByFilePath);
1417
- }
1418
-
1419
-
1420
- /***/ }),
1421
-
1422
- /***/ 3558:
1423
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1424
-
1425
- "use strict";
1426
-
1427
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1428
- exports.formatAndShareResults = void 0;
1429
- const feature_flags_1 = __webpack_require__(63011);
1430
- const cli_share_results_1 = __webpack_require__(24016);
1431
- const assert_iac_options_flag_1 = __webpack_require__(68590);
1432
- const share_results_formatter_1 = __webpack_require__(37324);
1433
- async function formatAndShareResults({ results, options, orgPublicId, policy, tags, attributes, }) {
1434
- const isCliReportEnabled = await feature_flags_1.isFeatureFlagSupportedForOrg('iacCliShareResults', orgPublicId);
1435
- if (!isCliReportEnabled.ok) {
1436
- throw new assert_iac_options_flag_1.FeatureFlagError('report', 'iacCliShareResults');
1437
- }
1438
- const formattedResults = share_results_formatter_1.formatShareResults(results, options);
1439
- return await cli_share_results_1.shareResults({
1440
- results: formattedResults,
1441
- policy,
1442
- tags,
1443
- attributes,
1444
- options,
1445
- });
1446
- }
1447
- exports.formatAndShareResults = formatAndShareResults;
1448
-
1449
-
1450
1468
  /***/ }),
1451
1469
 
1452
1470
  /***/ 80256:
@@ -1635,6 +1653,13 @@ async function test(...args) {
1635
1653
  // Holds an array of scanned file metadata for output.
1636
1654
  let iacScanFailures;
1637
1655
  let iacOutputMeta;
1656
+ const isNewIacOutputSupported = options.iac
1657
+ ? await feature_flags_1.hasFeatureFlag('iacCliOutput', options)
1658
+ : false;
1659
+ if (shouldPrintIacInitialMessage(options, isNewIacOutputSupported)) {
1660
+ console.log(os_1.EOL +
1661
+ chalk_1.default.white.bold('Snyk testing Infrastructure as Code configuration issues...'));
1662
+ }
1638
1663
  // Promise waterfall to test all other paths sequentially
1639
1664
  for (const path of paths) {
1640
1665
  // Create a copy of the options so a specific test can
@@ -1730,9 +1755,6 @@ async function test(...args) {
1730
1755
  err.sarifStringifiedResults = stringifiedSarifData;
1731
1756
  throw err;
1732
1757
  }
1733
- const isNewIacOutputSupported = options.iac
1734
- ? await feature_flags_1.hasFeatureFlag('iacCliOutput', options)
1735
- : false;
1736
1758
  let response = results
1737
1759
  .map((result, i) => {
1738
1760
  return display_result_1.displayResult(results[i], {
@@ -1829,6 +1851,9 @@ function shouldFail(vulnerableResults, failOn) {
1829
1851
  // should fail by default when there are vulnerable results
1830
1852
  return vulnerableResults.length > 0;
1831
1853
  }
1854
+ function shouldPrintIacInitialMessage(options, iacCliOutputFeatureFlag) {
1855
+ return !options.json && !options.sarif && iacCliOutputFeatureFlag;
1856
+ }
1832
1857
 
1833
1858
 
1834
1859
  /***/ }),