snyk 1.874.0 → 1.877.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.
- package/dist/cli/459.index.js +98 -6
- package/dist/cli/459.index.js.map +1 -1
- package/dist/cli/874.index.js +312 -1
- package/dist/cli/874.index.js.map +1 -1
- package/dist/cli/917.index.js +5 -4
- package/dist/cli/917.index.js.map +1 -1
- package/dist/cli/index.js +19 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/lib/errors/describe-exclusive-argument-error.d.ts +4 -0
- package/dist/lib/errors/describe-required-argument-error.d.ts +4 -0
- package/dist/lib/iac/drift.d.ts +4 -1
- package/help/cli-commands/iac-describe.md +2 -2
- package/package.json +1 -1
package/dist/cli/459.index.js
CHANGED
|
@@ -219,6 +219,44 @@ class FailedToGetIacOrgSettingsError extends errors_1.CustomError {
|
|
|
219
219
|
exports.FailedToGetIacOrgSettingsError = FailedToGetIacOrgSettingsError;
|
|
220
220
|
|
|
221
221
|
|
|
222
|
+
/***/ }),
|
|
223
|
+
|
|
224
|
+
/***/ 47658:
|
|
225
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
229
|
+
exports.DescribeExclusiveArgumentError = void 0;
|
|
230
|
+
const custom_error_1 = __webpack_require__(17188);
|
|
231
|
+
const drift_1 = __webpack_require__(26445);
|
|
232
|
+
class DescribeExclusiveArgumentError extends custom_error_1.CustomError {
|
|
233
|
+
constructor() {
|
|
234
|
+
super('Please use only one of these arguments: ' +
|
|
235
|
+
drift_1.DescribeExclusiveArgs.join(', '));
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
exports.DescribeExclusiveArgumentError = DescribeExclusiveArgumentError;
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
/***/ }),
|
|
242
|
+
|
|
243
|
+
/***/ 37541:
|
|
244
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
248
|
+
exports.DescribeRequiredArgumentError = void 0;
|
|
249
|
+
const custom_error_1 = __webpack_require__(17188);
|
|
250
|
+
const drift_1 = __webpack_require__(26445);
|
|
251
|
+
class DescribeRequiredArgumentError extends custom_error_1.CustomError {
|
|
252
|
+
constructor() {
|
|
253
|
+
super('Describe command require one of these arguments: ' +
|
|
254
|
+
drift_1.DescribeRequiredArgs.join(', '));
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
exports.DescribeRequiredArgumentError = DescribeRequiredArgumentError;
|
|
258
|
+
|
|
259
|
+
|
|
222
260
|
/***/ }),
|
|
223
261
|
|
|
224
262
|
/***/ 26445:
|
|
@@ -227,7 +265,7 @@ exports.FailedToGetIacOrgSettingsError = FailedToGetIacOrgSettingsError;
|
|
|
227
265
|
|
|
228
266
|
var _a;
|
|
229
267
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
230
|
-
exports.driftignoreFromPolicy = exports.runDriftCTL = exports.parseDriftAnalysisResults = exports.translateExitCode = exports.generateGenDriftIgnoreFlags = exports.generateArgs = exports.
|
|
268
|
+
exports.driftignoreFromPolicy = exports.runDriftCTL = exports.parseDriftAnalysisResults = exports.translateExitCode = exports.generateGenDriftIgnoreFlags = exports.generateArgs = exports.validateArgs = exports.driftctlVersion = exports.DescribeRequiredArgs = exports.DescribeExclusiveArgs = exports.DCTL_EXIT_CODES = void 0;
|
|
231
269
|
const debugLib = __webpack_require__(15158);
|
|
232
270
|
const child_process = __webpack_require__(63129);
|
|
233
271
|
const os = __webpack_require__(12087);
|
|
@@ -242,14 +280,30 @@ const service_mappings_1 = __webpack_require__(16228);
|
|
|
242
280
|
const exit_codes_1 = __webpack_require__(80079);
|
|
243
281
|
const metrics_1 = __webpack_require__(32971);
|
|
244
282
|
const analytics = __webpack_require__(82744);
|
|
283
|
+
const describe_exclusive_argument_error_1 = __webpack_require__(47658);
|
|
284
|
+
const describe_required_argument_error_1 = __webpack_require__(37541);
|
|
245
285
|
const cachePath = (_a = config_1.default.CACHE_PATH) !== null && _a !== void 0 ? _a : env_paths_1.default('snyk').cache;
|
|
246
286
|
const debug = debugLib('drift');
|
|
247
|
-
exports.driftctlVersion = 'v0.23.0';
|
|
248
287
|
exports.DCTL_EXIT_CODES = {
|
|
249
288
|
EXIT_IN_SYNC: 0,
|
|
250
289
|
EXIT_NOT_IN_SYNC: 1,
|
|
251
290
|
EXIT_ERROR: 2,
|
|
252
291
|
};
|
|
292
|
+
exports.DescribeExclusiveArgs = [
|
|
293
|
+
'all',
|
|
294
|
+
'only-managed',
|
|
295
|
+
'drift',
|
|
296
|
+
'only-unmanaged',
|
|
297
|
+
];
|
|
298
|
+
exports.DescribeRequiredArgs = [
|
|
299
|
+
'all',
|
|
300
|
+
'only-managed',
|
|
301
|
+
'drift',
|
|
302
|
+
'only-unmanaged',
|
|
303
|
+
];
|
|
304
|
+
// ⚠ Keep in mind to also update driftctl version used to generate docker images
|
|
305
|
+
// You can edit base image used for snyk final image here https://github.com/snyk/snyk-images/blob/master/alpine
|
|
306
|
+
exports.driftctlVersion = 'v0.23.0';
|
|
253
307
|
const driftctlChecksums = {
|
|
254
308
|
'driftctl_windows_386.exe': 'e5befbafe2291674a4d6c8522411a44fea3549057fb46d331402d49b180202fe',
|
|
255
309
|
driftctl_darwin_amd64: '9af4e88a8e08e53ac3c373407bdd0b18a91941dc620266349f10600fc7b283d2',
|
|
@@ -266,6 +320,33 @@ const dctlBaseUrl = 'https://github.com/snyk/driftctl/releases/download/';
|
|
|
266
320
|
const driftctlPath = path.join(cachePath, 'driftctl_' + exports.driftctlVersion);
|
|
267
321
|
const driftctlDefaultOptions = ['--no-version-check'];
|
|
268
322
|
let isBinaryDownloaded = false;
|
|
323
|
+
exports.validateArgs = (options) => {
|
|
324
|
+
if (options.kind === 'describe') {
|
|
325
|
+
return validateDescribeArgs(options);
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
const validateDescribeArgs = (options) => {
|
|
329
|
+
// Check that there is no more than one of the exclusive arguments
|
|
330
|
+
let count = 0;
|
|
331
|
+
for (const describeExclusiveArg of exports.DescribeExclusiveArgs) {
|
|
332
|
+
if (options[describeExclusiveArg]) {
|
|
333
|
+
count++;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
if (count > 1) {
|
|
337
|
+
throw new describe_exclusive_argument_error_1.DescribeExclusiveArgumentError();
|
|
338
|
+
}
|
|
339
|
+
// Check we have one of the required arguments
|
|
340
|
+
count = 0;
|
|
341
|
+
for (const describeRequiredArgs of exports.DescribeRequiredArgs) {
|
|
342
|
+
if (options[describeRequiredArgs]) {
|
|
343
|
+
count++;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
if (count === 0) {
|
|
347
|
+
throw new describe_required_argument_error_1.DescribeRequiredArgumentError();
|
|
348
|
+
}
|
|
349
|
+
};
|
|
269
350
|
exports.generateArgs = (options) => {
|
|
270
351
|
if (options.kind === 'describe') {
|
|
271
352
|
return generateScanFlags(options);
|
|
@@ -330,9 +411,9 @@ const generateScanFlags = (options) => {
|
|
|
330
411
|
}
|
|
331
412
|
args.push('--output');
|
|
332
413
|
args.push('json://stdout');
|
|
333
|
-
if (options
|
|
414
|
+
if (options['fetch-tfstate-headers']) {
|
|
334
415
|
args.push('--headers');
|
|
335
|
-
args.push(options
|
|
416
|
+
args.push(options['fetch-tfstate-headers']);
|
|
336
417
|
}
|
|
337
418
|
if (options['tfc-token']) {
|
|
338
419
|
args.push('--tfc-token');
|
|
@@ -352,7 +433,7 @@ const generateScanFlags = (options) => {
|
|
|
352
433
|
if (options.deep) {
|
|
353
434
|
args.push('--deep');
|
|
354
435
|
}
|
|
355
|
-
if (options['only-managed']) {
|
|
436
|
+
if (options['only-managed'] || options.drift) {
|
|
356
437
|
args.push('--only-managed');
|
|
357
438
|
}
|
|
358
439
|
if (options['only-unmanaged']) {
|
|
@@ -418,7 +499,8 @@ exports.parseDriftAnalysisResults = (input) => {
|
|
|
418
499
|
};
|
|
419
500
|
exports.runDriftCTL = async ({ options, input, stdio, }) => {
|
|
420
501
|
const path = await findOrDownload();
|
|
421
|
-
|
|
502
|
+
await exports.validateArgs(options);
|
|
503
|
+
const args = await exports.generateArgs(options);
|
|
422
504
|
if (!stdio) {
|
|
423
505
|
stdio = ['pipe', 'pipe', 'inherit'];
|
|
424
506
|
}
|
|
@@ -489,6 +571,16 @@ async function findDriftCtl() {
|
|
|
489
571
|
debug('Found driftctl in cache: %s', dctlPath);
|
|
490
572
|
return dctlPath;
|
|
491
573
|
}
|
|
574
|
+
// lookup in /bin
|
|
575
|
+
// when used in a docker context the default binary path should be used
|
|
576
|
+
{
|
|
577
|
+
dctlPath = '/bin/driftctl';
|
|
578
|
+
const exists = await isExe(dctlPath);
|
|
579
|
+
if (exists) {
|
|
580
|
+
debug('Found driftctl in %s', dctlPath);
|
|
581
|
+
return dctlPath;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
492
584
|
debug('driftctl not found');
|
|
493
585
|
return '';
|
|
494
586
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"459.index.js","mappings":";;;;;;;;;;;AAAA,4CAAqD;AACrD,0CAAqC;AACrC,iDAAmD;AACnD,2CAA6E;AAE7E,MAAM,IAAI,GAA2B;IACnC,KAAK;IACL,OAAO;IACP,UAAU;IACV,gBAAgB;IAChB,mBAAmB;IACnB,OAAO;IACP,MAAM;IACN,OAAO;IACP,kBAAkB;IAClB,mBAAmB;IACnB,GAAG;IACH,SAAS;IACT,GAAG;IACH,MAAM;IACN,GAAG;IACH,OAAO;IACP,MAAM;IACN,QAAQ;IAER,gBAAgB;IAChB,eAAe;IACf,aAAa;CACd,CAAC;AACF,MAAM,OAAO,GAAG,IAAI,GAAG,CAAS,IAAI,CAAC,CAAC;AAEtC,SAAS,eAAe,CAAC,GAAW;IAClC,OAAO,GAAG,CA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IAAI,gBAAgB,IAAI,EAAE,EAAE;YACvC,6EAA6E;YAC7E,IAAI,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;gBACzB,SAAS;aACV;YACD,GAAG,IAAI,KAAK,EAAE,EAAE,CAAC;YACjB,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;SACvB;KACF;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAlBD,gEAkBC;AAED,MAAa,mBAAoB,SAAQ,oBAAW;IAClD,YAAY,GAAW;QACrB,KAAK,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,IAAI,GAAG,qBAAa,CAAC,mBAAmB,CAAC;QAC9C,IAAI,CAAC,OAAO,GAAG,gCAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,WAAW,GAAG,GAAG,CAAC;IACzB,CAAC;CACF;AAPD,kDAOC","sources":["webpack://snyk/./src/cli/commands/test/iac-local-execution/assert-iac-options-flag.ts","webpack://snyk/./src/cli/commands/test/iac-local-execution/error-utils.ts","webpack://snyk/./src/cli/commands/test/iac-local-execution/org-settings/get-iac-org-settings.ts","webpack://snyk/./src/lib/iac/drift.ts","webpack://snyk/./src/lib/iac/service-mappings.ts"],"sourcesContent":["import { CustomError } from '../../../../lib/errors';\nimport { args } from '../../../args';\nimport { getErrorStringCode } from './error-utils';\nimport { IaCErrorCodes, IaCTestFlags, TerraformPlanScanMode } from './types';\n\nconst keys: (keyof IaCTestFlags)[] = [\n 'org',\n 'debug',\n 'insecure',\n 'detectionDepth',\n 'severityThreshold',\n 'rules',\n 'json',\n 'sarif',\n 'json-file-output',\n 'sarif-file-output',\n 'v',\n 'version',\n 'h',\n 'help',\n 'q',\n 'quiet',\n 'scan',\n 'report',\n\n // PolicyOptions\n 'ignore-policy',\n 'policy-path',\n];\nconst allowed = new Set<string>(keys);\n\nfunction camelcaseToDash(key: string) {\n return key.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase());\n}\n\nfunction getFlagName(key: string) {\n const dashes = key.length === 1 ? '-' : '--';\n const flag = camelcaseToDash(key);\n return `${dashes}${flag}`;\n}\n\nexport class FlagError extends CustomError {\n constructor(key: string) {\n const flag = getFlagName(key);\n const msg = `Unsupported flag \"${flag}\" provided. Run snyk iac test --help for supported flags`;\n super(msg);\n this.code = IaCErrorCodes.FlagError;\n this.strCode = getErrorStringCode(this.code);\n this.userMessage = msg;\n }\n}\n\nexport class FeatureFlagError extends CustomError {\n constructor(key: string, featureFlag: string, hasSnykPreview?: boolean) {\n const flag = getFlagName(key);\n let msg;\n if (hasSnykPreview) {\n msg = `Flag \"${flag}\" is only supported if feature flag '${featureFlag}' is enabled. The feature flag can be enabled via Snyk Preview if you are on the Enterprise Plan`;\n } else {\n msg = `Flag \"${flag}\" is only supported if feature flag \"${featureFlag}\" is enabled. To enable it, please contact Snyk support.`;\n }\n super(msg);\n this.code = IaCErrorCodes.FeatureFlagError;\n this.strCode = getErrorStringCode(this.code);\n this.userMessage = msg;\n }\n}\n\nexport class FlagValueError extends CustomError {\n constructor(key: string, value: string) {\n const flag = getFlagName(key);\n const msg = `Unsupported value \"${value}\" provided to flag \"${flag}\".\\nSupported values are: ${SUPPORTED_TF_PLAN_SCAN_MODES.join(\n ', ',\n )}`;\n super(msg);\n this.code = IaCErrorCodes.FlagValueError;\n this.strCode = getErrorStringCode(this.code);\n this.userMessage = msg;\n }\n}\n\nexport class UnsupportedEntitlementFlagError extends CustomError {\n constructor(key: string, entitlementName: string) {\n const flag = getFlagName(key);\n super(\n `Unsupported flag: ${flag} - Missing the ${entitlementName} entitlement`,\n );\n this.code = IaCErrorCodes.UnsupportedEntitlementFlagError;\n this.strCode = getErrorStringCode(this.code);\n this.userMessage = `Flag \"${flag}\" is currently not supported for this org. To enable it, please contact snyk support.`;\n }\n}\n\nexport class UnsupportedEntitlementCommandError extends CustomError {\n constructor(key: string, entitlementName: string) {\n super(\n `Unsupported command: ${key} - Missing the ${entitlementName} entitlement`,\n );\n this.code = IaCErrorCodes.UnsupportedEntitlementFlagError;\n this.strCode = getErrorStringCode(this.code);\n this.userMessage = `Command \"${key}\" is currently not supported for this org. To enable it, please contact snyk support.`;\n }\n}\n\n/**\n * Validates the command line flags passed to the snyk iac test\n * command. The current argument parsing is very permissive and\n * allows unknown flags to be provided without valdiation.\n *\n * For snyk iac we need to explictly validate the flags to avoid\n * misconfigurations and typos. For example, if the --experimental\n * flag were to be mis-spelled we would end up sending the client\n * data to our backend rather than running it locally as intended.\n * @param argv command line args passed to the process\n */\nexport function assertIaCOptionsFlags(argv: string[]) {\n // We process the process.argv so we don't get default values.\n const parsed = args(argv);\n for (const key of Object.keys(parsed.options)) {\n // The _ property is a special case that contains non\n // flag strings passed to the command line (usually files)\n // and `iac` is the command provided.\n if (key !== '_' && key !== 'iac' && !allowed.has(key)) {\n throw new FlagError(key);\n }\n }\n\n if (parsed.options.scan) {\n assertTerraformPlanModes(parsed.options.scan as string);\n }\n}\n\nconst SUPPORTED_TF_PLAN_SCAN_MODES = [\n TerraformPlanScanMode.DeltaScan,\n TerraformPlanScanMode.FullScan,\n];\n\nfunction assertTerraformPlanModes(scanModeArgValue: string) {\n if (\n !SUPPORTED_TF_PLAN_SCAN_MODES.includes(\n scanModeArgValue as TerraformPlanScanMode,\n )\n ) {\n throw new FlagValueError('scan', scanModeArgValue);\n }\n}\n\nexport function isIacShareResultsOptions(options) {\n return options.iac && options.report;\n}\n","import { IaCErrorCodes } from './types';\n\nexport function getErrorStringCode(code: number): string {\n const errorName = IaCErrorCodes[code];\n if (!errorName) {\n return 'INVALID_IAC_ERROR';\n }\n let result = errorName.replace(/([A-Z])/g, '_$1');\n if (result.charAt(0) === '_') {\n result = result.substring(1);\n }\n return result.toUpperCase();\n}\n","import { IaCErrorCodes, IacOrgSettings } from '../types';\nimport { Payload } from '../../../../../lib/snyk-test/types';\nimport config from '../../../../../lib/config';\nimport { isCI } from '../../../../../lib/is-ci';\nimport { api } from '../../../../../lib/api-token';\nimport { makeRequest } from '../../../../../lib/request';\nimport { CustomError } from '../../../../../lib/errors';\nimport { getErrorStringCode } from '../error-utils';\n\nexport function getIacOrgSettings(\n publicOrgId?: string,\n): Promise<IacOrgSettings> {\n const payload: Payload = {\n method: 'get',\n url: config.API + '/iac-org-settings',\n json: true,\n qs: { org: publicOrgId },\n headers: {\n 'x-is-ci': isCI(),\n authorization: `token ${api()}`,\n },\n };\n\n return new Promise((resolve, reject) => {\n makeRequest(payload, (error, res) => {\n if (error) {\n return reject(error);\n }\n if (res.statusCode < 200 || res.statusCode > 299) {\n return reject(new FailedToGetIacOrgSettingsError());\n }\n resolve(res.body);\n });\n });\n}\n\nexport class FailedToGetIacOrgSettingsError extends CustomError {\n constructor(message?: string) {\n super(message || 'Failed to fetch IaC organization settings');\n this.code = IaCErrorCodes.FailedToGetIacOrgSettingsError;\n this.strCode = getErrorStringCode(this.code);\n this.userMessage =\n 'We failed to fetch your organization settings, including custom severity overrides for infrastructure-as-code policies. Please run the command again with the `-d` flag and contact support@snyk.io with the contents of the output.';\n }\n}\n","import * as debugLib from 'debug';\nimport * as child_process from 'child_process';\nimport { StdioOptions } from 'child_process';\nimport * as os from 'os';\nimport envPaths from 'env-paths';\nimport * as fs from 'fs';\nimport { spinner } from '../spinner';\nimport { makeRequest } from '../request';\nimport config from '../../lib/config';\nimport * as path from 'path';\nimport * as crypto from 'crypto';\nimport {\n createIgnorePattern,\n verifyServiceMappingExists,\n} from './service-mappings';\nimport { EXIT_CODES } from '../../cli/exit-codes';\nimport {\n DescribeOptions,\n DriftAnalysis,\n DriftctlExecutionResult,\n DriftCTLOptions,\n FmtOptions,\n GenDriftIgnoreOptions,\n} from './types';\nimport { TimerMetricInstance } from '../metrics';\nimport * as analytics from '../../lib/analytics';\nimport { Policy } from '../policy/find-and-load-policy';\n\nconst cachePath = config.CACHE_PATH ?? envPaths('snyk').cache;\nconst debug = debugLib('drift');\n\nexport const driftctlVersion = 'v0.23.0';\n\nexport const DCTL_EXIT_CODES = {\n EXIT_IN_SYNC: 0,\n EXIT_NOT_IN_SYNC: 1,\n EXIT_ERROR: 2,\n};\n\nconst driftctlChecksums = {\n 'driftctl_windows_386.exe':\n 'e5befbafe2291674a4d6c8522411a44fea3549057fb46d331402d49b180202fe',\n driftctl_darwin_amd64:\n '9af4e88a8e08e53ac3c373407bdd0b18a91941dc620266349f10600fc7b283d2',\n driftctl_linux_386:\n '6cd2719f81210017e3f67677cb92f4b0060976a3588c220b4af6b2dda174df8f',\n driftctl_linux_amd64:\n 'd714a3d11056169f4c4cc047b48b4d732f5df8cdfbc00e40c3e5f6e6cc5ead3e',\n driftctl_linux_arm64:\n '24812c8b2ec2d8e3d619317e76fbba0d8e7e263fc2c26cba26265a9656e8fe91',\n 'driftctl_windows_arm64.exe':\n 'd84461f0ba63b59aec66393fa67147f4157b5bddc02a19315d737c5f5a46c07b',\n driftctl_darwin_arm64:\n 'b711143d9331a10fc34c202284f67ce5eeb0348baca546b47af139f418f812c1',\n 'driftctl_windows_arm.exe':\n 'b5d24e1407c24ddfff63ffbba85eb1dc13473e2fd36e3e99e5e1762cf615f011',\n driftctl_linux_arm:\n '089665efa8a7c5e95b3cee9ace85fc5b0f2d7f2a29c351f2d3dbef3dae553e2d',\n 'driftctl_windows_amd64.exe':\n 'bf7310277eeccc2679b529c1f1d2ced30e877949a6d7c5606eb2d4c2ec033b66',\n};\n\nconst dctlBaseUrl = 'https://github.com/snyk/driftctl/releases/download/';\nconst driftctlPath = path.join(cachePath, 'driftctl_' + driftctlVersion);\nconst driftctlDefaultOptions = ['--no-version-check'];\nlet isBinaryDownloaded = false;\n\nexport const generateArgs = (options: DriftCTLOptions): string[] => {\n if (options.kind === 'describe') {\n return generateScanFlags(options as DescribeOptions);\n }\n\n if (options.kind === 'gen-driftignore') {\n return generateGenDriftIgnoreFlags(options as GenDriftIgnoreOptions);\n }\n\n if (options.kind === 'fmt') {\n return generateFmtFlags(options as FmtOptions);\n }\n\n throw 'Unsupported command';\n};\n\nexport const generateGenDriftIgnoreFlags = (\n options: GenDriftIgnoreOptions,\n): string[] => {\n const args: string[] = ['gen-driftignore', ...driftctlDefaultOptions];\n\n if (options.input) {\n args.push('--input');\n args.push(options.input);\n }\n\n if (options.output) {\n args.push('--output');\n args.push(options.output);\n }\n\n if (options['exclude-changed']) {\n args.push('--exclude-changed');\n }\n\n if (options['exclude-missing']) {\n args.push('--exclude-missing');\n }\n\n if (options['exclude-unmanaged']) {\n args.push('--exclude-unmanaged');\n }\n\n return args;\n};\n\nconst generateFmtFlags = (options: FmtOptions): string[] => {\n const args: string[] = ['fmt', ...driftctlDefaultOptions];\n\n if (options.json) {\n args.push('--output');\n args.push('json://stdout');\n }\n\n if (options['json-file-output']) {\n args.push('--output');\n args.push('json://' + options['json-file-output']);\n }\n\n if (options.html) {\n args.push('--output');\n args.push('html://stdout');\n }\n\n if (options['html-file-output']) {\n args.push('--output');\n args.push('html://' + options['html-file-output']);\n }\n\n return args;\n};\n\nconst generateScanFlags = (options: DescribeOptions): string[] => {\n const args: string[] = ['scan', ...driftctlDefaultOptions];\n\n if (options.quiet) {\n args.push('--quiet');\n }\n\n if (options.filter) {\n args.push('--filter');\n args.push(options.filter);\n }\n\n args.push('--output');\n args.push('json://stdout');\n\n if (options.headers) {\n args.push('--headers');\n args.push(options.headers);\n }\n\n if (options['tfc-token']) {\n args.push('--tfc-token');\n args.push(options['tfc-token']);\n }\n\n if (options['tfc-endpoint']) {\n args.push('--tfc-endpoint');\n args.push(options['tfc-endpoint']);\n }\n\n if (options['tf-provider-version']) {\n args.push('--tf-provider-version');\n args.push(options['tf-provider-version']);\n }\n\n if (options.strict) {\n args.push('--strict');\n }\n\n if (options.deep) {\n args.push('--deep');\n }\n\n if (options['only-managed']) {\n args.push('--only-managed');\n }\n\n if (options['only-unmanaged']) {\n args.push('--only-unmanaged');\n }\n\n if (options.driftignore) {\n args.push('--driftignore');\n args.push(options.driftignore);\n }\n\n if (options['tf-lockfile']) {\n args.push('--tf-lockfile');\n args.push(options['tf-lockfile']);\n }\n\n if (options.ignore && options.ignore.length > 0) {\n args.push('--ignore');\n args.push(options.ignore.join(','));\n }\n\n let configDir = cachePath;\n createIfNotExists(cachePath);\n if (options['config-dir']) {\n configDir = options['config-dir'];\n }\n args.push('--config-dir');\n args.push(configDir);\n\n if (options.from) {\n const froms = options.from.split(',');\n for (const f of froms) {\n args.push('--from');\n args.push(f);\n }\n }\n\n let to = 'aws+tf';\n if (options.to) {\n to = options.to;\n }\n args.push('--to');\n args.push(to);\n\n if (options.service) {\n const services = options.service.split(',');\n verifyServiceMappingExists(services);\n args.push('--ignore');\n args.push(createIgnorePattern(services));\n }\n\n debug(args);\n\n return args;\n};\n\nexport function translateExitCode(exitCode: number | null): number {\n switch (exitCode) {\n case DCTL_EXIT_CODES.EXIT_IN_SYNC:\n return 0;\n case DCTL_EXIT_CODES.EXIT_NOT_IN_SYNC:\n return EXIT_CODES.VULNS_FOUND;\n case DCTL_EXIT_CODES.EXIT_ERROR:\n return EXIT_CODES.ERROR;\n default:\n debug('driftctl returned %d', exitCode);\n return EXIT_CODES.ERROR;\n }\n}\n\nexport const parseDriftAnalysisResults = (input: string): DriftAnalysis => {\n return JSON.parse(input) as DriftAnalysis;\n};\n\nexport const runDriftCTL = async ({\n options,\n input,\n stdio,\n}: {\n options: DriftCTLOptions;\n input?: string;\n stdio?: StdioOptions;\n}): Promise<DriftctlExecutionResult> => {\n const path = await findOrDownload();\n const args = generateArgs(options);\n\n if (!stdio) {\n stdio = ['pipe', 'pipe', 'inherit'];\n }\n\n debug('running driftctl %s ', args.join(' '));\n\n const p = child_process.spawn(path, args, {\n stdio,\n env: { ...process.env, DCTL_IS_SNYK: 'true' },\n });\n\n let stdout = '';\n return new Promise<DriftctlExecutionResult>((resolve, reject) => {\n if (input) {\n p.stdin?.write(input);\n p.stdin?.end();\n }\n p.on('error', (error) => {\n reject(error);\n });\n\n p.stdout?.on('data', (data) => {\n stdout += data;\n });\n\n p.on('exit', (code) => {\n resolve({ code: translateExitCode(code), stdout });\n });\n });\n};\n\nasync function findOrDownload(): Promise<string> {\n let dctl = await findDriftCtl();\n if (isBinaryDownloaded) {\n return dctl;\n }\n let downloadDuration = 0;\n let binaryExist = true;\n if (dctl === '') {\n binaryExist = false;\n try {\n createIfNotExists(cachePath);\n dctl = driftctlPath;\n\n const duration = new TimerMetricInstance('driftctl_download');\n duration.start();\n await download(driftctlUrl(), dctl);\n duration.stop();\n\n downloadDuration = Math.round((duration.getValue() as number) / 1000);\n } catch (err) {\n return Promise.reject(err);\n }\n }\n analytics.add('iac-drift-binary-already-exist', binaryExist);\n analytics.add('iac-drift-binary-download-duration-seconds', downloadDuration);\n isBinaryDownloaded = true;\n return dctl;\n}\n\nasync function findDriftCtl(): Promise<string> {\n // lookup in custom path contained in env var DRIFTCTL_PATH\n let dctlPath = config.DRIFTCTL_PATH;\n if (dctlPath != null) {\n const exists = await isExe(dctlPath);\n if (exists) {\n debug('Found driftctl in $DRIFTCTL_PATH: %s', dctlPath);\n return dctlPath;\n }\n }\n\n // lookup in app cache\n dctlPath = driftctlPath;\n const exists = await isExe(dctlPath);\n if (exists) {\n debug('Found driftctl in cache: %s', dctlPath);\n return dctlPath;\n }\n debug('driftctl not found');\n\n return '';\n}\n\nasync function download(url, destination: string): Promise<boolean> {\n debug('downloading driftctl into %s', destination);\n\n const payload = {\n method: 'GET',\n url: url,\n output: destination,\n follow: 3,\n };\n\n await spinner('Downloading...');\n return new Promise<boolean>((resolve, reject) => {\n makeRequest(payload, function(err, res, body) {\n try {\n if (err) {\n reject(\n new Error('Could not download driftctl from ' + url + ': ' + err),\n );\n return;\n }\n if (res.statusCode !== 200) {\n reject(\n new Error(\n 'Could not download driftctl from ' + url + ': ' + res.statusCode,\n ),\n );\n return;\n }\n\n validateChecksum(body);\n\n fs.writeFileSync(destination, body);\n debug('File saved: ' + destination);\n\n fs.chmodSync(destination, 0o744);\n resolve(true);\n } finally {\n spinner.clearAll();\n }\n });\n });\n}\n\nfunction validateChecksum(body: string) {\n // only validate if we downloaded the official driftctl binary\n if (config.DRIFTCTL_URL || config.DRIFTCTL_PATH) {\n return;\n }\n\n const computedHash = crypto\n .createHash('sha256')\n .update(body)\n .digest('hex');\n const givenHash = driftctlChecksums[driftctlFileName()];\n\n if (computedHash != givenHash) {\n throw new Error('Downloaded file has inconsistent checksum...');\n }\n}\n\nfunction driftctlFileName(): string {\n let platform = 'linux';\n switch (os.platform()) {\n case 'darwin':\n platform = 'darwin';\n break;\n case 'win32':\n platform = 'windows';\n break;\n }\n\n let arch = 'amd64';\n switch (os.arch()) {\n case 'ia32':\n case 'x32':\n arch = '386';\n break;\n case 'arm':\n arch = 'arm';\n break;\n case 'arm64':\n arch = 'arm64';\n break;\n }\n\n let ext = '';\n switch (os.platform()) {\n case 'win32':\n ext = '.exe';\n break;\n }\n\n return `driftctl_${platform}_${arch}${ext}`;\n}\n\nfunction driftctlUrl(): string {\n if (config.DRIFTCTL_URL) {\n return config.DRIFTCTL_URL;\n }\n\n return `${dctlBaseUrl}/${driftctlVersion}/${driftctlFileName()}`;\n}\n\nfunction isExe(dctlPath: string): Promise<boolean> {\n return new Promise<boolean>((resolve) => {\n fs.access(dctlPath, fs.constants.X_OK, (err) => {\n if (err) {\n resolve(false);\n return;\n }\n resolve(true);\n });\n });\n}\n\nfunction createIfNotExists(path: string) {\n if (!fs.existsSync(path)) {\n fs.mkdirSync(path, { recursive: true });\n }\n}\n\nexport function driftignoreFromPolicy(policy: Policy | undefined): string[] {\n const excludeSection = 'iac-drift';\n if (!policy || !policy.exclude || !(excludeSection in policy.exclude)) {\n return [];\n }\n return policy.exclude[excludeSection];\n}\n","import { CustomError } from '../errors';\nimport { IaCErrorCodes } from '../../cli/commands/test/iac-local-execution/types';\nimport { getErrorStringCode } from '../../cli/commands/test/iac-local-execution/error-utils';\n\nexport const services2resources = new Map<string, Array<string>>([\n // Amazon\n [\n 'aws_s3',\n [\n 'aws_s3_bucket',\n 'aws_s3_bucket_analytics_configuration',\n 'aws_s3_bucket_inventory',\n 'aws_s3_bucket_metric',\n 'aws_s3_bucket_notification',\n 'aws_s3_bucket_policy',\n ],\n ],\n [\n 'aws_ec2',\n [\n 'aws_instance',\n 'aws_key_pair',\n 'aws_ami',\n 'aws_ebs_snapshot',\n 'aws_ebs_volume',\n 'aws_eip',\n 'aws_eip_association',\n 'aws_volume_attachment',\n 'aws_launch_configuration',\n 'aws_launch_template',\n ],\n ],\n ['aws_lambda', ['aws_lambda_function', 'aws_lambda_event_source_mapping']],\n [\n 'aws_rds',\n [\n 'aws_db_instance',\n 'aws_db_subnet_group',\n 'aws_rds_cluster',\n 'aws_rds_cluster_endpoint',\n 'aws_rds_cluster_instance',\n ],\n ],\n ['aws_route53', ['aws_route53_record', 'aws_route53_zone']],\n [\n 'aws_iam',\n [\n 'aws_iam_access_key',\n 'aws_iam_policy',\n 'aws_iam_policy_attachment',\n 'aws_iam_role',\n 'aws_iam_role_policy',\n 'aws_iam_role_policy_attachment',\n 'aws_iam_user',\n 'aws_iam_user_policy',\n 'aws_iam_user_policy_attachment',\n ],\n ],\n [\n 'aws_vpc',\n [\n 'aws_security_group',\n 'aws_security_group_rule',\n 'aws_subnet',\n 'aws_default_vpc',\n 'aws_vpc',\n 'aws_default_security_group',\n 'aws_route_table',\n 'aws_default_route_table',\n 'aws_route',\n 'aws_route_table_association',\n 'aws_nat_gateway',\n 'aws_internet_gateway',\n ],\n ],\n [\n 'aws_api_gateway',\n [\n 'aws_api_gateway_resource',\n 'aws_api_gateway_rest_api',\n 'aws_api_gateway_account',\n 'aws_api_gateway_api_key',\n 'aws_api_gateway_authorizer',\n 'aws_api_gateway_base_path_mapping',\n 'aws_api_gateway_domain_name',\n 'aws_api_gateway_gateway_response',\n 'aws_api_gateway_integration',\n 'aws_api_gateway_integration_response',\n 'aws_api_gateway_method',\n 'aws_api_gateway_method_response',\n 'aws_api_gateway_method_settings',\n 'aws_api_gateway_model',\n 'aws_api_gateway_request_validator',\n 'aws_api_gateway_rest_api_policy',\n 'aws_api_gateway_stage',\n 'aws_api_gateway_vpc_link',\n ],\n ],\n [\n 'aws_apigatewayv2',\n [\n 'aws_apigatewayv2_api',\n 'aws_apigatewayv2_api_mapping',\n 'aws_apigatewayv2_authorizer',\n 'aws_apigatewayv2_deployment',\n 'aws_apigatewayv2_domain_name',\n 'aws_apigatewayv2_integration',\n 'aws_apigatewayv2_integration_response',\n 'aws_apigatewayv2_model',\n 'aws_apigatewayv2_route',\n 'aws_apigatewayv2_route_response',\n 'aws_apigatewayv2_stage',\n 'aws_apigatewayv2_vpc_link',\n ],\n ],\n ['aws_sqs', ['aws_sqs_queue', 'aws_sqs_queue_policy']],\n [\n 'aws_sns',\n ['aws_sns_topic', 'aws_sns_topic_policy', 'aws_sns_topic_subscription'],\n ],\n ['aws_ecr', ['aws_ecr_repository']],\n ['aws_cloudfront', ['aws_cloudfront_distribution']],\n ['aws_kms', ['aws_kms_key', 'aws_kms_alias']],\n ['aws_dynamodb', ['aws_dynamodb_table']],\n // Azure\n ['azure_base', ['azurerm_resource_group']],\n ['azure_compute', ['azurerm_image', 'azurerm_ssh_public_key']],\n ['azure_storage', ['azurerm_storage_account', 'azurerm_storage_container']],\n [\n 'azure_network',\n [\n 'azurerm_resource_group',\n 'azurerm_subnet',\n 'azurerm_public_ip',\n 'azurerm_firewall',\n 'azurerm_route',\n 'azurerm_route_table',\n 'azurerm_network_security_group',\n ],\n ],\n ['azure_container', ['azurerm_container_registry']],\n [\n 'azure_database',\n ['azurerm_postgresql_server', 'azurerm_postgresql_database'],\n ],\n ['azure_loadbalancer', ['azurerm_lb', 'azurerm_lb_rule']],\n [\n 'azure_private_dns',\n [\n 'azurerm_private_dns_a_record',\n 'azurerm_private_dns_aaaa_record',\n 'azurerm_private_dns_cname_record',\n 'azurerm_private_dns_mx_record',\n 'azurerm_private_dns_ptr_record',\n 'azurerm_private_dns_srv_record',\n 'azurerm_private_dns_txt_record',\n 'azurerm_private_dns_zone',\n ],\n ],\n\n // Google\n [\n 'google_cloud_platform',\n [\n 'google_project_iam_binding',\n 'google_project_iam_member',\n 'google_project_iam_policy',\n ],\n ],\n [\n 'google_cloud_storage',\n [\n 'google_storage_bucket',\n 'google_storage_bucket_iam_binding',\n 'google_storage_bucket_iam_member',\n 'google_storage_bucket_iam_policy',\n ],\n ],\n [\n 'google_compute_engine',\n [\n 'google_compute_address',\n 'google_compute_disk',\n 'google_compute_global_address',\n 'google_compute_firewall',\n 'google_compute_health_check',\n 'google_compute_image',\n 'google_compute_instance',\n 'google_compute_instance_group',\n 'google_compute_network',\n 'google_compute_node_group',\n 'google_compute_router',\n 'google_compute_subnetwork',\n ],\n ],\n ['google_cloud_dns', ['google_dns_managed_zone']],\n [\n 'google_cloud_bigtable',\n ['google_bigtable_instance', 'google_bigtable_table'],\n ],\n [\n 'google_cloud_bigquery',\n ['google_bigquery_table', 'google_bigquery_dataset'],\n ],\n ['google_cloud_functions', ['google_cloudfunctions_function']],\n ['google_cloud_sql', ['google_sql_database_instance']],\n ['google_cloud_run', ['google_cloud_run_service']],\n]);\n\nexport function verifyServiceMappingExists(services: string[]): void {\n if (services.length == 0) {\n throw new InvalidServiceError('');\n }\n for (const s of services) {\n if (!services2resources.has(s)) {\n throw new InvalidServiceError(\n `We were unable to match service \"${s}\". Please provide a valid service name: ${existingServiceNames()}`,\n );\n }\n }\n}\n\nfunction existingServiceNames(): string {\n let res = '';\n for (const s of services2resources.keys()) {\n res += `${s},`;\n }\n return res.substring(0, res.length - 1);\n}\n\nexport function createIgnorePattern(services: string[]): string {\n return createIgnorePatternWithMap(services, services2resources);\n}\n\nexport function createIgnorePatternWithMap(\n services: string[],\n serviceMap: Map<string, Array<string>>,\n): string {\n let res = '*';\n const seenResources = new Set<string>();\n for (const s of services) {\n const resourcePatterns = serviceMap.get(s);\n for (const rp of resourcePatterns || []) {\n // A resource might belong to multiple services, skip it if already processed\n if (seenResources.has(rp)) {\n continue;\n }\n res += `,!${rp}`;\n seenResources.add(rp);\n }\n }\n return res;\n}\n\nexport class InvalidServiceError extends CustomError {\n constructor(msg: string) {\n super(msg);\n this.code = IaCErrorCodes.InvalidServiceError;\n this.strCode = getErrorStringCode(this.code);\n this.userMessage = msg;\n }\n}\n"],"names":[],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"459.index.js","mappings":";;;;;;;;;;;AAAA,4CAAqD;AACrD,0CAAqC;AACrC,iDAAmD;AACnD,2CAA6E;AAE7E,MAAM,IAAI,GAA2B;IACnC,KAAK;IACL,OAAO;IACP,UAAU;IACV,gBAAgB;IAChB,mBAAmB;IACnB,OAAO;IACP,MAAM;IACN,OAAO;IACP,kBAAkB;IAClB,mBAAmB;IACnB,GAAG;IACH,SAAS;IACT,GAAG;IACH,MAAM;IACN,GAAG;IACH,OAAO;IACP,MAAM;IACN,QAAQ;IAER,gBAAgB;IAChB,eAAe;IACf,aAAa;CACd,CAAC;AACF,MAAM,OAAO,GAAG,IAAI,GAAG,CAAS,IAAI,CAAC,CAAC;AAEtC,SAAS,eAAe,CAAC,GAAW;IAClC,OAAO,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AAC7D,CAAC;AAED,SAAS,WAAW,CAAC,GAAW;IAC9B,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7C,MAAM,IAAI,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;IAClC,OAAO,GAAG,MAAM,GAAG,IAAI,EAAE,CAAC;AAC5B,CAAC;AAED,MAAa,SAAU,SAAQ,oBAAW;IACxC,YAAY,GAAW;QACrB,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;QAC9B,MAAM,GAAG,GAAG,qBAAqB,IAAI,0DAA0D,CAAC;QAChG,KAAK,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,IAA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EAAE,EAAE,CAAC;YACjB,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;SACvB;KACF;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAlBD,gEAkBC;AAED,MAAa,mBAAoB,SAAQ,oBAAW;IAClD,YAAY,GAAW;QACrB,KAAK,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,IAAI,GAAG,qBAAa,CAAC,mBAAmB,CAAC;QAC9C,IAAI,CAAC,OAAO,GAAG,gCAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,WAAW,GAAG,GAAG,CAAC;IACzB,CAAC;CACF;AAPD,kDAOC","sources":["webpack://snyk/./src/cli/commands/test/iac-local-execution/assert-iac-options-flag.ts","webpack://snyk/./src/cli/commands/test/iac-local-execution/error-utils.ts","webpack://snyk/./src/cli/commands/test/iac-local-execution/org-settings/get-iac-org-settings.ts","webpack://snyk/./src/lib/errors/describe-exclusive-argument-error.ts","webpack://snyk/./src/lib/errors/describe-required-argument-error.ts","webpack://snyk/./src/lib/iac/drift.ts","webpack://snyk/./src/lib/iac/service-mappings.ts"],"sourcesContent":["import { CustomError } from '../../../../lib/errors';\nimport { args } from '../../../args';\nimport { getErrorStringCode } from './error-utils';\nimport { IaCErrorCodes, IaCTestFlags, TerraformPlanScanMode } from './types';\n\nconst keys: (keyof IaCTestFlags)[] = [\n 'org',\n 'debug',\n 'insecure',\n 'detectionDepth',\n 'severityThreshold',\n 'rules',\n 'json',\n 'sarif',\n 'json-file-output',\n 'sarif-file-output',\n 'v',\n 'version',\n 'h',\n 'help',\n 'q',\n 'quiet',\n 'scan',\n 'report',\n\n // PolicyOptions\n 'ignore-policy',\n 'policy-path',\n];\nconst allowed = new Set<string>(keys);\n\nfunction camelcaseToDash(key: string) {\n return key.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase());\n}\n\nfunction getFlagName(key: string) {\n const dashes = key.length === 1 ? '-' : '--';\n const flag = camelcaseToDash(key);\n return `${dashes}${flag}`;\n}\n\nexport class FlagError extends CustomError {\n constructor(key: string) {\n const flag = getFlagName(key);\n const msg = `Unsupported flag \"${flag}\" provided. Run snyk iac test --help for supported flags`;\n super(msg);\n this.code = IaCErrorCodes.FlagError;\n this.strCode = getErrorStringCode(this.code);\n this.userMessage = msg;\n }\n}\n\nexport class FeatureFlagError extends CustomError {\n constructor(key: string, featureFlag: string, hasSnykPreview?: boolean) {\n const flag = getFlagName(key);\n let msg;\n if (hasSnykPreview) {\n msg = `Flag \"${flag}\" is only supported if feature flag '${featureFlag}' is enabled. The feature flag can be enabled via Snyk Preview if you are on the Enterprise Plan`;\n } else {\n msg = `Flag \"${flag}\" is only supported if feature flag \"${featureFlag}\" is enabled. To enable it, please contact Snyk support.`;\n }\n super(msg);\n this.code = IaCErrorCodes.FeatureFlagError;\n this.strCode = getErrorStringCode(this.code);\n this.userMessage = msg;\n }\n}\n\nexport class FlagValueError extends CustomError {\n constructor(key: string, value: string) {\n const flag = getFlagName(key);\n const msg = `Unsupported value \"${value}\" provided to flag \"${flag}\".\\nSupported values are: ${SUPPORTED_TF_PLAN_SCAN_MODES.join(\n ', ',\n )}`;\n super(msg);\n this.code = IaCErrorCodes.FlagValueError;\n this.strCode = getErrorStringCode(this.code);\n this.userMessage = msg;\n }\n}\n\nexport class UnsupportedEntitlementFlagError extends CustomError {\n constructor(key: string, entitlementName: string) {\n const flag = getFlagName(key);\n super(\n `Unsupported flag: ${flag} - Missing the ${entitlementName} entitlement`,\n );\n this.code = IaCErrorCodes.UnsupportedEntitlementFlagError;\n this.strCode = getErrorStringCode(this.code);\n this.userMessage = `Flag \"${flag}\" is currently not supported for this org. To enable it, please contact snyk support.`;\n }\n}\n\nexport class UnsupportedEntitlementCommandError extends CustomError {\n constructor(key: string, entitlementName: string) {\n super(\n `Unsupported command: ${key} - Missing the ${entitlementName} entitlement`,\n );\n this.code = IaCErrorCodes.UnsupportedEntitlementFlagError;\n this.strCode = getErrorStringCode(this.code);\n this.userMessage = `Command \"${key}\" is currently not supported for this org. To enable it, please contact snyk support.`;\n }\n}\n\n/**\n * Validates the command line flags passed to the snyk iac test\n * command. The current argument parsing is very permissive and\n * allows unknown flags to be provided without valdiation.\n *\n * For snyk iac we need to explictly validate the flags to avoid\n * misconfigurations and typos. For example, if the --experimental\n * flag were to be mis-spelled we would end up sending the client\n * data to our backend rather than running it locally as intended.\n * @param argv command line args passed to the process\n */\nexport function assertIaCOptionsFlags(argv: string[]) {\n // We process the process.argv so we don't get default values.\n const parsed = args(argv);\n for (const key of Object.keys(parsed.options)) {\n // The _ property is a special case that contains non\n // flag strings passed to the command line (usually files)\n // and `iac` is the command provided.\n if (key !== '_' && key !== 'iac' && !allowed.has(key)) {\n throw new FlagError(key);\n }\n }\n\n if (parsed.options.scan) {\n assertTerraformPlanModes(parsed.options.scan as string);\n }\n}\n\nconst SUPPORTED_TF_PLAN_SCAN_MODES = [\n TerraformPlanScanMode.DeltaScan,\n TerraformPlanScanMode.FullScan,\n];\n\nfunction assertTerraformPlanModes(scanModeArgValue: string) {\n if (\n !SUPPORTED_TF_PLAN_SCAN_MODES.includes(\n scanModeArgValue as TerraformPlanScanMode,\n )\n ) {\n throw new FlagValueError('scan', scanModeArgValue);\n }\n}\n\nexport function isIacShareResultsOptions(options) {\n return options.iac && options.report;\n}\n","import { IaCErrorCodes } from './types';\n\nexport function getErrorStringCode(code: number): string {\n const errorName = IaCErrorCodes[code];\n if (!errorName) {\n return 'INVALID_IAC_ERROR';\n }\n let result = errorName.replace(/([A-Z])/g, '_$1');\n if (result.charAt(0) === '_') {\n result = result.substring(1);\n }\n return result.toUpperCase();\n}\n","import { IaCErrorCodes, IacOrgSettings } from '../types';\nimport { Payload } from '../../../../../lib/snyk-test/types';\nimport config from '../../../../../lib/config';\nimport { isCI } from '../../../../../lib/is-ci';\nimport { api } from '../../../../../lib/api-token';\nimport { makeRequest } from '../../../../../lib/request';\nimport { CustomError } from '../../../../../lib/errors';\nimport { getErrorStringCode } from '../error-utils';\n\nexport function getIacOrgSettings(\n publicOrgId?: string,\n): Promise<IacOrgSettings> {\n const payload: Payload = {\n method: 'get',\n url: config.API + '/iac-org-settings',\n json: true,\n qs: { org: publicOrgId },\n headers: {\n 'x-is-ci': isCI(),\n authorization: `token ${api()}`,\n },\n };\n\n return new Promise((resolve, reject) => {\n makeRequest(payload, (error, res) => {\n if (error) {\n return reject(error);\n }\n if (res.statusCode < 200 || res.statusCode > 299) {\n return reject(new FailedToGetIacOrgSettingsError());\n }\n resolve(res.body);\n });\n });\n}\n\nexport class FailedToGetIacOrgSettingsError extends CustomError {\n constructor(message?: string) {\n super(message || 'Failed to fetch IaC organization settings');\n this.code = IaCErrorCodes.FailedToGetIacOrgSettingsError;\n this.strCode = getErrorStringCode(this.code);\n this.userMessage =\n 'We failed to fetch your organization settings, including custom severity overrides for infrastructure-as-code policies. Please run the command again with the `-d` flag and contact support@snyk.io with the contents of the output.';\n }\n}\n","import { CustomError } from './custom-error';\nimport { DescribeExclusiveArgs } from '../iac/drift';\n\nexport class DescribeExclusiveArgumentError extends CustomError {\n constructor() {\n super(\n 'Please use only one of these arguments: ' +\n DescribeExclusiveArgs.join(', '),\n );\n }\n}\n","import { CustomError } from './custom-error';\nimport { DescribeRequiredArgs } from '../iac/drift';\n\nexport class DescribeRequiredArgumentError extends CustomError {\n constructor() {\n super(\n 'Describe command require one of these arguments: ' +\n DescribeRequiredArgs.join(', '),\n );\n }\n}\n","import * as debugLib from 'debug';\nimport * as child_process from 'child_process';\nimport { StdioOptions } from 'child_process';\nimport * as os from 'os';\nimport envPaths from 'env-paths';\nimport * as fs from 'fs';\nimport { spinner } from '../spinner';\nimport { makeRequest } from '../request';\nimport config from '../../lib/config';\nimport * as path from 'path';\nimport * as crypto from 'crypto';\nimport {\n createIgnorePattern,\n verifyServiceMappingExists,\n} from './service-mappings';\nimport { EXIT_CODES } from '../../cli/exit-codes';\nimport {\n DescribeOptions,\n DriftAnalysis,\n DriftctlExecutionResult,\n DriftCTLOptions,\n FmtOptions,\n GenDriftIgnoreOptions,\n} from './types';\nimport { TimerMetricInstance } from '../metrics';\nimport * as analytics from '../../lib/analytics';\nimport { Policy } from '../policy/find-and-load-policy';\nimport { DescribeExclusiveArgumentError } from '../errors/describe-exclusive-argument-error';\nimport { DescribeRequiredArgumentError } from '../errors/describe-required-argument-error';\n\nconst cachePath = config.CACHE_PATH ?? envPaths('snyk').cache;\nconst debug = debugLib('drift');\n\nexport const DCTL_EXIT_CODES = {\n EXIT_IN_SYNC: 0,\n EXIT_NOT_IN_SYNC: 1,\n EXIT_ERROR: 2,\n};\n\nexport const DescribeExclusiveArgs = [\n 'all',\n 'only-managed',\n 'drift',\n 'only-unmanaged',\n];\n\nexport const DescribeRequiredArgs = [\n 'all',\n 'only-managed',\n 'drift',\n 'only-unmanaged',\n];\n\n// ⚠ Keep in mind to also update driftctl version used to generate docker images\n// You can edit base image used for snyk final image here https://github.com/snyk/snyk-images/blob/master/alpine\nexport const driftctlVersion = 'v0.23.0';\n\nconst driftctlChecksums = {\n 'driftctl_windows_386.exe':\n 'e5befbafe2291674a4d6c8522411a44fea3549057fb46d331402d49b180202fe',\n driftctl_darwin_amd64:\n '9af4e88a8e08e53ac3c373407bdd0b18a91941dc620266349f10600fc7b283d2',\n driftctl_linux_386:\n '6cd2719f81210017e3f67677cb92f4b0060976a3588c220b4af6b2dda174df8f',\n driftctl_linux_amd64:\n 'd714a3d11056169f4c4cc047b48b4d732f5df8cdfbc00e40c3e5f6e6cc5ead3e',\n driftctl_linux_arm64:\n '24812c8b2ec2d8e3d619317e76fbba0d8e7e263fc2c26cba26265a9656e8fe91',\n 'driftctl_windows_arm64.exe':\n 'd84461f0ba63b59aec66393fa67147f4157b5bddc02a19315d737c5f5a46c07b',\n driftctl_darwin_arm64:\n 'b711143d9331a10fc34c202284f67ce5eeb0348baca546b47af139f418f812c1',\n 'driftctl_windows_arm.exe':\n 'b5d24e1407c24ddfff63ffbba85eb1dc13473e2fd36e3e99e5e1762cf615f011',\n driftctl_linux_arm:\n '089665efa8a7c5e95b3cee9ace85fc5b0f2d7f2a29c351f2d3dbef3dae553e2d',\n 'driftctl_windows_amd64.exe':\n 'bf7310277eeccc2679b529c1f1d2ced30e877949a6d7c5606eb2d4c2ec033b66',\n};\n\nconst dctlBaseUrl = 'https://github.com/snyk/driftctl/releases/download/';\nconst driftctlPath = path.join(cachePath, 'driftctl_' + driftctlVersion);\nconst driftctlDefaultOptions = ['--no-version-check'];\nlet isBinaryDownloaded = false;\n\nexport const validateArgs = (options: DriftCTLOptions): void => {\n if (options.kind === 'describe') {\n return validateDescribeArgs(options as DescribeOptions);\n }\n};\n\nconst validateDescribeArgs = (options: DescribeOptions): void => {\n // Check that there is no more than one of the exclusive arguments\n let count = 0;\n for (const describeExclusiveArg of DescribeExclusiveArgs) {\n if (options[describeExclusiveArg]) {\n count++;\n }\n }\n if (count > 1) {\n throw new DescribeExclusiveArgumentError();\n }\n\n // Check we have one of the required arguments\n count = 0;\n for (const describeRequiredArgs of DescribeRequiredArgs) {\n if (options[describeRequiredArgs]) {\n count++;\n }\n }\n if (count === 0) {\n throw new DescribeRequiredArgumentError();\n }\n};\n\nexport const generateArgs = (options: DriftCTLOptions): string[] => {\n if (options.kind === 'describe') {\n return generateScanFlags(options as DescribeOptions);\n }\n\n if (options.kind === 'gen-driftignore') {\n return generateGenDriftIgnoreFlags(options as GenDriftIgnoreOptions);\n }\n\n if (options.kind === 'fmt') {\n return generateFmtFlags(options as FmtOptions);\n }\n\n throw 'Unsupported command';\n};\n\nexport const generateGenDriftIgnoreFlags = (\n options: GenDriftIgnoreOptions,\n): string[] => {\n const args: string[] = ['gen-driftignore', ...driftctlDefaultOptions];\n\n if (options.input) {\n args.push('--input');\n args.push(options.input);\n }\n\n if (options.output) {\n args.push('--output');\n args.push(options.output);\n }\n\n if (options['exclude-changed']) {\n args.push('--exclude-changed');\n }\n\n if (options['exclude-missing']) {\n args.push('--exclude-missing');\n }\n\n if (options['exclude-unmanaged']) {\n args.push('--exclude-unmanaged');\n }\n\n return args;\n};\n\nconst generateFmtFlags = (options: FmtOptions): string[] => {\n const args: string[] = ['fmt', ...driftctlDefaultOptions];\n\n if (options.json) {\n args.push('--output');\n args.push('json://stdout');\n }\n\n if (options['json-file-output']) {\n args.push('--output');\n args.push('json://' + options['json-file-output']);\n }\n\n if (options.html) {\n args.push('--output');\n args.push('html://stdout');\n }\n\n if (options['html-file-output']) {\n args.push('--output');\n args.push('html://' + options['html-file-output']);\n }\n\n return args;\n};\n\nconst generateScanFlags = (options: DescribeOptions): string[] => {\n const args: string[] = ['scan', ...driftctlDefaultOptions];\n\n if (options.quiet) {\n args.push('--quiet');\n }\n\n if (options.filter) {\n args.push('--filter');\n args.push(options.filter);\n }\n\n args.push('--output');\n args.push('json://stdout');\n\n if (options['fetch-tfstate-headers']) {\n args.push('--headers');\n args.push(options['fetch-tfstate-headers']);\n }\n\n if (options['tfc-token']) {\n args.push('--tfc-token');\n args.push(options['tfc-token']);\n }\n\n if (options['tfc-endpoint']) {\n args.push('--tfc-endpoint');\n args.push(options['tfc-endpoint']);\n }\n\n if (options['tf-provider-version']) {\n args.push('--tf-provider-version');\n args.push(options['tf-provider-version']);\n }\n\n if (options.strict) {\n args.push('--strict');\n }\n\n if (options.deep) {\n args.push('--deep');\n }\n\n if (options['only-managed'] || options.drift) {\n args.push('--only-managed');\n }\n\n if (options['only-unmanaged']) {\n args.push('--only-unmanaged');\n }\n\n if (options.driftignore) {\n args.push('--driftignore');\n args.push(options.driftignore);\n }\n\n if (options['tf-lockfile']) {\n args.push('--tf-lockfile');\n args.push(options['tf-lockfile']);\n }\n\n if (options.ignore && options.ignore.length > 0) {\n args.push('--ignore');\n args.push(options.ignore.join(','));\n }\n\n let configDir = cachePath;\n createIfNotExists(cachePath);\n if (options['config-dir']) {\n configDir = options['config-dir'];\n }\n args.push('--config-dir');\n args.push(configDir);\n\n if (options.from) {\n const froms = options.from.split(',');\n for (const f of froms) {\n args.push('--from');\n args.push(f);\n }\n }\n\n let to = 'aws+tf';\n if (options.to) {\n to = options.to;\n }\n args.push('--to');\n args.push(to);\n\n if (options.service) {\n const services = options.service.split(',');\n verifyServiceMappingExists(services);\n args.push('--ignore');\n args.push(createIgnorePattern(services));\n }\n\n debug(args);\n\n return args;\n};\n\nexport function translateExitCode(exitCode: number | null): number {\n switch (exitCode) {\n case DCTL_EXIT_CODES.EXIT_IN_SYNC:\n return 0;\n case DCTL_EXIT_CODES.EXIT_NOT_IN_SYNC:\n return EXIT_CODES.VULNS_FOUND;\n case DCTL_EXIT_CODES.EXIT_ERROR:\n return EXIT_CODES.ERROR;\n default:\n debug('driftctl returned %d', exitCode);\n return EXIT_CODES.ERROR;\n }\n}\n\nexport const parseDriftAnalysisResults = (input: string): DriftAnalysis => {\n return JSON.parse(input) as DriftAnalysis;\n};\n\nexport const runDriftCTL = async ({\n options,\n input,\n stdio,\n}: {\n options: DriftCTLOptions;\n input?: string;\n stdio?: StdioOptions;\n}): Promise<DriftctlExecutionResult> => {\n const path = await findOrDownload();\n await validateArgs(options);\n const args = await generateArgs(options);\n\n if (!stdio) {\n stdio = ['pipe', 'pipe', 'inherit'];\n }\n\n debug('running driftctl %s ', args.join(' '));\n\n const p = child_process.spawn(path, args, {\n stdio,\n env: { ...process.env, DCTL_IS_SNYK: 'true' },\n });\n\n let stdout = '';\n return new Promise<DriftctlExecutionResult>((resolve, reject) => {\n if (input) {\n p.stdin?.write(input);\n p.stdin?.end();\n }\n p.on('error', (error) => {\n reject(error);\n });\n\n p.stdout?.on('data', (data) => {\n stdout += data;\n });\n\n p.on('exit', (code) => {\n resolve({ code: translateExitCode(code), stdout });\n });\n });\n};\n\nasync function findOrDownload(): Promise<string> {\n let dctl = await findDriftCtl();\n if (isBinaryDownloaded) {\n return dctl;\n }\n let downloadDuration = 0;\n let binaryExist = true;\n if (dctl === '') {\n binaryExist = false;\n try {\n createIfNotExists(cachePath);\n dctl = driftctlPath;\n\n const duration = new TimerMetricInstance('driftctl_download');\n duration.start();\n await download(driftctlUrl(), dctl);\n duration.stop();\n\n downloadDuration = Math.round((duration.getValue() as number) / 1000);\n } catch (err) {\n return Promise.reject(err);\n }\n }\n analytics.add('iac-drift-binary-already-exist', binaryExist);\n analytics.add('iac-drift-binary-download-duration-seconds', downloadDuration);\n isBinaryDownloaded = true;\n return dctl;\n}\n\nasync function findDriftCtl(): Promise<string> {\n // lookup in custom path contained in env var DRIFTCTL_PATH\n let dctlPath = config.DRIFTCTL_PATH;\n if (dctlPath != null) {\n const exists = await isExe(dctlPath);\n if (exists) {\n debug('Found driftctl in $DRIFTCTL_PATH: %s', dctlPath);\n return dctlPath;\n }\n }\n\n // lookup in app cache\n dctlPath = driftctlPath;\n const exists = await isExe(dctlPath);\n if (exists) {\n debug('Found driftctl in cache: %s', dctlPath);\n return dctlPath;\n }\n\n // lookup in /bin\n // when used in a docker context the default binary path should be used\n {\n dctlPath = '/bin/driftctl';\n const exists = await isExe(dctlPath);\n if (exists) {\n debug('Found driftctl in %s', dctlPath);\n return dctlPath;\n }\n }\n\n debug('driftctl not found');\n return '';\n}\n\nasync function download(url, destination: string): Promise<boolean> {\n debug('downloading driftctl into %s', destination);\n\n const payload = {\n method: 'GET',\n url: url,\n output: destination,\n follow: 3,\n };\n\n await spinner('Downloading...');\n return new Promise<boolean>((resolve, reject) => {\n makeRequest(payload, function(err, res, body) {\n try {\n if (err) {\n reject(\n new Error('Could not download driftctl from ' + url + ': ' + err),\n );\n return;\n }\n if (res.statusCode !== 200) {\n reject(\n new Error(\n 'Could not download driftctl from ' + url + ': ' + res.statusCode,\n ),\n );\n return;\n }\n\n validateChecksum(body);\n\n fs.writeFileSync(destination, body);\n debug('File saved: ' + destination);\n\n fs.chmodSync(destination, 0o744);\n resolve(true);\n } finally {\n spinner.clearAll();\n }\n });\n });\n}\n\nfunction validateChecksum(body: string) {\n // only validate if we downloaded the official driftctl binary\n if (config.DRIFTCTL_URL || config.DRIFTCTL_PATH) {\n return;\n }\n\n const computedHash = crypto\n .createHash('sha256')\n .update(body)\n .digest('hex');\n const givenHash = driftctlChecksums[driftctlFileName()];\n\n if (computedHash != givenHash) {\n throw new Error('Downloaded file has inconsistent checksum...');\n }\n}\n\nfunction driftctlFileName(): string {\n let platform = 'linux';\n switch (os.platform()) {\n case 'darwin':\n platform = 'darwin';\n break;\n case 'win32':\n platform = 'windows';\n break;\n }\n\n let arch = 'amd64';\n switch (os.arch()) {\n case 'ia32':\n case 'x32':\n arch = '386';\n break;\n case 'arm':\n arch = 'arm';\n break;\n case 'arm64':\n arch = 'arm64';\n break;\n }\n\n let ext = '';\n switch (os.platform()) {\n case 'win32':\n ext = '.exe';\n break;\n }\n\n return `driftctl_${platform}_${arch}${ext}`;\n}\n\nfunction driftctlUrl(): string {\n if (config.DRIFTCTL_URL) {\n return config.DRIFTCTL_URL;\n }\n\n return `${dctlBaseUrl}/${driftctlVersion}/${driftctlFileName()}`;\n}\n\nfunction isExe(dctlPath: string): Promise<boolean> {\n return new Promise<boolean>((resolve) => {\n fs.access(dctlPath, fs.constants.X_OK, (err) => {\n if (err) {\n resolve(false);\n return;\n }\n resolve(true);\n });\n });\n}\n\nfunction createIfNotExists(path: string) {\n if (!fs.existsSync(path)) {\n fs.mkdirSync(path, { recursive: true });\n }\n}\n\nexport function driftignoreFromPolicy(policy: Policy | undefined): string[] {\n const excludeSection = 'iac-drift';\n if (!policy || !policy.exclude || !(excludeSection in policy.exclude)) {\n return [];\n }\n return policy.exclude[excludeSection];\n}\n","import { CustomError } from '../errors';\nimport { IaCErrorCodes } from '../../cli/commands/test/iac-local-execution/types';\nimport { getErrorStringCode } from '../../cli/commands/test/iac-local-execution/error-utils';\n\nexport const services2resources = new Map<string, Array<string>>([\n // Amazon\n [\n 'aws_s3',\n [\n 'aws_s3_bucket',\n 'aws_s3_bucket_analytics_configuration',\n 'aws_s3_bucket_inventory',\n 'aws_s3_bucket_metric',\n 'aws_s3_bucket_notification',\n 'aws_s3_bucket_policy',\n ],\n ],\n [\n 'aws_ec2',\n [\n 'aws_instance',\n 'aws_key_pair',\n 'aws_ami',\n 'aws_ebs_snapshot',\n 'aws_ebs_volume',\n 'aws_eip',\n 'aws_eip_association',\n 'aws_volume_attachment',\n 'aws_launch_configuration',\n 'aws_launch_template',\n ],\n ],\n ['aws_lambda', ['aws_lambda_function', 'aws_lambda_event_source_mapping']],\n [\n 'aws_rds',\n [\n 'aws_db_instance',\n 'aws_db_subnet_group',\n 'aws_rds_cluster',\n 'aws_rds_cluster_endpoint',\n 'aws_rds_cluster_instance',\n ],\n ],\n ['aws_route53', ['aws_route53_record', 'aws_route53_zone']],\n [\n 'aws_iam',\n [\n 'aws_iam_access_key',\n 'aws_iam_policy',\n 'aws_iam_policy_attachment',\n 'aws_iam_role',\n 'aws_iam_role_policy',\n 'aws_iam_role_policy_attachment',\n 'aws_iam_user',\n 'aws_iam_user_policy',\n 'aws_iam_user_policy_attachment',\n ],\n ],\n [\n 'aws_vpc',\n [\n 'aws_security_group',\n 'aws_security_group_rule',\n 'aws_subnet',\n 'aws_default_vpc',\n 'aws_vpc',\n 'aws_default_security_group',\n 'aws_route_table',\n 'aws_default_route_table',\n 'aws_route',\n 'aws_route_table_association',\n 'aws_nat_gateway',\n 'aws_internet_gateway',\n ],\n ],\n [\n 'aws_api_gateway',\n [\n 'aws_api_gateway_resource',\n 'aws_api_gateway_rest_api',\n 'aws_api_gateway_account',\n 'aws_api_gateway_api_key',\n 'aws_api_gateway_authorizer',\n 'aws_api_gateway_base_path_mapping',\n 'aws_api_gateway_domain_name',\n 'aws_api_gateway_gateway_response',\n 'aws_api_gateway_integration',\n 'aws_api_gateway_integration_response',\n 'aws_api_gateway_method',\n 'aws_api_gateway_method_response',\n 'aws_api_gateway_method_settings',\n 'aws_api_gateway_model',\n 'aws_api_gateway_request_validator',\n 'aws_api_gateway_rest_api_policy',\n 'aws_api_gateway_stage',\n 'aws_api_gateway_vpc_link',\n ],\n ],\n [\n 'aws_apigatewayv2',\n [\n 'aws_apigatewayv2_api',\n 'aws_apigatewayv2_api_mapping',\n 'aws_apigatewayv2_authorizer',\n 'aws_apigatewayv2_deployment',\n 'aws_apigatewayv2_domain_name',\n 'aws_apigatewayv2_integration',\n 'aws_apigatewayv2_integration_response',\n 'aws_apigatewayv2_model',\n 'aws_apigatewayv2_route',\n 'aws_apigatewayv2_route_response',\n 'aws_apigatewayv2_stage',\n 'aws_apigatewayv2_vpc_link',\n ],\n ],\n ['aws_sqs', ['aws_sqs_queue', 'aws_sqs_queue_policy']],\n [\n 'aws_sns',\n ['aws_sns_topic', 'aws_sns_topic_policy', 'aws_sns_topic_subscription'],\n ],\n ['aws_ecr', ['aws_ecr_repository']],\n ['aws_cloudfront', ['aws_cloudfront_distribution']],\n ['aws_kms', ['aws_kms_key', 'aws_kms_alias']],\n ['aws_dynamodb', ['aws_dynamodb_table']],\n // Azure\n ['azure_base', ['azurerm_resource_group']],\n ['azure_compute', ['azurerm_image', 'azurerm_ssh_public_key']],\n ['azure_storage', ['azurerm_storage_account', 'azurerm_storage_container']],\n [\n 'azure_network',\n [\n 'azurerm_resource_group',\n 'azurerm_subnet',\n 'azurerm_public_ip',\n 'azurerm_firewall',\n 'azurerm_route',\n 'azurerm_route_table',\n 'azurerm_network_security_group',\n ],\n ],\n ['azure_container', ['azurerm_container_registry']],\n [\n 'azure_database',\n ['azurerm_postgresql_server', 'azurerm_postgresql_database'],\n ],\n ['azure_loadbalancer', ['azurerm_lb', 'azurerm_lb_rule']],\n [\n 'azure_private_dns',\n [\n 'azurerm_private_dns_a_record',\n 'azurerm_private_dns_aaaa_record',\n 'azurerm_private_dns_cname_record',\n 'azurerm_private_dns_mx_record',\n 'azurerm_private_dns_ptr_record',\n 'azurerm_private_dns_srv_record',\n 'azurerm_private_dns_txt_record',\n 'azurerm_private_dns_zone',\n ],\n ],\n\n // Google\n [\n 'google_cloud_platform',\n [\n 'google_project_iam_binding',\n 'google_project_iam_member',\n 'google_project_iam_policy',\n ],\n ],\n [\n 'google_cloud_storage',\n [\n 'google_storage_bucket',\n 'google_storage_bucket_iam_binding',\n 'google_storage_bucket_iam_member',\n 'google_storage_bucket_iam_policy',\n ],\n ],\n [\n 'google_compute_engine',\n [\n 'google_compute_address',\n 'google_compute_disk',\n 'google_compute_global_address',\n 'google_compute_firewall',\n 'google_compute_health_check',\n 'google_compute_image',\n 'google_compute_instance',\n 'google_compute_instance_group',\n 'google_compute_network',\n 'google_compute_node_group',\n 'google_compute_router',\n 'google_compute_subnetwork',\n ],\n ],\n ['google_cloud_dns', ['google_dns_managed_zone']],\n [\n 'google_cloud_bigtable',\n ['google_bigtable_instance', 'google_bigtable_table'],\n ],\n [\n 'google_cloud_bigquery',\n ['google_bigquery_table', 'google_bigquery_dataset'],\n ],\n ['google_cloud_functions', ['google_cloudfunctions_function']],\n ['google_cloud_sql', ['google_sql_database_instance']],\n ['google_cloud_run', ['google_cloud_run_service']],\n]);\n\nexport function verifyServiceMappingExists(services: string[]): void {\n if (services.length == 0) {\n throw new InvalidServiceError('');\n }\n for (const s of services) {\n if (!services2resources.has(s)) {\n throw new InvalidServiceError(\n `We were unable to match service \"${s}\". Please provide a valid service name: ${existingServiceNames()}`,\n );\n }\n }\n}\n\nfunction existingServiceNames(): string {\n let res = '';\n for (const s of services2resources.keys()) {\n res += `${s},`;\n }\n return res.substring(0, res.length - 1);\n}\n\nexport function createIgnorePattern(services: string[]): string {\n return createIgnorePatternWithMap(services, services2resources);\n}\n\nexport function createIgnorePatternWithMap(\n services: string[],\n serviceMap: Map<string, Array<string>>,\n): string {\n let res = '*';\n const seenResources = new Set<string>();\n for (const s of services) {\n const resourcePatterns = serviceMap.get(s);\n for (const rp of resourcePatterns || []) {\n // A resource might belong to multiple services, skip it if already processed\n if (seenResources.has(rp)) {\n continue;\n }\n res += `,!${rp}`;\n seenResources.add(rp);\n }\n }\n return res;\n}\n\nexport class InvalidServiceError extends CustomError {\n constructor(msg: string) {\n super(msg);\n this.code = IaCErrorCodes.InvalidServiceError;\n this.strCode = getErrorStringCode(this.code);\n this.userMessage = msg;\n }\n}\n"],"names":[],"sourceRoot":""}
|