snyk 1.962.0 → 1.965.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 (43) hide show
  1. package/config.default.json +0 -2
  2. package/dist/cli/184.index.js +3 -3
  3. package/dist/cli/477.index.js +1 -1
  4. package/dist/cli/519.index.js +1 -20
  5. package/dist/cli/519.index.js.map +1 -1
  6. package/dist/cli/542.index.js +2 -2
  7. package/dist/cli/663.index.js +1 -1
  8. package/dist/cli/726.index.js +1 -1
  9. package/dist/cli/741.index.js +1 -1
  10. package/dist/cli/784.index.js +42 -37
  11. package/dist/cli/784.index.js.map +1 -1
  12. package/dist/cli/831.index.js +1 -1
  13. package/dist/cli/895.index.js +13 -13
  14. package/dist/cli/895.index.js.map +1 -1
  15. package/dist/cli/917.index.js +313 -37
  16. package/dist/cli/917.index.js.map +1 -1
  17. package/dist/cli/974.index.js +10 -6
  18. package/dist/cli/974.index.js.map +1 -1
  19. package/dist/cli/commands/test/iac/local-execution/file-loader.d.ts +1 -0
  20. package/dist/cli/commands/test/iac/local-execution/parsers/terraform-file-parser.d.ts +1 -0
  21. package/dist/cli/commands/test/iac/local-execution/yaml-parser.d.ts +2 -0
  22. package/dist/cli/index.js +157 -24
  23. package/dist/cli/index.js.map +1 -1
  24. package/dist/lib/config/api-url.d.ts +19 -0
  25. package/dist/lib/{config.d.ts → config/index.d.ts} +0 -0
  26. package/dist/lib/formatters/iac-output/v2/issues-list/formatters.d.ts +1 -1
  27. package/dist/lib/formatters/iac-output/v2/issues-list/types.d.ts +1 -1
  28. package/dist/lib/iac/drift/driftctl.d.ts +1 -1
  29. package/dist/lib/iac/test/v2/index.d.ts +1 -1
  30. package/dist/lib/iac/test/v2/json.d.ts +78 -0
  31. package/dist/lib/iac/test/v2/output.d.ts +6 -2
  32. package/dist/lib/iac/test/v2/{scan.d.ts → scan/index.d.ts} +2 -2
  33. package/dist/{cli/commands/test/iac/v2/policy-engine-types.d.ts → lib/iac/test/v2/scan/policy-engine.d.ts} +0 -0
  34. package/dist/{cli/commands/test/iac/v2/types.d.ts → lib/iac/test/v2/scan/results.d.ts} +7 -10
  35. package/dist/lib/iac/test/v2/setup/local-cache/policy-engine/constants/index.d.ts +2 -1
  36. package/dist/lib/iac/test/v2/setup/local-cache/policy-engine/constants/utils.d.ts +1 -0
  37. package/dist/lib/iac/test/v2/setup/local-cache/policy-engine/download.d.ts +0 -1
  38. package/dist/lib/iac/test/v2/types.d.ts +3 -0
  39. package/help/cli-commands/container.md +9 -0
  40. package/help/cli-commands/monitor.md +16 -2
  41. package/help/cli-commands/test.md +20 -4
  42. package/package.json +1 -1
  43. package/dist/cli/commands/test/iac/local-execution/math-utils.d.ts +0 -7
@@ -1,6 +1,4 @@
1
1
  {
2
- "API": "https://snyk.io/api/v1",
3
- "API_REST_URL": "https://api.snyk.io/rest",
4
2
  "devDeps": false,
5
3
  "PRUNE_DEPS_THRESHOLD": 40000,
6
4
  "MAX_PATH_COUNT": 1500000,
@@ -93536,7 +93536,7 @@ exports.decode = function(input) {
93536
93536
 
93537
93537
  var external = __webpack_require__(38565);
93538
93538
  var DataWorker = __webpack_require__(5301);
93539
- var Crc32Probe = __webpack_require__(65055);
93539
+ var Crc32Probe = __webpack_require__(22541);
93540
93540
  var DataLengthProbe = __webpack_require__(95977);
93541
93541
 
93542
93542
  /**
@@ -94541,7 +94541,7 @@ var utils = __webpack_require__(58910);
94541
94541
  var external = __webpack_require__(38565);
94542
94542
  var utf8 = __webpack_require__(83600);
94543
94543
  var ZipEntries = __webpack_require__(6624);
94544
- var Crc32Probe = __webpack_require__(65055);
94544
+ var Crc32Probe = __webpack_require__(22541);
94545
94545
  var nodejsUtils = __webpack_require__(72182);
94546
94546
 
94547
94547
  /**
@@ -95592,7 +95592,7 @@ module.exports = ConvertWorker;
95592
95592
 
95593
95593
  /***/ }),
95594
95594
 
95595
- /***/ 65055:
95595
+ /***/ 22541:
95596
95596
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
95597
95597
 
95598
95598
  "use strict";
@@ -41,7 +41,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
41
41
  exports.display = void 0;
42
42
  const chalk_1 = __webpack_require__(32589);
43
43
  const snyk_policy_1 = __webpack_require__(70535);
44
- const config_1 = __webpack_require__(22541);
44
+ const config_1 = __webpack_require__(25425);
45
45
  async function display(policy) {
46
46
  const p = snyk_policy_1.demunge(policy, config_1.default.ROOT);
47
47
  const delimiter = '\n\n------------------------\n';
@@ -11,7 +11,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
11
11
  exports.addIacDriftAnalytics = exports.performanceAnalyticsObject = exports.addIacAnalytics = void 0;
12
12
  const types_1 = __webpack_require__(94820);
13
13
  const analytics = __webpack_require__(82744);
14
- const math_utils_1 = __webpack_require__(42095);
15
14
  const file_utils_1 = __webpack_require__(45281);
16
15
  const driftctl_1 = __webpack_require__(3659);
17
16
  function addIacAnalytics(formattedResults, opts) {
@@ -50,7 +49,6 @@ function addIacAnalytics(formattedResults, opts) {
50
49
  analytics.add('iac-local-custom-rules', opts.rulesOrigin === types_1.RulesOrigin.Local);
51
50
  analytics.add('iac-remote-custom-rules', opts.rulesOrigin === types_1.RulesOrigin.Remote);
52
51
  analytics.add('iac-custom-rules-issues-count', issuesFromCustomRulesCount);
53
- analytics.add('iac-custom-rules-issues-percentage', math_utils_1.calculatePercentage(issuesFromCustomRulesCount, totalIssuesCount));
54
52
  analytics.add('iac-custom-rules-checksum', file_utils_1.computeCustomRulesBundleChecksum());
55
53
  analytics.add('iac-custom-rules-coverage-count', uniqueCustomRulesCount);
56
54
  }
@@ -216,7 +214,7 @@ const Debug = __webpack_require__(15158);
216
214
  const errors_1 = __webpack_require__(55191);
217
215
  const analytics = __webpack_require__(82744);
218
216
  const error_utils_1 = __webpack_require__(36401);
219
- const config_1 = __webpack_require__(22541);
217
+ const config_1 = __webpack_require__(25425);
220
218
  const request_1 = __webpack_require__(1552);
221
219
  const debug = Debug('iac-local-cache');
222
220
  exports.LOCAL_POLICY_ENGINE_DIR = '.iac-data';
@@ -387,23 +385,6 @@ class FailedToCleanLocalCacheError extends errors_1.CustomError {
387
385
  }
388
386
 
389
387
 
390
- /***/ }),
391
-
392
- /***/ 42095:
393
- /***/ ((__unused_webpack_module, exports) => {
394
-
395
-
396
- Object.defineProperty(exports, "__esModule", ({ value: true }));
397
- exports.calculatePercentage = void 0;
398
- /**
399
- * Calculate percentage from relative and total amounts.
400
- * @param relativeValue The relative amount.
401
- * @param totalValue The total amount.
402
- * @returns The calculated precentage.
403
- */
404
- exports.calculatePercentage = (relativeValue, totalValue) => +(totalValue ? (relativeValue / totalValue) * 100 : 0).toFixed(2);
405
-
406
-
407
388
  /***/ }),
408
389
 
409
390
  /***/ 166:
@@ -1 +1 @@
1
- {"version":3,"file":"519.index.js","mappings":";;;;;;;;;;;AAAA,2CAAgF;AAChF,6CAA0D;AAC1D,gDAAmD;AACnD,gDAAgE;AAEhE,6CAAwE;AAExE,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,IAAI,CAAC,WAAW,CAAC,CAAC;QAClC,oBAAoB,CAAC,WAAW,CAAC,SAAG,oBAAoB,CAAC,WAAW,CAAC,mCAAI;YACvE,KAAK,EAAE,CAAC;SACT,CAAC;QACF,oBAAoB,C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I,CAAC,OAAO,GAAG,gCAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,WAAW,GAAG,oCAAoC,OAAO,2DAA2D,CAAC;IAC5H,CAAC;CACF;AAPD,8EAOC;AAED,MAAa,6BAA8B,SAAQ,oBAAW;IAC5D,YAAY,GAAY;QACtB,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,qBAAa,CAAC,6BAA6B,CAAC;QACxD,IAAI,CAAC,OAAO,GAAG,gCAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,WAAW,GAAG,mCACjB,GAAG,CAAC,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,EACvB,qCAAqC,CAAC;IACxC,CAAC;CACF;AATD,sEASC;AAED,MAAa,+BAAgC,SAAQ,oBAAW;IAC9D,YAAY,WAAmB;QAC7B,KAAK,CAAC,wCAAwC,WAAW,cAAc,CAAC,CAAC;QACzE,IAAI,CAAC,IAAI,GAAG,qBAAa,CAAC,+BAA+B,CAAC;QAC1D,IAAI,CAAC,OAAO,GAAG,gCAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,WAAW,GAAG,8GAA8G,CAAC;IACpI,CAAC;CACF;AAPD,0EAOC","sources":["webpack://snyk/./src/cli/commands/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/rules/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/driftctl';\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 './rules/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 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 { getErrorStringCode } from './error-utils';\nimport config from '../../../../../lib/config';\nimport { streamRequest } from '../../../../../lib/request/request';\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 // IAC_BUNDLE_PATH is a developer setting that is not useful to most users. It\n // is not a replacement for custom rules.\n if (config.IAC_BUNDLE_PATH) {\n const stream = fs.createReadStream(config.IAC_BUNDLE_PATH);\n await extractBundle(stream);\n return;\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 = await streamRequest({\n method: 'get',\n url: BUNDLE_URL,\n body: null,\n headers: {},\n });\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 { promises as fs } from 'fs';\nimport * as path from 'path';\nimport { IaCErrorCodes, OCIRegistryURLComponents } 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';\nimport { OciRegistry } from './oci-registry';\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 const [registryHost, repoWithTag] = [\n urlWithoutProtocol.substring(0, firstSlashIdx),\n urlWithoutProtocol.substring(firstSlashIdx + 1),\n ];\n const [repo, tag = 'latest'] = repoWithTag.split(':');\n if (firstSlashIdx === -1 || !registryHost || !repoWithTag || !repo) {\n throw new InvalidRemoteRegistryURLError(OCIRegistryURL);\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\n * disk. 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\n * the manifests, the layers and then builds the artifact. Example:\n * https://github.com/opencontainers/image-spec/blob/main/manifest.md#example-image-manifest\n *\n * @param registry The client for accessing an OCI registry.\n * @param repository The name of an OCI repository.\n * @param tag The tag of an image in an OCI repository.\n **/\nexport async function pull(\n registry: OciRegistry,\n repository: string,\n tag: string,\n): Promise<string> {\n const { schemaVersion, layers } = await registry.getManifest(repository, tag);\n if (schemaVersion !== 2) {\n throw new InvalidManifestSchemaVersionError(schemaVersion.toString());\n }\n // We assume that we will always have an artifact of a single layer\n if (layers.length > 1) {\n debug('There were more than one layers found in the OCI Artifact.');\n }\n const { blob } = await registry.getLayer(repository, layers[0].digest);\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":""}
1
+ {"version":3,"file":"519.index.js","mappings":";;;;;;;;;;;AAAA,2CAAgF;AAChF,6CAA0D;AAC1D,gDAAgE;AAEhE,6CAAwE;AAExE,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,KA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;QACpD,IAAI,CAAC,IAAI,GAAG,qBAAa,CAAC,6BAA6B,CAAC;QACxD,IAAI,CAAC,OAAO,GAAG,gCAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,WAAW,GAAG,oCAAoC,OAAO,2DAA2D,CAAC;IAC5H,CAAC;CACF;AAPD,8EAOC;AAED,MAAa,6BAA8B,SAAQ,oBAAW;IAC5D,YAAY,GAAY;QACtB,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,qBAAa,CAAC,6BAA6B,CAAC;QACxD,IAAI,CAAC,OAAO,GAAG,gCAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,WAAW,GAAG,mCACjB,GAAG,CAAC,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,EACvB,qCAAqC,CAAC;IACxC,CAAC;CACF;AATD,sEASC;AAED,MAAa,+BAAgC,SAAQ,oBAAW;IAC9D,YAAY,WAAmB;QAC7B,KAAK,CAAC,wCAAwC,WAAW,cAAc,CAAC,CAAC;QACzE,IAAI,CAAC,IAAI,GAAG,qBAAa,CAAC,+BAA+B,CAAC;QAC1D,IAAI,CAAC,OAAO,GAAG,gCAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,WAAW,GAAG,8GAA8G,CAAC;IACpI,CAAC;CACF;AAPD,0EAOC","sources":["webpack://snyk/./src/cli/commands/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/rules/oci-pull.ts"],"sourcesContent":["import { FormattedResult, PerformanceAnalyticsKey, RulesOrigin } from './types';\nimport * as analytics from '../../../../../lib/analytics';\nimport { computeCustomRulesBundleChecksum } from './file-utils';\nimport { DescribeOptions, DriftAnalysis } from '../../../../../lib/iac/types';\nimport { driftctlVersion } from '../../../../../lib/iac/drift/driftctl';\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-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 './rules/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 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 { getErrorStringCode } from './error-utils';\nimport config from '../../../../../lib/config';\nimport { streamRequest } from '../../../../../lib/request/request';\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 // IAC_BUNDLE_PATH is a developer setting that is not useful to most users. It\n // is not a replacement for custom rules.\n if (config.IAC_BUNDLE_PATH) {\n const stream = fs.createReadStream(config.IAC_BUNDLE_PATH);\n await extractBundle(stream);\n return;\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 = await streamRequest({\n method: 'get',\n url: BUNDLE_URL,\n body: null,\n headers: {},\n });\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","import { promises as fs } from 'fs';\nimport * as path from 'path';\nimport { IaCErrorCodes, OCIRegistryURLComponents } 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';\nimport { OciRegistry } from './oci-registry';\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 const [registryHost, repoWithTag] = [\n urlWithoutProtocol.substring(0, firstSlashIdx),\n urlWithoutProtocol.substring(firstSlashIdx + 1),\n ];\n const [repo, tag = 'latest'] = repoWithTag.split(':');\n if (firstSlashIdx === -1 || !registryHost || !repoWithTag || !repo) {\n throw new InvalidRemoteRegistryURLError(OCIRegistryURL);\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\n * disk. 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\n * the manifests, the layers and then builds the artifact. Example:\n * https://github.com/opencontainers/image-spec/blob/main/manifest.md#example-image-manifest\n *\n * @param registry The client for accessing an OCI registry.\n * @param repository The name of an OCI repository.\n * @param tag The tag of an image in an OCI repository.\n **/\nexport async function pull(\n registry: OciRegistry,\n repository: string,\n tag: string,\n): Promise<string> {\n const { schemaVersion, layers } = await registry.getManifest(repository, tag);\n if (schemaVersion !== 2) {\n throw new InvalidManifestSchemaVersionError(schemaVersion.toString());\n }\n // We assume that we will always have an artifact of a single layer\n if (layers.length > 1) {\n debug('There were more than one layers found in the OCI Artifact.');\n }\n const { blob } = await registry.getLayer(repository, layers[0].digest);\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":""}
@@ -10,7 +10,7 @@ exports.modules = {
10
10
  Object.defineProperty(exports, "__esModule", ({ value: true }));
11
11
  exports.verifyAPI = exports.isAuthed = void 0;
12
12
  const snyk = __webpack_require__(9146);
13
- const config_1 = __webpack_require__(22541);
13
+ const config_1 = __webpack_require__(25425);
14
14
  const request_1 = __webpack_require__(52050);
15
15
  function isAuthed() {
16
16
  const token = snyk.config.get('api');
@@ -171,7 +171,7 @@ async function load(path) {
171
171
  Object.defineProperty(exports, "__esModule", ({ value: true }));
172
172
  exports.actionAllowed = void 0;
173
173
  const api_token_1 = __webpack_require__(95181);
174
- const config_1 = __webpack_require__(22541);
174
+ const config_1 = __webpack_require__(25425);
175
175
  const request_1 = __webpack_require__(52050);
176
176
  async function actionAllowed(action, options) {
177
177
  const org = options.org || config_1.default.org || null;
@@ -700,7 +700,7 @@ const _1 = __webpack_require__(14589);
700
700
  const chalk_1 = __webpack_require__(32589);
701
701
  const errors_1 = __webpack_require__(55191);
702
702
  const Debug = __webpack_require__(15158);
703
- const config_1 = __webpack_require__(22541);
703
+ const config_1 = __webpack_require__(25425);
704
704
  const debug = Debug(_1.SNYK_APP_DEBUG);
705
705
  function getAppsURL(selection, opts = {}) {
706
706
  // Get the rest URL from user config
@@ -63,7 +63,7 @@ const legacyError = __webpack_require__(79407);
63
63
  const drift_1 = __webpack_require__(26445);
64
64
  const get_iac_org_settings_1 = __webpack_require__(11693);
65
65
  const assert_iac_options_flag_1 = __webpack_require__(33111);
66
- const config_1 = __webpack_require__(22541);
66
+ const config_1 = __webpack_require__(25425);
67
67
  const analytics_1 = __webpack_require__(41519);
68
68
  const analytics = __webpack_require__(82744);
69
69
  const policy_1 = __webpack_require__(32615);
@@ -369,7 +369,7 @@ exports.formatTestError = formatTestError;
369
369
 
370
370
  Object.defineProperty(exports, "__esModule", ({ value: true }));
371
371
  exports.setDefaultTestOptions = void 0;
372
- const config_1 = __webpack_require__(22541);
372
+ const config_1 = __webpack_require__(25425);
373
373
  function setDefaultTestOptions(options) {
374
374
  const svpSupplied = (options['show-vulnerable-paths'] || '')
375
375
  .toString()
@@ -47,7 +47,7 @@ const cli_interface_1 = __webpack_require__(65266);
47
47
  const options_validator_1 = __webpack_require__(1570);
48
48
  const check_paths_1 = __webpack_require__(94501);
49
49
  const types_1 = __webpack_require__(94055);
50
- const config_1 = __webpack_require__(22541);
50
+ const config_1 = __webpack_require__(25425);
51
51
  const detect = __webpack_require__(45318);
52
52
  const spinner_1 = __webpack_require__(86766);
53
53
  const analytics = __webpack_require__(82744);
@@ -536,13 +536,13 @@ exports.checkOSSPaths = checkOSSPaths;
536
536
 
537
537
  Object.defineProperty(exports, "__esModule", ({ value: true }));
538
538
  exports.getBase64Encoding = exports.getCodeClientProxyUrl = void 0;
539
- const config_1 = __webpack_require__(22541);
539
+ const config_1 = __webpack_require__(25425);
540
540
  const user_config_1 = __webpack_require__(28137);
541
541
  function getCodeClientProxyUrl() {
542
542
  const url = new URL(config_1.default.API);
543
543
  const domain = url.origin;
544
544
  return (config_1.default.CODE_CLIENT_PROXY_URL ||
545
- domain.replace(/\/\/(app\.)?/, '//deeproxy.'));
545
+ domain.replace(/\/\/(ap[pi]\.)?/, '//deeproxy.'));
546
546
  }
547
547
  exports.getCodeClientProxyUrl = getCodeClientProxyUrl;
548
548
  function getBase64Encoding(enabled = user_config_1.config.get('use-base64-encoding')) {
@@ -644,7 +644,7 @@ exports.getEcosystem = getEcosystem;
644
644
  Object.defineProperty(exports, "__esModule", ({ value: true }));
645
645
  exports.getFormattedMonitorOutput = exports.generateMonitorDependenciesRequest = exports.monitorEcosystem = void 0;
646
646
  const chalk_1 = __webpack_require__(32589);
647
- const config_1 = __webpack_require__(22541);
647
+ const config_1 = __webpack_require__(25425);
648
648
  const is_ci_1 = __webpack_require__(10090);
649
649
  const promise_1 = __webpack_require__(90430);
650
650
  const spinner_1 = __webpack_require__(86766);
@@ -1053,7 +1053,7 @@ exports.resolveAndTestFacts = resolveAndTestFacts;
1053
1053
 
1054
1054
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1055
1055
  exports.selectAndExecuteTestStrategy = exports.testEcosystem = void 0;
1056
- const config_1 = __webpack_require__(22541);
1056
+ const config_1 = __webpack_require__(25425);
1057
1057
  const is_ci_1 = __webpack_require__(10090);
1058
1058
  const promise_1 = __webpack_require__(90430);
1059
1059
  const types_1 = __webpack_require__(55246);
@@ -1185,7 +1185,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
1185
1185
  exports.hasFeatureFlag = exports.isFeatureFlagSupportedForOrg = void 0;
1186
1186
  const request_1 = __webpack_require__(52050);
1187
1187
  const api_token_1 = __webpack_require__(95181);
1188
- const config_1 = __webpack_require__(22541);
1188
+ const config_1 = __webpack_require__(25425);
1189
1189
  const common_1 = __webpack_require__(53110);
1190
1190
  const errors_1 = __webpack_require__(55191);
1191
1191
  async function isFeatureFlagSupportedForOrg(featureFlag, org) {
@@ -1598,7 +1598,7 @@ exports.formatMonitorOutput = exports.formatErrorMonitorOutput = void 0;
1598
1598
  const assign = __webpack_require__(31730);
1599
1599
  const chalk_1 = __webpack_require__(32589);
1600
1600
  const url = __webpack_require__(78835);
1601
- const config_1 = __webpack_require__(22541);
1601
+ const config_1 = __webpack_require__(25425);
1602
1602
  const show_multi_scan_tip_1 = __webpack_require__(95100);
1603
1603
  function formatErrorMonitorOutput(packageManager, res, options, projectName) {
1604
1604
  const humanReadableName = projectName
@@ -1929,7 +1929,7 @@ const detect_1 = __webpack_require__(45318);
1929
1929
  const get_severity_value_1 = __webpack_require__(24898);
1930
1930
  const sarif_output_1 = __webpack_require__(5034);
1931
1931
  const version_1 = __webpack_require__(38217);
1932
- const config_1 = __webpack_require__(22541);
1932
+ const config_1 = __webpack_require__(25425);
1933
1933
  const git_1 = __webpack_require__(82421);
1934
1934
  const debug = Debug('iac-output');
1935
1935
  function formatIacIssue(issue, isNew, path) {
@@ -2403,7 +2403,7 @@ function formatProperties(result) {
2403
2403
 
2404
2404
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2405
2405
  exports.shareCustomRulesDisclaimer = exports.shareResultsTip = exports.formatShareResultsOutput = void 0;
2406
- const config_1 = __webpack_require__(22541);
2406
+ const config_1 = __webpack_require__(25425);
2407
2407
  const os_1 = __webpack_require__(12087);
2408
2408
  const utils_1 = __webpack_require__(67533);
2409
2409
  function formatShareResultsOutput(iacOutputMeta) {
@@ -2609,7 +2609,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
2609
2609
  exports.titleCaseText = exports.formatIssues = void 0;
2610
2610
  const uniq = __webpack_require__(97644);
2611
2611
  const chalk_1 = __webpack_require__(32589);
2612
- const config_1 = __webpack_require__(22541);
2612
+ const config_1 = __webpack_require__(25425);
2613
2613
  const detect_1 = __webpack_require__(45318);
2614
2614
  const snyk_module_1 = __webpack_require__(60390);
2615
2615
  const package_managers_1 = __webpack_require__(53847);
@@ -2820,7 +2820,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
2820
2820
  exports.formatIssue = exports.printPath = exports.formatIssuesWithRemediation = void 0;
2821
2821
  const chalk_1 = __webpack_require__(32589);
2822
2822
  const theme_1 = __webpack_require__(86988);
2823
- const config_1 = __webpack_require__(22541);
2823
+ const config_1 = __webpack_require__(25425);
2824
2824
  const common_1 = __webpack_require__(53110);
2825
2825
  const legal_license_instructions_1 = __webpack_require__(48049);
2826
2826
  const format_reachability_1 = __webpack_require__(13331);
@@ -3719,7 +3719,7 @@ const depGraphLib = __webpack_require__(71479);
3719
3719
  const snyk = __webpack_require__(9146);
3720
3720
  const api_token_1 = __webpack_require__(95181);
3721
3721
  const request_1 = __webpack_require__(52050);
3722
- const config_1 = __webpack_require__(22541);
3722
+ const config_1 = __webpack_require__(25425);
3723
3723
  const os = __webpack_require__(12087);
3724
3724
  const get = __webpack_require__(29208);
3725
3725
  const is_ci_1 = __webpack_require__(10090);
@@ -4161,7 +4161,7 @@ exports.getTargetFile = getTargetFile;
4161
4161
 
4162
4162
  Object.defineProperty(exports, "__esModule", ({ value: true }));
4163
4163
  exports.validateOptions = void 0;
4164
- const config_1 = __webpack_require__(22541);
4164
+ const config_1 = __webpack_require__(25425);
4165
4165
  const reachableVulns = __webpack_require__(86978);
4166
4166
  const is_multi_project_scan_1 = __webpack_require__(62435);
4167
4167
  const errors_1 = __webpack_require__(55191);
@@ -5186,7 +5186,7 @@ exports.getCodeAnalysisAndParseResults = void 0;
5186
5186
  const code_client_1 = __webpack_require__(95951);
5187
5187
  const legacy_1 = __webpack_require__(34013);
5188
5188
  const api_token_1 = __webpack_require__(95181);
5189
- const config_1 = __webpack_require__(22541);
5189
+ const config_1 = __webpack_require__(25425);
5190
5190
  const code_config_1 = __webpack_require__(55203);
5191
5191
  const spinner_1 = __webpack_require__(86766);
5192
5192
  const utils_1 = __webpack_require__(33113);
@@ -5338,7 +5338,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
5338
5338
  exports.trackUsage = exports.getSastSettingsForOrg = void 0;
5339
5339
  const request_1 = __webpack_require__(52050);
5340
5340
  const api_token_1 = __webpack_require__(95181);
5341
- const config_1 = __webpack_require__(22541);
5341
+ const config_1 = __webpack_require__(25425);
5342
5342
  const common_1 = __webpack_require__(53110);
5343
5343
  async function getSastSettingsForOrg(org) {
5344
5344
  const response = await request_1.makeRequest({
@@ -5458,21 +5458,24 @@ function getCodeDisplayedOutput(codeTest, meta, prefix) {
5458
5458
  '\n\n' +
5459
5459
  meta +
5460
5460
  '\n\n' +
5461
- codeIssueSummary);
5461
+ chalk_1.default.bold('Summary:') +
5462
+ '\n\n' +
5463
+ codeIssueSummary +
5464
+ '\n\n');
5462
5465
  }
5463
5466
  exports.getCodeDisplayedOutput = getCodeDisplayedOutput;
5464
5467
  function getCodeIssuesSummary(issues) {
5465
5468
  const lowSeverityText = issues.low.length
5466
- ? common_1.colorTextBySeverity(common_1.SEVERITY.LOW, ` ${issues.low.length} [Low] `)
5469
+ ? common_1.colorTextBySeverity(common_1.SEVERITY.LOW, ` ${issues.low.length} [Low] `)
5467
5470
  : '';
5468
5471
  const mediumSeverityText = issues.medium.length
5469
- ? common_1.colorTextBySeverity(common_1.SEVERITY.MEDIUM, ` ${issues.medium.length} [Medium] `)
5472
+ ? common_1.colorTextBySeverity(common_1.SEVERITY.MEDIUM, ` ${issues.medium.length} [Medium] `)
5470
5473
  : '';
5471
5474
  const highSeverityText = issues.high.length
5472
- ? common_1.colorTextBySeverity(common_1.SEVERITY.HIGH, `${issues.high.length} [High] `)
5475
+ ? common_1.colorTextBySeverity(common_1.SEVERITY.HIGH, ` ${issues.high.length} [High] `)
5473
5476
  : '';
5474
5477
  const codeIssueCount = issues.low.length + issues.medium.length + issues.high.length;
5475
- const codeIssueFound = `${codeIssueCount} Code issue${codeIssueCount > 0 ? 's' : ''} found`;
5478
+ const codeIssueFound = ` ${codeIssueCount} Code issue${codeIssueCount > 0 ? 's' : ''} found`;
5476
5479
  const issuesBySeverityText = highSeverityText + mediumSeverityText + lowSeverityText;
5477
5480
  const vulnPathsText = theme_1.color.status.success(`${theme_1.icon.VALID} Awesome! No issues were found.`);
5478
5481
  return codeIssueCount > 0
@@ -5495,14 +5498,16 @@ function getIssues(results, rulesMap) {
5495
5498
  if (!(ruleId in rulesMap)) {
5496
5499
  debug('Rule ID does not exist in the rules list');
5497
5500
  }
5498
- const ruleName = ((_b = rulesMap[ruleId].shortDescription) === null || _b === void 0 ? void 0 : _b.text) || rulesMap[ruleId].name;
5499
- const ruleIdSeverityText = common_1.colorTextBySeverity(severity, ` ${theme_1.icon.ISSUE} [${severity}] ${ruleName}`);
5501
+ const ruleName = ((_b = rulesMap[ruleId].shortDescription) === null || _b === void 0 ? void 0 : _b.text) ||
5502
+ rulesMap[ruleId].name ||
5503
+ '';
5504
+ const ruleIdSeverityText = common_1.colorTextBySeverity(severity, ` ${theme_1.icon.ISSUE} [${severity}] ${chalk_1.default.bold(ruleName)}`);
5500
5505
  const artifactLocationUri = location.artifactLocation.uri;
5501
5506
  const startLine = location.region.startLine;
5502
5507
  const text = res.message.text;
5503
5508
  const title = ruleIdSeverityText;
5504
- const path = ` Path: ${artifactLocationUri}, line ${startLine}`;
5505
- const info = ` Info: ${text}`;
5509
+ const path = ` Path: ${artifactLocationUri}, line ${startLine}`;
5510
+ const info = ` Info: ${text}`;
5506
5511
  acc[severity.toLowerCase()].push(`${title} \n ${path} \n ${info}\n\n`);
5507
5512
  }
5508
5513
  }
@@ -5527,14 +5532,14 @@ function sarifToSeverityLevel(sarifConfigurationLevel) {
5527
5532
  }
5528
5533
  function getMeta(options, path) {
5529
5534
  const padToLength = 19; // chars to align
5530
- const orgName = options.org;
5535
+ const orgName = options.org || '';
5531
5536
  const projectPath = options.path || path;
5532
5537
  const meta = [
5533
- chalk_1.default.bold(right_pad_1.rightPadWithSpaces('Organization: ', padToLength)) + orgName,
5538
+ right_pad_1.rightPadWithSpaces('Organization: ', padToLength) + chalk_1.default.bold(orgName),
5534
5539
  ];
5535
- meta.push(chalk_1.default.bold(right_pad_1.rightPadWithSpaces('Test type: ', padToLength)) +
5536
- 'Static code analysis');
5537
- meta.push(chalk_1.default.bold(right_pad_1.rightPadWithSpaces('Project path: ', padToLength)) + projectPath);
5540
+ meta.push(right_pad_1.rightPadWithSpaces('Test type: ', padToLength) +
5541
+ chalk_1.default.bold('Static code analysis'));
5542
+ meta.push(right_pad_1.rightPadWithSpaces('Project path: ', padToLength) + chalk_1.default.bold(projectPath));
5538
5543
  return meta.join('\n');
5539
5544
  }
5540
5545
  exports.getMeta = getMeta;
@@ -5671,7 +5676,7 @@ function throwIssuesError(args) {
5671
5676
 
5672
5677
  Object.defineProperty(exports, "__esModule", ({ value: true }));
5673
5678
  exports.getSastSettings = void 0;
5674
- const config_1 = __webpack_require__(22541);
5679
+ const config_1 = __webpack_require__(25425);
5675
5680
  const checks_1 = __webpack_require__(15976);
5676
5681
  const errors_1 = __webpack_require__(55191);
5677
5682
  async function getSastSettings(options) {
@@ -5892,7 +5897,7 @@ exports.handleProcessingStatus = handleProcessingStatus;
5892
5897
 
5893
5898
  Object.defineProperty(exports, "__esModule", ({ value: true }));
5894
5899
  exports.pollingMonitorWithTokenUntilDone = exports.requestMonitorPollingToken = void 0;
5895
- const config_1 = __webpack_require__(22541);
5900
+ const config_1 = __webpack_require__(25425);
5896
5901
  const is_ci_1 = __webpack_require__(10090);
5897
5902
  const promise_1 = __webpack_require__(90430);
5898
5903
  const common_1 = __webpack_require__(53110);
@@ -5961,7 +5966,7 @@ exports.pollingMonitorWithTokenUntilDone = pollingMonitorWithTokenUntilDone;
5961
5966
 
5962
5967
  Object.defineProperty(exports, "__esModule", ({ value: true }));
5963
5968
  exports.pollingTestWithTokenUntilDone = exports.requestTestPollingToken = void 0;
5964
- const config_1 = __webpack_require__(22541);
5969
+ const config_1 = __webpack_require__(25425);
5965
5970
  const is_ci_1 = __webpack_require__(10090);
5966
5971
  const promise_1 = __webpack_require__(90430);
5967
5972
  const common_1 = __webpack_require__(53110);
@@ -6027,7 +6032,7 @@ exports.pollingTestWithTokenUntilDone = pollingTestWithTokenUntilDone;
6027
6032
 
6028
6033
  Object.defineProperty(exports, "__esModule", ({ value: true }));
6029
6034
  exports.maybePrintDepTree = exports.maybePrintDepGraph = void 0;
6030
- const config_1 = __webpack_require__(22541);
6035
+ const config_1 = __webpack_require__(25425);
6031
6036
  const depGraphLib = __webpack_require__(71479);
6032
6037
  const utils_1 = __webpack_require__(61721);
6033
6038
  const json_1 = __webpack_require__(27019);
@@ -6234,7 +6239,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
6234
6239
  exports.pruneGraph = void 0;
6235
6240
  const _debug = __webpack_require__(15158);
6236
6241
  const dep_graph_1 = __webpack_require__(71479);
6237
- const config_1 = __webpack_require__(22541);
6242
+ const config_1 = __webpack_require__(25425);
6238
6243
  const errors_1 = __webpack_require__(55191);
6239
6244
  const analytics = __webpack_require__(82744);
6240
6245
  const utils_1 = __webpack_require__(61721);
@@ -6401,7 +6406,7 @@ exports.rightPadWithSpaces = rightPadWithSpaces;
6401
6406
  Object.defineProperty(exports, "__esModule", ({ value: true }));
6402
6407
  exports.assembleEcosystemPayloads = void 0;
6403
6408
  const path = __webpack_require__(85622);
6404
- const config_1 = __webpack_require__(22541);
6409
+ const config_1 = __webpack_require__(25425);
6405
6410
  const is_ci_1 = __webpack_require__(10090);
6406
6411
  const ecosystems_1 = __webpack_require__(5168);
6407
6412
  const common_1 = __webpack_require__(53110);
@@ -6660,7 +6665,7 @@ const errors_1 = __webpack_require__(55191);
6660
6665
  const snyk = __webpack_require__(9146);
6661
6666
  const is_ci_1 = __webpack_require__(10090);
6662
6667
  const common = __webpack_require__(53110);
6663
- const config_1 = __webpack_require__(22541);
6668
+ const config_1 = __webpack_require__(25425);
6664
6669
  const analytics = __webpack_require__(82744);
6665
6670
  const print_deps_1 = __webpack_require__(79792);
6666
6671
  const projectMetadata = __webpack_require__(3594);
@@ -7268,7 +7273,7 @@ exports.execute = execute;
7268
7273
  /***/ 9146:
7269
7274
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
7270
7275
 
7271
- const snykConfig = __webpack_require__(22541);
7276
+ const snykConfig = __webpack_require__(25425);
7272
7277
 
7273
7278
  // This module is kind of "world object" that is used to indirectly import modules.
7274
7279
  // This also introduces some circular imports.