snyk 1.902.0 → 1.905.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.
Files changed (68) hide show
  1. package/dist/cli/450.index.js +2 -2
  2. package/dist/cli/450.index.js.map +1 -1
  3. package/dist/cli/{716.index.js → 519.index.js} +21 -49
  4. package/dist/cli/519.index.js.map +1 -0
  5. package/dist/cli/784.index.js +81 -57
  6. package/dist/cli/784.index.js.map +1 -1
  7. package/dist/cli/874.index.js +3 -3
  8. package/dist/cli/874.index.js.map +1 -1
  9. package/dist/cli/{459.index.js → 895.index.js} +13 -13
  10. package/dist/cli/895.index.js.map +1 -0
  11. package/dist/cli/917.index.js +486 -204
  12. package/dist/cli/917.index.js.map +1 -1
  13. package/dist/cli/99.index.js +2 -2
  14. package/dist/cli/99.index.js.map +1 -1
  15. package/dist/cli/commands/test/iac/index.d.ts +3 -0
  16. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/analytics.d.ts +1 -1
  17. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/assert-iac-options-flag.d.ts +1 -1
  18. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/directory-loader.d.ts +0 -0
  19. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/error-utils.d.ts +0 -0
  20. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/file-loader.d.ts +1 -1
  21. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/file-parser.d.ts +1 -1
  22. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/file-scanner.d.ts +1 -1
  23. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/file-utils.d.ts +0 -5
  24. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/index.d.ts +1 -1
  25. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/local-cache.d.ts +1 -1
  26. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/math-utils.d.ts +0 -0
  27. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/measurable-methods.d.ts +0 -0
  28. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/oci-pull.d.ts +1 -1
  29. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/org-settings/apply-custom-severities.d.ts +0 -0
  30. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/org-settings/get-iac-org-settings.d.ts +1 -1
  31. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/parsers/config-type-detection.d.ts +0 -0
  32. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/parsers/hcl-to-json/index.d.ts +0 -0
  33. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/parsers/hcl-to-json-v2/index.d.ts +0 -0
  34. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/parsers/terraform-file-parser.d.ts +1 -1
  35. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/parsers/terraform-plan-parser.d.ts +1 -1
  36. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution/process-results}/extract-line-number.d.ts +0 -0
  37. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/process-results/index.d.ts +2 -2
  38. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/process-results/policy.d.ts +1 -1
  39. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/process-results/results-formatter.d.ts +2 -2
  40. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/process-results/share-results-formatter.d.ts +0 -0
  41. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/process-results/share-results.d.ts +2 -2
  42. package/dist/cli/commands/test/iac/local-execution/process-results/utils.d.ts +5 -0
  43. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/rules.d.ts +1 -1
  44. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/types.d.ts +5 -15
  45. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/url-utils.d.ts +0 -0
  46. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/usage-tracking.d.ts +1 -1
  47. package/dist/cli/commands/test/{iac-local-execution → iac/local-execution}/yaml-parser.d.ts +1 -1
  48. package/dist/cli/index.js +8 -8
  49. package/dist/cli/index.js.map +1 -1
  50. package/dist/lib/formatters/iac-output/index.d.ts +2 -4
  51. package/dist/lib/formatters/iac-output/v2/formatters.d.ts +4 -0
  52. package/dist/lib/formatters/iac-output/v2/index.d.ts +1 -2
  53. package/dist/lib/formatters/iac-output/v2/issues-list.d.ts +3 -0
  54. package/dist/lib/formatters/iac-output/v2/types.d.ts +16 -0
  55. package/dist/lib/formatters/test/display-result.d.ts +1 -5
  56. package/dist/lib/iac/cli-share-results.d.ts +1 -1
  57. package/dist/lib/iac/envelope-formatters.d.ts +1 -1
  58. package/help/cli-commands/config.md +1 -1
  59. package/help/cli-commands/container.md +10 -8
  60. package/help/cli-commands/iac-describe.md +8 -6
  61. package/help/cli-commands/iac-test.md +14 -6
  62. package/help/cli-commands/ignore.md +2 -2
  63. package/help/cli-commands/log4shell.md +4 -2
  64. package/help/cli-commands/monitor.md +20 -12
  65. package/help/cli-commands/test.md +19 -11
  66. package/package.json +1 -1
  67. package/dist/cli/459.index.js.map +0 -1
  68. package/dist/cli/716.index.js.map +0 -1
@@ -10,8 +10,8 @@ exports.modules = {
10
10
  Object.defineProperty(exports, "__esModule", ({ value: true }));
11
11
  exports.UnsupportedReportCommandError = void 0;
12
12
  const errors_1 = __webpack_require__(55191);
13
- const error_utils_1 = __webpack_require__(23872);
14
- const types_1 = __webpack_require__(42258);
13
+ const error_utils_1 = __webpack_require__(36401);
14
+ const types_1 = __webpack_require__(94820);
15
15
  class UnsupportedReportCommandError extends errors_1.CustomError {
16
16
  constructor(message) {
17
17
  super(message || 'Command "report" is only supported for IaC');
@@ -1 +1 @@
1
- {"version":3,"file":"450.index.js","mappings":";;;;;;;;;;;AAAA,4CAAqD;AACrD,iDAAgF;AAChF,2CAAqE;AAErE,MAAa,6BAA8B,SAAQ,oBAAW;IAC5D,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,IAAI,4CAA4C,CAAC,CAAC;QAC/D,IAAI,CAAC,IAAI,GAAG,qBAAa,CAAC,6BAA6B,CAAC;QACxD,IAAI,CAAC,OAAO,GAAG,gCAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,WAAW;YACd,wEAAwE,CAAC;IAC7E,CAAC;CACF;AARD,sEAQC;;;;;;;;;;ACTD,0CAA2B;AAC3B,mDAA4D;AAE5D,4CAAkE;AAClE,0DAA6D;AAC7D,gEAAoF;AAErE,KAAK,UAAU,MAAM,CAClC,GAAG,IAAgB;IAEnB,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,yCAAkB,CAAC,GAAG,IAAI,CAAC,CAAC;IAEvD,IAAI,OAAO,CAAC,GAAG,IAAI,IAAI,EAAE;QACvB,MAAM,IAAI,0DAA6B,EAAE,CAAC;KAC3C;IAED,MAAM,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAErC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAEtB,OAAO,MAAM,cAAI,CAAC,GAAG,KAAK,EAAE,OAAO,CAAC,CAAC;AACvC,CAAC;AAdD,yBAcC;AAED,KAAK,UAAU,qBAAqB,CAAC,OAAqB;IACxD,MAAM,iBAAiB,GAAG,MAAM,8BAAc,CAC5C,oBAAoB,EACpB,OAAkB,CACnB,CAAC;IACF,IAAI,CAAC,iBAAiB,EAAE;QACtB,MAAM,IAAI,oCAA2B,CAAC,oBAAoB,CAAC,CAAC;KAC7D;AACH,CAAC","sources":["webpack://snyk/./src/cli/commands/report/errors/unsupported-report-command.ts","webpack://snyk/./src/cli/commands/report/index.ts"],"sourcesContent":["import { CustomError } from '../../../../lib/errors';\nimport { getErrorStringCode } from '../../test/iac-local-execution/error-utils';\nimport { IaCErrorCodes } from '../../test/iac-local-execution/types';\n\nexport class UnsupportedReportCommandError extends CustomError {\n constructor(message?: string) {\n super(message || 'Command \"report\" is only supported for IaC');\n this.code = IaCErrorCodes.UnsupportedReportCommandError;\n this.strCode = getErrorStringCode(this.code);\n this.userMessage =\n '\"report\" is not a supported command. Did you mean to use \"iac report\"?';\n }\n}\n","import { MethodArgs } from '../../args';\nimport { IaCTestFlags } from '../test/iac-local-execution/types';\nimport { TestCommandResult } from '../types';\nimport test from '../test';\nimport { hasFeatureFlag } from '../../../lib/feature-flags';\nimport { Options } from '../../../lib/types';\nimport { UnsupportedFeatureFlagError } from '../../../lib/errors';\nimport { processCommandArgs } from '../process-command-args';\nimport { UnsupportedReportCommandError } from './errors/unsupported-report-command';\n\nexport default async function report(\n ...args: MethodArgs\n): Promise<TestCommandResult> {\n const { paths, options } = processCommandArgs(...args);\n\n if (options.iac != true) {\n throw new UnsupportedReportCommandError();\n }\n\n await assertReportSupported(options);\n\n options.report = true;\n\n return await test(...paths, options);\n}\n\nasync function assertReportSupported(options: IaCTestFlags) {\n const isReportSupported = await hasFeatureFlag(\n 'iacCliShareResults',\n options as Options,\n );\n if (!isReportSupported) {\n throw new UnsupportedFeatureFlagError('iacCliShareResults');\n }\n}\n"],"names":[],"sourceRoot":""}
1
+ {"version":3,"file":"450.index.js","mappings":";;;;;;;;;;;AAAA,4CAAqD;AACrD,iDAAgF;AAChF,2CAAqE;AAErE,MAAa,6BAA8B,SAAQ,oBAAW;IAC5D,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,IAAI,4CAA4C,CAAC,CAAC;QAC/D,IAAI,CAAC,IAAI,GAAG,qBAAa,CAAC,6BAA6B,CAAC;QACxD,IAAI,CAAC,OAAO,GAAG,gCAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,WAAW;YACd,wEAAwE,CAAC;IAC7E,CAAC;CACF;AARD,sEAQC;;;;;;;;;;ACTD,0CAA2B;AAC3B,mDAA4D;AAE5D,4CAAkE;AAClE,0DAA6D;AAC7D,gEAAoF;AAErE,KAAK,UAAU,MAAM,CAClC,GAAG,IAAgB;IAEnB,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,yCAAkB,CAAC,GAAG,IAAI,CAAC,CAAC;IAEvD,IAAI,OAAO,CAAC,GAAG,IAAI,IAAI,EAAE;QACvB,MAAM,IAAI,0DAA6B,EAAE,CAAC;KAC3C;IAED,MAAM,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAErC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAEtB,OAAO,MAAM,cAAI,CAAC,GAAG,KAAK,EAAE,OAAO,CAAC,CAAC;AACvC,CAAC;AAdD,yBAcC;AAED,KAAK,UAAU,qBAAqB,CAAC,OAAqB;IACxD,MAAM,iBAAiB,GAAG,MAAM,8BAAc,CAC5C,oBAAoB,EACpB,OAAkB,CACnB,CAAC;IACF,IAAI,CAAC,iBAAiB,EAAE;QACtB,MAAM,IAAI,oCAA2B,CAAC,oBAAoB,CAAC,CAAC;KAC7D;AACH,CAAC","sources":["webpack://snyk/./src/cli/commands/report/errors/unsupported-report-command.ts","webpack://snyk/./src/cli/commands/report/index.ts"],"sourcesContent":["import { CustomError } from '../../../../lib/errors';\nimport { getErrorStringCode } from '../../test/iac/local-execution/error-utils';\nimport { IaCErrorCodes } from '../../test/iac/local-execution/types';\n\nexport class UnsupportedReportCommandError extends CustomError {\n constructor(message?: string) {\n super(message || 'Command \"report\" is only supported for IaC');\n this.code = IaCErrorCodes.UnsupportedReportCommandError;\n this.strCode = getErrorStringCode(this.code);\n this.userMessage =\n '\"report\" is not a supported command. Did you mean to use \"iac report\"?';\n }\n}\n","import { MethodArgs } from '../../args';\nimport { IaCTestFlags } from '../test/iac/local-execution/types';\nimport { TestCommandResult } from '../types';\nimport test from '../test';\nimport { hasFeatureFlag } from '../../../lib/feature-flags';\nimport { Options } from '../../../lib/types';\nimport { UnsupportedFeatureFlagError } from '../../../lib/errors';\nimport { processCommandArgs } from '../process-command-args';\nimport { UnsupportedReportCommandError } from './errors/unsupported-report-command';\n\nexport default async function report(\n ...args: MethodArgs\n): Promise<TestCommandResult> {\n const { paths, options } = processCommandArgs(...args);\n\n if (options.iac != true) {\n throw new UnsupportedReportCommandError();\n }\n\n await assertReportSupported(options);\n\n options.report = true;\n\n return await test(...paths, options);\n}\n\nasync function assertReportSupported(options: IaCTestFlags) {\n const isReportSupported = await hasFeatureFlag(\n 'iacCliShareResults',\n options as Options,\n );\n if (!isReportSupported) {\n throw new UnsupportedFeatureFlagError('iacCliShareResults');\n }\n}\n"],"names":[],"sourceRoot":""}
@@ -1,18 +1,18 @@
1
1
  "use strict";
2
- exports.id = 716;
3
- exports.ids = [716];
2
+ exports.id = 519;
3
+ exports.ids = [519];
4
4
  exports.modules = {
5
5
 
6
- /***/ 22716:
6
+ /***/ 41519:
7
7
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
8
8
 
9
9
 
10
10
  Object.defineProperty(exports, "__esModule", ({ value: true }));
11
11
  exports.addIacDriftAnalytics = exports.performanceAnalyticsObject = exports.addIacAnalytics = void 0;
12
- const types_1 = __webpack_require__(42258);
12
+ const types_1 = __webpack_require__(94820);
13
13
  const analytics = __webpack_require__(82744);
14
- const math_utils_1 = __webpack_require__(48537);
15
- const file_utils_1 = __webpack_require__(58486);
14
+ const math_utils_1 = __webpack_require__(42095);
15
+ const file_utils_1 = __webpack_require__(45281);
16
16
  const drift_1 = __webpack_require__(26445);
17
17
  function addIacAnalytics(formattedResults, opts) {
18
18
  let totalIssuesCount = 0;
@@ -93,19 +93,18 @@ exports.addIacDriftAnalytics = addIacDriftAnalytics;
93
93
 
94
94
  /***/ }),
95
95
 
96
- /***/ 58486:
96
+ /***/ 45281:
97
97
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
98
98
 
99
99
 
100
100
  Object.defineProperty(exports, "__esModule", ({ value: true }));
101
- exports.makeFileAndDirectoryGenerator = exports.computePaths = exports.computeCustomRulesBundleChecksum = exports.isValidBundle = exports.extractBundle = exports.createIacDir = void 0;
101
+ exports.makeFileAndDirectoryGenerator = exports.computeCustomRulesBundleChecksum = exports.isValidBundle = exports.extractBundle = exports.createIacDir = void 0;
102
102
  const fs = __webpack_require__(35747);
103
103
  const tar = __webpack_require__(97998);
104
104
  const path = __webpack_require__(85622);
105
105
  const crypto = __webpack_require__(76417);
106
- const local_cache_1 = __webpack_require__(6255);
107
- const oci_pull_1 = __webpack_require__(5029);
108
- const detect_1 = __webpack_require__(45318);
106
+ const local_cache_1 = __webpack_require__(50089);
107
+ const oci_pull_1 = __webpack_require__(584);
109
108
  const fs_1 = __webpack_require__(35747);
110
109
  const path_1 = __webpack_require__(85622);
111
110
  function hashData(s) {
@@ -166,33 +165,6 @@ function computeCustomRulesBundleChecksum() {
166
165
  }
167
166
  }
168
167
  exports.computeCustomRulesBundleChecksum = computeCustomRulesBundleChecksum;
169
- function computePaths(filePath, pathArg = '.') {
170
- const targetFilePath = path.resolve(filePath, '.');
171
- // the absolute path is needed to compute the full project path
172
- const cmdPath = path.resolve(pathArg);
173
- let projectPath;
174
- let targetFile;
175
- if (!detect_1.isLocalFolder(cmdPath)) {
176
- // if the provided path points to a file, then the project starts at the parent folder of that file
177
- // and the target file was provided as the path argument
178
- projectPath = path.dirname(cmdPath);
179
- targetFile = path.isAbsolute(pathArg)
180
- ? path.relative(process.cwd(), pathArg)
181
- : pathArg;
182
- }
183
- else {
184
- // otherwise, the project starts at the provided path
185
- // and the target file must be the relative path from the project path to the path of the scanned file
186
- projectPath = cmdPath;
187
- targetFile = path.relative(projectPath, targetFilePath);
188
- }
189
- return {
190
- targetFilePath,
191
- projectName: path.basename(projectPath),
192
- targetFile,
193
- };
194
- }
195
- exports.computePaths = computePaths;
196
168
  /**
197
169
  * makeFileAndDirectoryGenerator is a generator function that helps walking the directory and file structure of this pathToScan
198
170
  * @param root
@@ -229,7 +201,7 @@ exports.makeFileAndDirectoryGenerator = makeFileAndDirectoryGenerator;
229
201
 
230
202
  /***/ }),
231
203
 
232
- /***/ 6255:
204
+ /***/ 50089:
233
205
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
234
206
 
235
207
 
@@ -237,14 +209,14 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
237
209
  exports.InvalidCustomRulesPath = exports.InvalidCustomRules = exports.FailedToExtractCustomRulesError = exports.FailedToDownloadRulesError = exports.FailedToInitLocalCacheError = exports.cleanLocalCache = exports.initLocalCache = exports.getLocalCachePath = exports.assertNever = exports.CUSTOM_POLICY_ENGINE_WASM_PATH = exports.LOCAL_POLICY_ENGINE_DIR = void 0;
238
210
  const path = __webpack_require__(85622);
239
211
  const fs = __webpack_require__(35747);
240
- const types_1 = __webpack_require__(42258);
212
+ const types_1 = __webpack_require__(94820);
241
213
  const needle = __webpack_require__(64484);
242
214
  const rimraf = __webpack_require__(50984);
243
- const file_utils_1 = __webpack_require__(58486);
215
+ const file_utils_1 = __webpack_require__(45281);
244
216
  const Debug = __webpack_require__(15158);
245
217
  const errors_1 = __webpack_require__(55191);
246
218
  const analytics = __webpack_require__(82744);
247
- const error_utils_1 = __webpack_require__(23872);
219
+ const error_utils_1 = __webpack_require__(36401);
248
220
  const debug = Debug('iac-local-cache');
249
221
  exports.LOCAL_POLICY_ENGINE_DIR = '.iac-data';
250
222
  const KUBERNETES_POLICY_ENGINE_WASM_PATH = path.join(exports.LOCAL_POLICY_ENGINE_DIR, 'k8s_policy.wasm');
@@ -404,7 +376,7 @@ class FailedToCleanLocalCacheError extends errors_1.CustomError {
404
376
 
405
377
  /***/ }),
406
378
 
407
- /***/ 48537:
379
+ /***/ 42095:
408
380
  /***/ ((__unused_webpack_module, exports) => {
409
381
 
410
382
 
@@ -421,7 +393,7 @@ exports.calculatePercentage = (relativeValue, totalValue) => +(totalValue ? (rel
421
393
 
422
394
  /***/ }),
423
395
 
424
- /***/ 5029:
396
+ /***/ 584:
425
397
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
426
398
 
427
399
 
@@ -430,12 +402,12 @@ exports.UnsupportedEntitlementPullError = exports.InvalidRemoteRegistryURLError
430
402
  const registryClient = __webpack_require__(28310);
431
403
  const fs_1 = __webpack_require__(35747);
432
404
  const path = __webpack_require__(85622);
433
- const types_1 = __webpack_require__(42258);
405
+ const types_1 = __webpack_require__(94820);
434
406
  const errors_1 = __webpack_require__(55191);
435
- const error_utils_1 = __webpack_require__(23872);
436
- const local_cache_1 = __webpack_require__(6255);
407
+ const error_utils_1 = __webpack_require__(36401);
408
+ const local_cache_1 = __webpack_require__(50089);
437
409
  const Debug = __webpack_require__(15158);
438
- const file_utils_1 = __webpack_require__(58486);
410
+ const file_utils_1 = __webpack_require__(45281);
439
411
  const debug = Debug('iac-oci-pull');
440
412
  exports.CUSTOM_RULES_TARBALL = 'custom-bundle.tar.gz';
441
413
  function extractOCIRegistryURLComponents(OCIRegistryURL) {
@@ -538,4 +510,4 @@ exports.UnsupportedEntitlementPullError = UnsupportedEntitlementPullError;
538
510
 
539
511
  };
540
512
  ;
541
- //# sourceMappingURL=716.index.js.map
513
+ //# sourceMappingURL=519.index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"519.index.js","mappings":";;;;;;;;;;;AAAA,2CAAgF;AAChF,6CAA0D;AAC1D,gDAAmD;AACnD,gDAAgE;AAEhE,2CAA+D;AAE/D,SAAgB,eAAe,CAC7B,gBAAmC,EACnC,IAGC;IAED,IAAI,gBAAgB,GAAG,CAAC,CAAC;IACzB,MAAM,2BAA2B,GAAqC,EAAE,CAAC;IACzE,IAAI,0BAA0B,GAAG,CAAC,CAAC;IACnC,MAAM,oBAAoB,GAA2B,EAAE,CAAC;IACxD,MAAM,eAAe,GAAG,KAAK,EAAU,CAAC;IAExC,gBAAgB,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;;QAC/B,gBAAgB;YACd,CAAC,gBAAgB,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC;QAEjE,MAAM,WAAW,GAAG,GAAG,CAAC,cAAc,CAAC;QACvC,eAAe,CAAC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/test/iac/local-execution/analytics.ts","webpack://snyk/./src/cli/commands/test/iac/local-execution/file-utils.ts","webpack://snyk/./src/cli/commands/test/iac/local-execution/local-cache.ts","webpack://snyk/./src/cli/commands/test/iac/local-execution/math-utils.ts","webpack://snyk/./src/cli/commands/test/iac/local-execution/oci-pull.ts"],"sourcesContent":["import { FormattedResult, PerformanceAnalyticsKey, RulesOrigin } from './types';\nimport * as analytics from '../../../../../lib/analytics';\nimport { calculatePercentage } from './math-utils';\nimport { computeCustomRulesBundleChecksum } from './file-utils';\nimport { DescribeOptions, DriftAnalysis } from '../../../../../lib/iac/types';\nimport { driftctlVersion } from '../../../../../lib/iac/drift';\n\nexport function addIacAnalytics(\n formattedResults: FormattedResult[],\n opts: {\n ignoredIssuesCount: number;\n rulesOrigin: RulesOrigin;\n },\n): void {\n let totalIssuesCount = 0;\n const customRulesIdsFoundInIssues: { [customRuleId: string]: true } = {};\n let issuesFromCustomRulesCount = 0;\n const projectTypeAnalytics: Record<string, object> = {};\n const packageManagers = Array<string>();\n\n formattedResults.forEach((res) => {\n totalIssuesCount =\n (totalIssuesCount || 0) + res.result.cloudConfigResults.length;\n\n const projectType = res.packageManager;\n packageManagers.push(projectType);\n projectTypeAnalytics[projectType] = projectTypeAnalytics[projectType] ?? {\n count: 0,\n };\n projectTypeAnalytics[projectType]['count']++;\n\n res.result.cloudConfigResults.forEach((policy) => {\n projectTypeAnalytics[projectType][policy.severity] =\n (projectTypeAnalytics[projectType][policy.severity] || 0) + 1;\n\n if (policy.isGeneratedByCustomRule) {\n issuesFromCustomRulesCount++;\n customRulesIdsFoundInIssues[policy.publicId] = true;\n }\n });\n });\n\n const uniqueCustomRulesCount: number = Object.keys(\n customRulesIdsFoundInIssues,\n ).length;\n\n analytics.add('packageManager', Array.from(new Set(packageManagers)));\n analytics.add('iac-issues-count', totalIssuesCount);\n analytics.add('iac-ignored-issues-count', opts.ignoredIssuesCount);\n analytics.add('iac-type', projectTypeAnalytics);\n analytics.add('iac-metrics', performanceAnalyticsObject);\n analytics.add('iac-test-count', formattedResults.length); // TODO: remove this once we all analytics use iac-files-count\n analytics.add('iac-files-count', formattedResults.length);\n analytics.add(\n 'iac-local-custom-rules',\n opts.rulesOrigin === RulesOrigin.Local,\n );\n analytics.add(\n 'iac-remote-custom-rules',\n opts.rulesOrigin === RulesOrigin.Remote,\n );\n analytics.add('iac-custom-rules-issues-count', issuesFromCustomRulesCount);\n analytics.add(\n 'iac-custom-rules-issues-percentage',\n calculatePercentage(issuesFromCustomRulesCount, totalIssuesCount),\n );\n analytics.add(\n 'iac-custom-rules-checksum',\n computeCustomRulesBundleChecksum(),\n );\n analytics.add('iac-custom-rules-coverage-count', uniqueCustomRulesCount);\n}\n\nexport const performanceAnalyticsObject: Record<\n PerformanceAnalyticsKey,\n number | null\n> = {\n [PerformanceAnalyticsKey.InitLocalCache]: null,\n [PerformanceAnalyticsKey.FileLoading]: null,\n [PerformanceAnalyticsKey.FileParsing]: null,\n [PerformanceAnalyticsKey.FileScanning]: null,\n [PerformanceAnalyticsKey.OrgSettings]: null,\n [PerformanceAnalyticsKey.CustomSeverities]: null,\n [PerformanceAnalyticsKey.ResultFormatting]: null,\n [PerformanceAnalyticsKey.UsageTracking]: null,\n [PerformanceAnalyticsKey.CacheCleanup]: null,\n [PerformanceAnalyticsKey.Total]: null,\n};\n\nexport function addIacDriftAnalytics(\n analysis: DriftAnalysis,\n options: DescribeOptions,\n): void {\n analytics.add('iac-drift-coverage', analysis.coverage);\n analytics.add('iac-drift-total-resources', analysis.summary.total_resources);\n analytics.add('iac-drift-total-unmanaged', analysis.summary.total_unmanaged);\n analytics.add('iac-drift-total-managed', analysis.summary.total_managed);\n analytics.add('iac-drift-total-missing', analysis.summary.total_missing);\n analytics.add('iac-drift-total-changed', analysis.summary.total_changed);\n analytics.add(\n 'iac-drift-iac-source-count',\n analysis.summary.total_iac_source_count,\n );\n analytics.add('iac-drift-provider-name', analysis.provider_name);\n analytics.add('iac-drift-provider-version', analysis.provider_version);\n analytics.add('iac-drift-version', driftctlVersion);\n analytics.add('iac-drift-scan-duration', analysis.scan_duration);\n\n let scope = 'all';\n if (options['only-managed']) {\n scope = 'managed';\n } else if (options['only-unmanaged']) {\n scope = 'unmanaged';\n }\n analytics.add('iac-drift-scan-scope', scope);\n}\n","import * as fs from 'fs';\nimport * as tar from 'tar';\nimport * as path from 'path';\nimport * as crypto from 'crypto';\nimport {\n FailedToInitLocalCacheError,\n LOCAL_POLICY_ENGINE_DIR,\n} from './local-cache';\nimport { CUSTOM_RULES_TARBALL } from './oci-pull';\nimport { readdirSync } from 'fs';\nimport { join } from 'path';\n\nfunction hashData(s: string): string {\n const hashedData = crypto\n .createHash('sha1')\n .update(s)\n .digest('hex');\n return hashedData;\n}\n\nexport function createIacDir(): void {\n // this path will be able to be customised by the user in the future\n const iacPath: fs.PathLike = path.join(LOCAL_POLICY_ENGINE_DIR);\n try {\n if (!fs.existsSync(iacPath)) {\n fs.mkdirSync(iacPath, '700');\n }\n fs.accessSync(iacPath, fs.constants.W_OK);\n } catch {\n throw new FailedToInitLocalCacheError();\n }\n}\n\nexport function extractBundle(response: NodeJS.ReadableStream): Promise<void> {\n return new Promise((resolve, reject) => {\n response\n .on('error', reject)\n .pipe(\n tar.x({\n C: path.join(LOCAL_POLICY_ENGINE_DIR),\n }),\n )\n .on('finish', resolve)\n .on('error', reject);\n });\n}\n\nexport function isValidBundle(wasmPath: string, dataPath: string): boolean {\n try {\n // verify that the correct files were generated, since this is user input\n return !(!fs.existsSync(wasmPath) || !fs.existsSync(dataPath));\n } catch {\n return false;\n }\n}\n\nexport function computeCustomRulesBundleChecksum(): string | undefined {\n try {\n const customRulesPolicyWasmPath = path.join(\n LOCAL_POLICY_ENGINE_DIR,\n CUSTOM_RULES_TARBALL,\n );\n // if bundle is not configured we don't want to include the checksum\n if (!fs.existsSync(customRulesPolicyWasmPath)) {\n return;\n }\n const policyWasm = fs.readFileSync(customRulesPolicyWasmPath, 'utf8');\n return hashData(policyWasm);\n } catch (err) {\n return;\n }\n}\n\n/**\n * makeFileAndDirectoryGenerator is a generator function that helps walking the directory and file structure of this pathToScan\n * @param root\n * @param maxDepth? - An optional `maxDepth` argument can be provided to limit how deep in the file tree the search will go.\n * @returns {Generator<object>} - a generator which yields an object with directories or paths for the path to scan\n */\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nexport function* makeFileAndDirectoryGenerator(root = '.', maxDepth?: number) {\n function* generatorHelper(pathToScan, currentDepth) {\n {\n yield { directory: pathToScan };\n }\n if (maxDepth !== currentDepth) {\n for (const dirent of readdirSync(pathToScan, { withFileTypes: true })) {\n if (\n dirent.isDirectory() &&\n fs.readdirSync(join(pathToScan, dirent.name)).length !== 0\n ) {\n yield* generatorHelper(\n join(pathToScan, dirent.name),\n currentDepth + 1,\n );\n } else if (dirent.isFile()) {\n yield {\n file: {\n dir: pathToScan,\n fileName: join(pathToScan, dirent.name),\n },\n };\n }\n }\n }\n }\n yield* generatorHelper(root, 0);\n}\n","import * as path from 'path';\nimport * as fs from 'fs';\nimport { EngineType, IaCErrorCodes } from './types';\nimport * as needle from 'needle';\nimport * as rimraf from 'rimraf';\nimport { createIacDir, extractBundle, isValidBundle } from './file-utils';\nimport * as Debug from 'debug';\nimport { CustomError } from '../../../../../lib/errors';\nimport * as analytics from '../../../../../lib/analytics';\nimport ReadableStream = NodeJS.ReadableStream;\nimport { getErrorStringCode } from './error-utils';\n\nconst debug = Debug('iac-local-cache');\n\nexport const LOCAL_POLICY_ENGINE_DIR = '.iac-data';\n\nconst KUBERNETES_POLICY_ENGINE_WASM_PATH = path.join(\n LOCAL_POLICY_ENGINE_DIR,\n 'k8s_policy.wasm',\n);\nconst KUBERNETES_POLICY_ENGINE_DATA_PATH = path.join(\n LOCAL_POLICY_ENGINE_DIR,\n 'k8s_data.json',\n);\nconst TERRAFORM_POLICY_ENGINE_WASM_PATH = path.join(\n LOCAL_POLICY_ENGINE_DIR,\n 'tf_policy.wasm',\n);\nconst TERRAFORM_POLICY_ENGINE_DATA_PATH = path.join(\n LOCAL_POLICY_ENGINE_DIR,\n 'tf_data.json',\n);\nconst CLOUDFORMATION_POLICY_ENGINE_WASM_PATH = path.join(\n LOCAL_POLICY_ENGINE_DIR,\n 'cloudformation_policy.wasm',\n);\nconst CLOUDFORMATION_POLICY_ENGINE_DATA_PATH = path.join(\n LOCAL_POLICY_ENGINE_DIR,\n 'cloudformation_data.json',\n);\nconst ARM_POLICY_ENGINE_WASM_PATH = path.join(\n LOCAL_POLICY_ENGINE_DIR,\n 'arm_policy.wasm',\n);\nconst ARM_POLICY_ENGINE_DATA_PATH = path.join(\n LOCAL_POLICY_ENGINE_DIR,\n 'arm_data.json',\n);\n\n// NOTE: The filenames used for the custom policy bundles match those output\n// by the `opa` CLI tool, which is why they are very generic.\nexport const CUSTOM_POLICY_ENGINE_WASM_PATH = path.join(\n LOCAL_POLICY_ENGINE_DIR,\n 'policy.wasm',\n);\nconst CUSTOM_POLICY_ENGINE_DATA_PATH = path.join(\n LOCAL_POLICY_ENGINE_DIR,\n 'data.json',\n);\n\nexport function assertNever(value: never): never {\n throw new Error(\n `Unhandled discriminated union member: ${JSON.stringify(value)}`,\n );\n}\n\nexport function getLocalCachePath(engineType: EngineType): string[] {\n switch (engineType) {\n case EngineType.Kubernetes:\n return [\n `${process.cwd()}/${KUBERNETES_POLICY_ENGINE_WASM_PATH}`,\n `${process.cwd()}/${KUBERNETES_POLICY_ENGINE_DATA_PATH}`,\n ];\n case EngineType.Terraform:\n return [\n `${process.cwd()}/${TERRAFORM_POLICY_ENGINE_WASM_PATH}`,\n `${process.cwd()}/${TERRAFORM_POLICY_ENGINE_DATA_PATH}`,\n ];\n case EngineType.CloudFormation:\n return [\n `${process.cwd()}/${CLOUDFORMATION_POLICY_ENGINE_WASM_PATH}`,\n `${process.cwd()}/${CLOUDFORMATION_POLICY_ENGINE_DATA_PATH}`,\n ];\n case EngineType.ARM:\n return [\n `${process.cwd()}/${ARM_POLICY_ENGINE_WASM_PATH}`,\n `${process.cwd()}/${ARM_POLICY_ENGINE_DATA_PATH}`,\n ];\n case EngineType.Custom:\n return [\n `${process.cwd()}/${CUSTOM_POLICY_ENGINE_WASM_PATH}`,\n `${process.cwd()}/${CUSTOM_POLICY_ENGINE_DATA_PATH}`,\n ];\n default:\n assertNever(engineType);\n }\n}\n\nexport async function initLocalCache({\n customRulesPath,\n}: { customRulesPath?: string } = {}): Promise<void> {\n try {\n createIacDir();\n } catch (e) {\n throw new FailedToInitLocalCacheError();\n }\n\n // Attempt to extract the custom rules from the path provided.\n if (customRulesPath) {\n if (!fs.existsSync(customRulesPath)) {\n throw new InvalidCustomRulesPath(customRulesPath);\n }\n\n try {\n const response = fs.createReadStream(customRulesPath);\n await extractBundle(response);\n } catch (e) {\n throw new FailedToExtractCustomRulesError(customRulesPath);\n }\n\n if (\n !isValidBundle(\n CUSTOM_POLICY_ENGINE_WASM_PATH,\n CUSTOM_POLICY_ENGINE_DATA_PATH,\n )\n ) {\n throw new InvalidCustomRules(customRulesPath);\n }\n }\n\n // We extract the Snyk rules after the custom rules to ensure our files\n // always overwrite whatever might be there.\n try {\n const BUNDLE_URL = 'https://static.snyk.io/cli/wasm/bundle.tar.gz';\n const response: ReadableStream = needle.get(BUNDLE_URL);\n await extractBundle(response);\n } catch (e) {\n throw new FailedToDownloadRulesError();\n }\n}\n\nexport function cleanLocalCache() {\n // path to delete is hardcoded for now\n const iacPath: fs.PathLike = path.join(\n `${process.cwd()}`,\n LOCAL_POLICY_ENGINE_DIR,\n );\n try {\n // when we support Node version >= 12.10.0 , we can replace rimraf\n // with the native fs.rmdirSync(path, {recursive: true})\n rimraf.sync(iacPath);\n } catch (e) {\n const err = new FailedToCleanLocalCacheError();\n analytics.add('error-code', err.code);\n debug('The local cache directory could not be deleted');\n }\n}\n\nexport class FailedToInitLocalCacheError extends CustomError {\n constructor(message?: string) {\n super(message || 'Failed to initialize local cache');\n this.code = IaCErrorCodes.FailedToInitLocalCacheError;\n this.strCode = getErrorStringCode(this.code);\n this.userMessage =\n 'We were unable to create a local directory to store the test assets, please ensure that the current working directory is writable';\n }\n}\n\nexport class FailedToDownloadRulesError extends CustomError {\n constructor(message?: string) {\n super(message || 'Failed to download policies');\n this.code = IaCErrorCodes.FailedToDownloadRulesError;\n this.strCode = getErrorStringCode(this.code);\n this.userMessage =\n 'We were unable to download the security rules, please ensure the network can access https://static.snyk.io';\n }\n}\n\nexport class FailedToExtractCustomRulesError extends CustomError {\n constructor(path: string, message?: string) {\n super(message || 'Failed to download policies');\n this.code = IaCErrorCodes.FailedToExtractCustomRulesError;\n this.strCode = getErrorStringCode(this.code);\n this.userMessage = `We were unable to extract the rules provided at: ${path}. The provided bundle may be corrupted or invalid. Please ensure it was generated using the 'snyk-iac-rules' SDK`;\n }\n}\n\nexport class InvalidCustomRules extends CustomError {\n constructor(path: string, message?: string) {\n super(message || 'Invalid custom rules bundle');\n this.code = IaCErrorCodes.InvalidCustomRules;\n this.strCode = getErrorStringCode(this.code);\n this.userMessage = `We were unable to extract the rules provided at: ${path}. The provided bundle does not match the required structure. Please ensure it was generated using the 'snyk-iac-rules' SDK`;\n }\n}\n\nexport class InvalidCustomRulesPath extends CustomError {\n constructor(path: string, message?: string) {\n super(message || 'Invalid path to custom rules bundle');\n this.code = IaCErrorCodes.InvalidCustomRulesPath;\n this.strCode = getErrorStringCode(this.code);\n this.userMessage = `We were unable to extract the rules provided at: ${path}. The bundle at the provided path does not exist`;\n }\n}\n\nclass FailedToCleanLocalCacheError extends CustomError {\n constructor(message?: string) {\n super(message || 'Failed to clean local cache');\n this.code = IaCErrorCodes.FailedToCleanLocalCacheError;\n this.strCode = getErrorStringCode(this.code);\n this.userMessage = ''; // Not a user facing error.\n }\n}\n","/**\n * Calculate percentage from relative and total amounts.\n * @param relativeValue The relative amount.\n * @param totalValue The total amount.\n * @returns The calculated precentage.\n */\nexport const calculatePercentage = (\n relativeValue: number,\n totalValue: number,\n): number => +(totalValue ? (relativeValue / totalValue) * 100 : 0).toFixed(2);\n","import * as registryClient from '@snyk/docker-registry-v2-client';\nimport { promises as fs } from 'fs';\nimport * as path from 'path';\nimport {\n IaCErrorCodes,\n ImageManifest,\n ManifestConfig,\n OCIPullOptions,\n OCIRegistryURLComponents,\n} from './types';\nimport { CustomError } from '../../../../../lib/errors';\nimport { getErrorStringCode } from './error-utils';\nimport { LOCAL_POLICY_ENGINE_DIR } from './local-cache';\nimport * as Debug from 'debug';\nimport { createIacDir } from './file-utils';\nconst debug = Debug('iac-oci-pull');\n\nexport const CUSTOM_RULES_TARBALL = 'custom-bundle.tar.gz';\n\nexport function extractOCIRegistryURLComponents(\n OCIRegistryURL: string,\n): OCIRegistryURLComponents {\n try {\n const urlWithoutProtocol = OCIRegistryURL.includes('://')\n ? OCIRegistryURL.split('://')[1]\n : OCIRegistryURL;\n\n const firstSlashIdx = urlWithoutProtocol.indexOf('/');\n if (firstSlashIdx === -1) {\n throw new InvalidRemoteRegistryURLError(OCIRegistryURL);\n }\n\n const [registryHost, repoWithTag] = [\n urlWithoutProtocol.substring(0, firstSlashIdx),\n urlWithoutProtocol.substring(firstSlashIdx + 1),\n ];\n if (!registryHost || !repoWithTag) {\n throw new InvalidRemoteRegistryURLError(OCIRegistryURL);\n }\n\n const [repo, tag = 'latest'] = repoWithTag.split(':');\n if (!repo) {\n throw new InvalidRemoteRegistryURLError(OCIRegistryURL);\n }\n\n return { registryBase: registryHost, repo, tag };\n } catch {\n throw new InvalidRemoteRegistryURLError(OCIRegistryURL);\n }\n}\n\n/**\n * Downloads an OCI Artifact from a remote OCI Registry and writes it to the disk.\n * The artifact here is a custom rules bundle stored in a remote registry.\n * In order to do that, it calls an external docker registry v2 client to get the manifests, the layers and then builds the artifact.\n * Example: https://github.com/opencontainers/image-spec/blob/main/manifest.md#example-image-manifest\n * @param OCIRegistryURL - the URL where the custom rules bundle is stored\n * @param opt????? (optional) - object that holds the credentials and other metadata required for the registry-v2-client\n **/\nexport async function pull(\n { registryBase, repo, tag }: OCIRegistryURLComponents,\n opt?: OCIPullOptions,\n): Promise<string> {\n const manifest: ImageManifest = await registryClient.getManifest(\n registryBase,\n repo,\n tag,\n opt?.username,\n opt?.password,\n opt?.reqOptions,\n );\n if (manifest.schemaVersion !== 2) {\n throw new InvalidManifestSchemaVersionError(\n manifest.schemaVersion.toString(),\n );\n }\n const manifestLayers: ManifestConfig[] = manifest.layers;\n // We assume that we will always have an artifact of a single layer\n if (manifestLayers.length > 1) {\n debug('There were more than one layers found in the OCI Artifact.');\n }\n const blob = await registryClient.getLayer(\n registryBase,\n repo,\n manifestLayers[0].digest,\n opt?.username,\n opt?.password,\n opt?.reqOptions,\n );\n\n try {\n const downloadPath: string = path.join(\n LOCAL_POLICY_ENGINE_DIR,\n CUSTOM_RULES_TARBALL,\n );\n createIacDir();\n await fs.writeFile(downloadPath, blob);\n return downloadPath;\n } catch (err) {\n throw new FailedToBuildOCIArtifactError();\n }\n}\n\nexport class FailedToBuildOCIArtifactError extends CustomError {\n constructor(message?: string) {\n super(message || 'Could not build OCI Artifact');\n this.code = IaCErrorCodes.FailedToBuildOCIArtifactError;\n this.strCode = getErrorStringCode(this.code);\n this.userMessage =\n 'We were unable to build the remote OCI Artifact locally, please ensure that the local directory is writeable.';\n }\n}\n\nexport class InvalidManifestSchemaVersionError extends CustomError {\n constructor(message?: string) {\n super(message || 'Invalid manifest schema version');\n this.code = IaCErrorCodes.InvalidRemoteRegistryURLError;\n this.strCode = getErrorStringCode(this.code);\n this.userMessage = `Invalid manifest schema version: ${message}. We currently support Image Manifest Version 2, Schema 2`;\n }\n}\n\nexport class InvalidRemoteRegistryURLError extends CustomError {\n constructor(url?: string) {\n super('Invalid URL for Remote Registry');\n this.code = IaCErrorCodes.InvalidRemoteRegistryURLError;\n this.strCode = getErrorStringCode(this.code);\n this.userMessage = `The provided remote registry URL${\n url ? `: \"${url}\"` : ''\n } is invalid. Please check it again.`;\n }\n}\n\nexport class UnsupportedEntitlementPullError extends CustomError {\n constructor(entitlement: string) {\n super(`OCI Pull not supported - Missing the ${entitlement} entitlement`);\n this.code = IaCErrorCodes.UnsupportedEntitlementPullError;\n this.strCode = getErrorStringCode(this.code);\n this.userMessage = `The custom rules feature is currently not supported for this org. To enable it, please contact snyk support.`;\n }\n}\n"],"names":[],"sourceRoot":""}
@@ -1800,17 +1800,9 @@ exports.getSeverityValue = getSeverityValue;
1800
1800
  "use strict";
1801
1801
 
1802
1802
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1803
- exports.getIacDisplayErrorFileOutput = exports.getIacDisplayedOutput = void 0;
1803
+ exports.getIacDisplayErrorFileOutput = void 0;
1804
1804
  const v1 = __webpack_require__(7666);
1805
1805
  const v2 = __webpack_require__(49041);
1806
- var v2_1 = __webpack_require__(49041);
1807
- Object.defineProperty(exports, "formatIacTestSummary", ({ enumerable: true, get: function () { return v2_1.formatIacTestSummary; } }));
1808
- function getIacDisplayedOutput(iacTest, testedInfoText, meta, prefix, isNewIacOutputSupported) {
1809
- return isNewIacOutputSupported
1810
- ? v2.getIacDisplayedOutput(iacTest, testedInfoText, meta, prefix)
1811
- : v1.getIacDisplayedOutput(iacTest, testedInfoText, meta, prefix);
1812
- }
1813
- exports.getIacDisplayedOutput = getIacDisplayedOutput;
1814
1806
  function getIacDisplayErrorFileOutput(iacFileResult, isNewIacOutputSupported) {
1815
1807
  return isNewIacOutputSupported
1816
1808
  ? v2.getIacDisplayErrorFileOutput(iacFileResult)
@@ -1821,6 +1813,10 @@ var v1_1 = __webpack_require__(7666);
1821
1813
  Object.defineProperty(exports, "capitalizePackageManager", ({ enumerable: true, get: function () { return v1_1.capitalizePackageManager; } }));
1822
1814
  Object.defineProperty(exports, "createSarifOutputForIac", ({ enumerable: true, get: function () { return v1_1.createSarifOutputForIac; } }));
1823
1815
  Object.defineProperty(exports, "shareResultsOutput", ({ enumerable: true, get: function () { return v1_1.shareResultsOutput; } }));
1816
+ Object.defineProperty(exports, "getIacDisplayedOutput", ({ enumerable: true, get: function () { return v1_1.getIacDisplayedOutput; } }));
1817
+ var v2_1 = __webpack_require__(49041);
1818
+ Object.defineProperty(exports, "formatIacTestSummary", ({ enumerable: true, get: function () { return v2_1.formatIacTestSummary; } }));
1819
+ Object.defineProperty(exports, "getIacDisplayedIssues", ({ enumerable: true, get: function () { return v2_1.getIacDisplayedIssues; } }));
1824
1820
 
1825
1821
 
1826
1822
  /***/ }),
@@ -2116,6 +2112,37 @@ exports.severityColor = {
2116
2112
  };
2117
2113
 
2118
2114
 
2115
+ /***/ }),
2116
+
2117
+ /***/ 62089:
2118
+ /***/ ((__unused_webpack_module, exports) => {
2119
+
2120
+ "use strict";
2121
+
2122
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
2123
+ exports.formatScanResultsNewOutput = void 0;
2124
+ function formatScanResultsNewOutput(oldFormattedResults, outputMeta) {
2125
+ const newFormattedResults = {
2126
+ results: {},
2127
+ metadata: outputMeta,
2128
+ };
2129
+ oldFormattedResults.forEach((oldFormattedResult) => {
2130
+ oldFormattedResult.result.cloudConfigResults.forEach((policyMetadata) => {
2131
+ if (!newFormattedResults.results[policyMetadata.severity]) {
2132
+ newFormattedResults.results[policyMetadata.severity] = [];
2133
+ }
2134
+ newFormattedResults.results[policyMetadata.severity].push({
2135
+ policyMetadata,
2136
+ targetFile: oldFormattedResult.targetFile,
2137
+ targetFilePath: oldFormattedResult.targetFilePath,
2138
+ });
2139
+ });
2140
+ });
2141
+ return newFormattedResults;
2142
+ }
2143
+ exports.formatScanResultsNewOutput = formatScanResultsNewOutput;
2144
+
2145
+
2119
2146
  /***/ }),
2120
2147
 
2121
2148
  /***/ 49041:
@@ -2124,57 +2151,12 @@ exports.severityColor = {
2124
2151
  "use strict";
2125
2152
 
2126
2153
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2127
- exports.getIacDisplayErrorFileOutput = exports.getIacDisplayedOutput = void 0;
2128
- const chalk_1 = __webpack_require__(32589);
2129
- const theme_1 = __webpack_require__(86988);
2130
- const Debug = __webpack_require__(15158);
2154
+ exports.getIacDisplayErrorFileOutput = void 0;
2131
2155
  const pathLib = __webpack_require__(85622);
2132
- const remediation_based_format_issues_1 = __webpack_require__(57995);
2133
- const legacy_format_issue_1 = __webpack_require__(63540);
2134
- const common_1 = __webpack_require__(53110);
2135
- const get_severity_value_1 = __webpack_require__(24898);
2156
+ var issues_list_1 = __webpack_require__(57962);
2157
+ Object.defineProperty(exports, "getIacDisplayedIssues", ({ enumerable: true, get: function () { return issues_list_1.getIacDisplayedIssues; } }));
2136
2158
  var test_summary_1 = __webpack_require__(42242);
2137
2159
  Object.defineProperty(exports, "formatIacTestSummary", ({ enumerable: true, get: function () { return test_summary_1.formatIacTestSummary; } }));
2138
- const debug = Debug('iac-output');
2139
- function formatIacIssue(issue, isNew, path) {
2140
- const newBadge = isNew ? ' (new)' : '';
2141
- const name = issue.subType ? ` in ${chalk_1.default.bold(issue.subType)}` : '';
2142
- let introducedBy = '';
2143
- if (path) {
2144
- // In this mode, we show only one path by default, for compactness
2145
- const pathStr = remediation_based_format_issues_1.printPath(path, 0);
2146
- introducedBy = `\n introduced by ${pathStr}`;
2147
- }
2148
- return (common_1.colorTextBySeverity(issue.severity, ` ${theme_1.icon.ISSUE} ${chalk_1.default.bold(issue.title)}${newBadge} [${legacy_format_issue_1.titleCaseText(issue.severity)} Severity]`) +
2149
- ` [${issue.id}]` +
2150
- name +
2151
- introducedBy +
2152
- '\n');
2153
- }
2154
- function getIacDisplayedOutput(iacTest, testedInfoText, meta, prefix) {
2155
- const issuesTextArray = [
2156
- chalk_1.default.bold.white('\nInfrastructure as code issues:'),
2157
- ];
2158
- const NotNew = false;
2159
- const issues = iacTest.result.cloudConfigResults;
2160
- debug(`iac display output - ${issues.length} issues`);
2161
- issues
2162
- .sort((a, b) => get_severity_value_1.getSeverityValue(b.severity) - get_severity_value_1.getSeverityValue(a.severity))
2163
- .forEach((issue) => {
2164
- issuesTextArray.push(formatIacIssue(issue, NotNew, issue.cloudConfigPath));
2165
- });
2166
- const issuesInfoOutput = [];
2167
- debug(`Iac display output - ${issuesTextArray.length} issues text`);
2168
- if (issuesTextArray.length > 0) {
2169
- issuesInfoOutput.push(issuesTextArray.join('\n'));
2170
- }
2171
- let body = issuesInfoOutput.join('\n\n') + '\n\n' + meta;
2172
- const vulnCountText = `found ${issues.length} issues`;
2173
- const summary = testedInfoText + ', ' + chalk_1.default.red.bold(vulnCountText);
2174
- body = body + '\n\n' + summary;
2175
- return prefix + body;
2176
- }
2177
- exports.getIacDisplayedOutput = getIacDisplayedOutput;
2178
2160
  function getIacDisplayErrorFileOutput(iacFileResult) {
2179
2161
  const fileName = pathLib.basename(iacFileResult.filePath);
2180
2162
  return `
@@ -2188,6 +2170,48 @@ ${iacFileResult.failureReason}`;
2188
2170
  exports.getIacDisplayErrorFileOutput = getIacDisplayErrorFileOutput;
2189
2171
 
2190
2172
 
2173
+ /***/ }),
2174
+
2175
+ /***/ 57962:
2176
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2177
+
2178
+ "use strict";
2179
+
2180
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
2181
+ exports.getIacDisplayedIssues = void 0;
2182
+ const chalk_1 = __webpack_require__(32589);
2183
+ const os_1 = __webpack_require__(12087);
2184
+ const capitalize = __webpack_require__(48403);
2185
+ const debug = __webpack_require__(15158);
2186
+ const color_utils_1 = __webpack_require__(4960);
2187
+ const formatters_1 = __webpack_require__(62089);
2188
+ function getIacDisplayedIssues(results, outputMeta) {
2189
+ const formattedResults = formatters_1.formatScanResultsNewOutput(results, outputMeta);
2190
+ let output = os_1.EOL + chalk_1.default.bold.white('Issues') + os_1.EOL;
2191
+ ['low', 'medium', 'high', 'critical'].forEach((severity) => {
2192
+ if (formattedResults.results[severity]) {
2193
+ const issues = formattedResults.results[severity];
2194
+ output +=
2195
+ os_1.EOL +
2196
+ color_utils_1.severityColor[severity](chalk_1.default.bold(`${capitalize(severity)} Severity Issues: ${issues.length}`)) +
2197
+ os_1.EOL.repeat(2);
2198
+ output += getIssuesOutput(issues);
2199
+ debug(`iac display output - ${severity} severity ${issues.length} issues`);
2200
+ }
2201
+ });
2202
+ return output;
2203
+ }
2204
+ exports.getIacDisplayedIssues = getIacDisplayedIssues;
2205
+ // CFG-1574 will continue the work on this function
2206
+ function getIssuesOutput(issues) {
2207
+ let output = '';
2208
+ issues.forEach((issue) => {
2209
+ output += chalk_1.default.white(`${issue.policyMetadata.title}`) + os_1.EOL;
2210
+ });
2211
+ return output;
2212
+ }
2213
+
2214
+
2191
2215
  /***/ }),
2192
2216
 
2193
2217
  /***/ 42242: