snyk 1.857.0 → 1.860.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 (38) hide show
  1. package/dist/cli/269.index.js +724 -0
  2. package/dist/cli/269.index.js.map +1 -0
  3. package/dist/cli/272.index.js +240 -40
  4. package/dist/cli/272.index.js.map +1 -1
  5. package/dist/cli/459.index.js +1 -416
  6. package/dist/cli/459.index.js.map +1 -1
  7. package/dist/cli/535.index.js +14 -1
  8. package/dist/cli/535.index.js.map +1 -1
  9. package/dist/cli/917.index.js +13 -0
  10. package/dist/cli/917.index.js.map +1 -1
  11. package/dist/cli/919.index.js +267 -0
  12. package/dist/cli/919.index.js.map +1 -0
  13. package/dist/cli/commands/describe.d.ts +3 -0
  14. package/dist/cli/commands/test/iac-local-execution/assert-iac-options-flag.d.ts +5 -1
  15. package/dist/cli/commands/test/iac-local-execution/file-utils.d.ts +5 -0
  16. package/dist/cli/commands/test/iac-local-execution/measurable-methods.d.ts +1 -1
  17. package/dist/cli/commands/test/iac-local-execution/results-formatter.d.ts +1 -1
  18. package/dist/cli/commands/test/iac-local-execution/share-results-formatter.d.ts +2 -0
  19. package/dist/cli/commands/test/iac-local-execution/share-results.d.ts +1 -0
  20. package/dist/cli/commands/test/iac-local-execution/types.d.ts +25 -3
  21. package/dist/cli/index.js +8 -3
  22. package/dist/cli/index.js.map +1 -1
  23. package/dist/cli/thirdPartyNotice.json +2 -2
  24. package/dist/lib/ecosystems/types.d.ts +10 -1
  25. package/dist/lib/iac/cli-share-results.d.ts +2 -0
  26. package/dist/lib/iac/drift.d.ts +13 -2
  27. package/dist/lib/iac/envelope-formatters.d.ts +3 -0
  28. package/dist/lib/iac/service-mappings.d.ts +8 -0
  29. package/dist/lib/polling/types.d.ts +2 -2
  30. package/dist/lib/types.d.ts +3 -1
  31. package/help/cli-commands/container.md +20 -0
  32. package/help/cli-commands/iac-describe.md +306 -0
  33. package/help/cli-commands/iac-gen-driftignore.md +56 -0
  34. package/help/cli-commands/ignore.md +1 -1
  35. package/help/cli-commands/monitor.md +1 -15
  36. package/package.json +1 -1
  37. package/help/cli-commands/iac-drift-scan.md +0 -209
  38. package/help/cli-commands/iac-drift.md +0 -7
@@ -0,0 +1,724 @@
1
+ "use strict";
2
+ exports.id = 269;
3
+ exports.ids = [269];
4
+ exports.modules = {
5
+
6
+ /***/ 21766:
7
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
8
+
9
+
10
+ const path = __webpack_require__(85622);
11
+ const os = __webpack_require__(12087);
12
+
13
+ const homedir = os.homedir();
14
+ const tmpdir = os.tmpdir();
15
+ const {env} = process;
16
+
17
+ const macos = name => {
18
+ const library = path.join(homedir, 'Library');
19
+
20
+ return {
21
+ data: path.join(library, 'Application Support', name),
22
+ config: path.join(library, 'Preferences', name),
23
+ cache: path.join(library, 'Caches', name),
24
+ log: path.join(library, 'Logs', name),
25
+ temp: path.join(tmpdir, name)
26
+ };
27
+ };
28
+
29
+ const windows = name => {
30
+ const appData = env.APPDATA || path.join(homedir, 'AppData', 'Roaming');
31
+ const localAppData = env.LOCALAPPDATA || path.join(homedir, 'AppData', 'Local');
32
+
33
+ return {
34
+ // Data/config/cache/log are invented by me as Windows isn't opinionated about this
35
+ data: path.join(localAppData, name, 'Data'),
36
+ config: path.join(appData, name, 'Config'),
37
+ cache: path.join(localAppData, name, 'Cache'),
38
+ log: path.join(localAppData, name, 'Log'),
39
+ temp: path.join(tmpdir, name)
40
+ };
41
+ };
42
+
43
+ // https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
44
+ const linux = name => {
45
+ const username = path.basename(homedir);
46
+
47
+ return {
48
+ data: path.join(env.XDG_DATA_HOME || path.join(homedir, '.local', 'share'), name),
49
+ config: path.join(env.XDG_CONFIG_HOME || path.join(homedir, '.config'), name),
50
+ cache: path.join(env.XDG_CACHE_HOME || path.join(homedir, '.cache'), name),
51
+ // https://wiki.debian.org/XDGBaseDirectorySpecification#state
52
+ log: path.join(env.XDG_STATE_HOME || path.join(homedir, '.local', 'state'), name),
53
+ temp: path.join(tmpdir, username, name)
54
+ };
55
+ };
56
+
57
+ const envPaths = (name, options) => {
58
+ if (typeof name !== 'string') {
59
+ throw new TypeError(`Expected string, got ${typeof name}`);
60
+ }
61
+
62
+ options = Object.assign({suffix: 'nodejs'}, options);
63
+
64
+ if (options.suffix) {
65
+ // Add suffix to prevent possible conflict with native apps
66
+ name += `-${options.suffix}`;
67
+ }
68
+
69
+ if (process.platform === 'darwin') {
70
+ return macos(name);
71
+ }
72
+
73
+ if (process.platform === 'win32') {
74
+ return windows(name);
75
+ }
76
+
77
+ return linux(name);
78
+ };
79
+
80
+ module.exports = envPaths;
81
+ // TODO: Remove this for the next major release
82
+ module.exports.default = envPaths;
83
+
84
+
85
+ /***/ }),
86
+
87
+ /***/ 52369:
88
+ /***/ ((__unused_webpack_module, exports) => {
89
+
90
+
91
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
92
+ exports.processCommandArgs = void 0;
93
+ function processCommandArgs(...args) {
94
+ let options = {};
95
+ if (typeof args[args.length - 1] === 'object') {
96
+ options = args.pop();
97
+ }
98
+ args = args.filter(Boolean);
99
+ // For repository scanning, populate with default path (cwd) if no path given
100
+ if (args.length === 0 && !options.docker) {
101
+ args.unshift(process.cwd());
102
+ }
103
+ return { options, paths: args };
104
+ }
105
+ exports.processCommandArgs = processCommandArgs;
106
+
107
+
108
+ /***/ }),
109
+
110
+ /***/ 26445:
111
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
112
+
113
+
114
+ var _a;
115
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
116
+ exports.findDriftCtl = exports.driftctl = exports.translateExitCode = exports.parseDescribeFlags = exports.parseArgs = exports.DCTL_EXIT_CODES = exports.driftctlVersion = void 0;
117
+ const debugLib = __webpack_require__(15158);
118
+ const child_process = __webpack_require__(63129);
119
+ const os = __webpack_require__(12087);
120
+ const env_paths_1 = __webpack_require__(21766);
121
+ const fs = __webpack_require__(35747);
122
+ const spinner_1 = __webpack_require__(86766);
123
+ const request_1 = __webpack_require__(52050);
124
+ const config_1 = __webpack_require__(22541);
125
+ const path = __webpack_require__(85622);
126
+ const crypto = __webpack_require__(76417);
127
+ const service_mappings_1 = __webpack_require__(16228);
128
+ const exit_codes_1 = __webpack_require__(80079);
129
+ const cachePath = (_a = config_1.default.CACHE_PATH) !== null && _a !== void 0 ? _a : env_paths_1.default('snyk').cache;
130
+ const debug = debugLib('drift');
131
+ exports.driftctlVersion = 'v0.21.0';
132
+ exports.DCTL_EXIT_CODES = {
133
+ EXIT_IN_SYNC: 0,
134
+ EXIT_NOT_IN_SYNC: 1,
135
+ EXIT_ERROR: 2,
136
+ };
137
+ const driftctlChecksums = {
138
+ 'driftctl_windows_386.exe': 'f7affbe0ba270b0339d0398befc686bd747a1694a4db0890ce73a2b1921521d4',
139
+ driftctl_darwin_amd64: '85cd7a0b5670aa0ee52181357ec891f5a84df29cf505344e403b8b9de5953d61',
140
+ driftctl_linux_386: '4221b4f2db65163ccfd300f90fe7cffa7bac1f806f56971ebbca5e36269aa3a4',
141
+ driftctl_linux_amd64: 'eb64c0d7a7094f0d741abae24c59a46db3eb76f619f177fd745efea7d468a66e',
142
+ driftctl_linux_arm64: 'c0c4dbfb2f5217124d3f7e1ef33b8b547fc84adf65612aca438e48e63da2f63e',
143
+ 'driftctl_windows_arm64.exe': '9e87c2a7fecca5a2846c87d4c570b5357e892e4234d7eafa0dac5ea31142e992',
144
+ driftctl_darwin_arm64: '39813b4f05c034b6833508062f72bc17f1edbe2bc4db244893e75198eb013a34',
145
+ 'driftctl_windows_arm.exe': '5d66cb4db95bfa33d4946d324c4674f10fde8370dfb5003d99242a560d8e7e1b',
146
+ driftctl_linux_arm: '13705de80f0de3d1a931e81947cc7a443dcec59968bafcb8ea888a4f643e5605',
147
+ 'driftctl_windows_amd64.exe': '154afbf87a3c0d36a345ccadad8ca7f85855a1c1f8f622ce1ea46931dadafce7',
148
+ };
149
+ const dctlBaseUrl = 'https://github.com/snyk/driftctl/releases/download/';
150
+ const driftctlPath = path.join(cachePath, 'driftctl_' + exports.driftctlVersion);
151
+ var DriftctlCmd;
152
+ (function (DriftctlCmd) {
153
+ DriftctlCmd["GenDriftIgnore"] = "gen-driftignore";
154
+ })(DriftctlCmd || (DriftctlCmd = {}));
155
+ const supportedDriftctlCommands = [DriftctlCmd.GenDriftIgnore];
156
+ function parseArgs(commands, options) {
157
+ const args = commands;
158
+ const driftctlCommand = args[0];
159
+ if (!supportedDriftctlCommands.includes(driftctlCommand)) {
160
+ throw new Error(`Unsupported command: ${driftctlCommand}`);
161
+ }
162
+ // It is currently not possible to iterate on options and pass everything
163
+ // to the args since there is snyk CLI related data on it.
164
+ // We can try to switch the logic from a whitelist approch to a blacklist apporoach
165
+ // But if something change from the snyk cli options parsing sub command will fail
166
+ // For now it's better to keep the control on that even if mean that we'll need to update theses methods every time
167
+ // we make change on arguments in driftctl
168
+ switch (driftctlCommand) {
169
+ case DriftctlCmd.GenDriftIgnore:
170
+ args.push(...parseGenDriftIgnoreFlags(options));
171
+ break;
172
+ }
173
+ debug(args);
174
+ return args;
175
+ }
176
+ exports.parseArgs = parseArgs;
177
+ const parseGenDriftIgnoreFlags = (options) => {
178
+ const args = [];
179
+ if (options.input) {
180
+ args.push('--input');
181
+ args.push(options.input);
182
+ }
183
+ if (options.output) {
184
+ args.push('--output');
185
+ args.push(options.output);
186
+ }
187
+ if (options['exclude-changed']) {
188
+ args.push('--exclude-changed');
189
+ }
190
+ if (options['exclude-missing']) {
191
+ args.push('--exclude-missing');
192
+ }
193
+ if (options['exclude-unmanaged']) {
194
+ args.push('--exclude-unmanaged');
195
+ }
196
+ return args;
197
+ };
198
+ exports.parseDescribeFlags = (options) => {
199
+ const args = ['scan'];
200
+ if (options.quiet) {
201
+ args.push('--quiet');
202
+ }
203
+ if (options.filter) {
204
+ args.push('--filter');
205
+ args.push(options.filter);
206
+ }
207
+ if (options.json) {
208
+ args.push('--output');
209
+ args.push('json://stdout');
210
+ }
211
+ if (options['json-file-output']) {
212
+ args.push('--output');
213
+ args.push('json://' + options['json-file-output']);
214
+ }
215
+ if (options.html) {
216
+ args.push('--output');
217
+ args.push('html://stdout');
218
+ }
219
+ if (options['html-file-output']) {
220
+ args.push('--output');
221
+ args.push('html://' + options['html-file-output']);
222
+ }
223
+ if (options.headers) {
224
+ args.push('--headers');
225
+ args.push(options.headers);
226
+ }
227
+ if (options['tfc-token']) {
228
+ args.push('--tfc-token');
229
+ args.push(options['tfc-token']);
230
+ }
231
+ if (options['tfc-endpoint']) {
232
+ args.push('--tfc-endpoint');
233
+ args.push(options['tfc-endpoint']);
234
+ }
235
+ if (options['tf-provider-version']) {
236
+ args.push('--tf-provider-version');
237
+ args.push(options['tf-provider-version']);
238
+ }
239
+ if (options.strict) {
240
+ args.push('--strict');
241
+ }
242
+ if (options.deep) {
243
+ args.push('--deep');
244
+ }
245
+ if (options.driftignore) {
246
+ args.push('--driftignore');
247
+ args.push(options.driftignore);
248
+ }
249
+ if (options['tf-lockfile']) {
250
+ args.push('--tf-lockfile');
251
+ args.push(options['tf-lockfile']);
252
+ }
253
+ let configDir = cachePath;
254
+ createIfNotExists(cachePath);
255
+ if (options['config-dir']) {
256
+ configDir = options['config-dir'];
257
+ }
258
+ args.push('--config-dir');
259
+ args.push(configDir);
260
+ if (options.from) {
261
+ const froms = options.from.split(',');
262
+ for (const f of froms) {
263
+ args.push('--from');
264
+ args.push(f);
265
+ }
266
+ }
267
+ let to = 'aws+tf';
268
+ if (options.to) {
269
+ to = options.to;
270
+ }
271
+ args.push('--to');
272
+ args.push(to);
273
+ if (options.service) {
274
+ const services = options.service.split(',');
275
+ service_mappings_1.verifyServiceMappingExists(services);
276
+ args.push('--ignore');
277
+ args.push(service_mappings_1.createIgnorePattern(services));
278
+ }
279
+ debug(args);
280
+ return args;
281
+ };
282
+ function translateExitCode(exitCode) {
283
+ switch (exitCode) {
284
+ case exports.DCTL_EXIT_CODES.EXIT_IN_SYNC:
285
+ return 0;
286
+ case exports.DCTL_EXIT_CODES.EXIT_NOT_IN_SYNC:
287
+ return exit_codes_1.EXIT_CODES.VULNS_FOUND;
288
+ case exports.DCTL_EXIT_CODES.EXIT_ERROR:
289
+ return exit_codes_1.EXIT_CODES.ERROR;
290
+ default:
291
+ debug('driftctl returned %d', exitCode);
292
+ return exit_codes_1.EXIT_CODES.ERROR;
293
+ }
294
+ }
295
+ exports.translateExitCode = translateExitCode;
296
+ async function driftctl(args) {
297
+ debug('running driftctl %s ', args.join(' '));
298
+ const path = await findOrDownload();
299
+ const exitCode = await launch(path, args);
300
+ return translateExitCode(exitCode);
301
+ }
302
+ exports.driftctl = driftctl;
303
+ async function launch(path, args) {
304
+ return new Promise((resolve, reject) => {
305
+ const child = child_process.spawn(path, args, { stdio: 'inherit' });
306
+ child.on('error', (error) => {
307
+ reject(error);
308
+ });
309
+ child.on('exit', (code) => {
310
+ if (code == null) {
311
+ //failed to find why this could happen...
312
+ reject(new Error('Process was terminated'));
313
+ }
314
+ else {
315
+ resolve(code);
316
+ }
317
+ });
318
+ });
319
+ }
320
+ async function findOrDownload() {
321
+ let dctl = await findDriftCtl();
322
+ if (dctl === '') {
323
+ try {
324
+ createIfNotExists(cachePath);
325
+ dctl = driftctlPath;
326
+ await download(driftctlUrl(), dctl);
327
+ }
328
+ catch (err) {
329
+ return Promise.reject(err);
330
+ }
331
+ }
332
+ return dctl;
333
+ }
334
+ async function findDriftCtl() {
335
+ // lookup in custom path contained in env var DRIFTCTL_PATH
336
+ let dctlPath = config_1.default.DRIFTCTL_PATH;
337
+ if (dctlPath != null) {
338
+ const exists = await isExe(dctlPath);
339
+ if (exists) {
340
+ debug('Found driftctl in $DRIFTCTL_PATH: %s', dctlPath);
341
+ return dctlPath;
342
+ }
343
+ }
344
+ // lookup in app cache
345
+ dctlPath = driftctlPath;
346
+ const exists = await isExe(dctlPath);
347
+ if (exists) {
348
+ debug('Found driftctl in cache: %s', dctlPath);
349
+ return dctlPath;
350
+ }
351
+ debug('driftctl not found');
352
+ return '';
353
+ }
354
+ exports.findDriftCtl = findDriftCtl;
355
+ async function download(url, destination) {
356
+ debug('downloading driftctl into %s', destination);
357
+ const payload = {
358
+ method: 'GET',
359
+ url: url,
360
+ output: destination,
361
+ follow: 3,
362
+ };
363
+ await spinner_1.spinner('Downloading...');
364
+ return new Promise((resolve, reject) => {
365
+ request_1.makeRequest(payload, function (err, res, body) {
366
+ try {
367
+ if (err) {
368
+ reject(new Error('Could not download driftctl from ' + url + ': ' + err));
369
+ return;
370
+ }
371
+ if (res.statusCode !== 200) {
372
+ reject(new Error('Could not download driftctl from ' + url + ': ' + res.statusCode));
373
+ return;
374
+ }
375
+ validateChecksum(body);
376
+ fs.writeFileSync(destination, body);
377
+ debug('File saved: ' + destination);
378
+ fs.chmodSync(destination, 0o744);
379
+ resolve(true);
380
+ }
381
+ finally {
382
+ spinner_1.spinner.clearAll();
383
+ }
384
+ });
385
+ });
386
+ }
387
+ function validateChecksum(body) {
388
+ // only validate if we downloaded the official driftctl binary
389
+ if (config_1.default.DRIFTCTL_URL || config_1.default.DRIFTCTL_PATH) {
390
+ return;
391
+ }
392
+ const computedHash = crypto
393
+ .createHash('sha256')
394
+ .update(body)
395
+ .digest('hex');
396
+ const givenHash = driftctlChecksums[driftctlFileName()];
397
+ if (computedHash != givenHash) {
398
+ throw new Error('Downloaded file has inconsistent checksum...');
399
+ }
400
+ }
401
+ function driftctlFileName() {
402
+ let platform = 'linux';
403
+ switch (os.platform()) {
404
+ case 'darwin':
405
+ platform = 'darwin';
406
+ break;
407
+ case 'win32':
408
+ platform = 'windows';
409
+ break;
410
+ }
411
+ let arch = 'amd64';
412
+ switch (os.arch()) {
413
+ case 'ia32':
414
+ case 'x32':
415
+ arch = '386';
416
+ break;
417
+ case 'arm':
418
+ arch = 'arm';
419
+ break;
420
+ case 'arm64':
421
+ arch = 'arm64';
422
+ break;
423
+ }
424
+ let ext = '';
425
+ switch (os.platform()) {
426
+ case 'win32':
427
+ ext = '.exe';
428
+ break;
429
+ }
430
+ return `driftctl_${platform}_${arch}${ext}`;
431
+ }
432
+ function driftctlUrl() {
433
+ if (config_1.default.DRIFTCTL_URL) {
434
+ return config_1.default.DRIFTCTL_URL;
435
+ }
436
+ return `${dctlBaseUrl}/${exports.driftctlVersion}/${driftctlFileName()}`;
437
+ }
438
+ function isExe(dctlPath) {
439
+ return new Promise((resolve) => {
440
+ fs.access(dctlPath, fs.constants.X_OK, (err) => {
441
+ if (err) {
442
+ resolve(false);
443
+ return;
444
+ }
445
+ resolve(true);
446
+ });
447
+ });
448
+ }
449
+ function createIfNotExists(path) {
450
+ if (!fs.existsSync(path)) {
451
+ fs.mkdirSync(path, { recursive: true });
452
+ }
453
+ }
454
+
455
+
456
+ /***/ }),
457
+
458
+ /***/ 16228:
459
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
460
+
461
+
462
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
463
+ exports.InvalidServiceError = exports.createIgnorePatternWithMap = exports.createIgnorePattern = exports.verifyServiceMappingExists = exports.services2resources = void 0;
464
+ const errors_1 = __webpack_require__(55191);
465
+ const types_1 = __webpack_require__(42258);
466
+ const error_utils_1 = __webpack_require__(23872);
467
+ exports.services2resources = new Map([
468
+ // Amazon
469
+ [
470
+ 'aws_s3',
471
+ [
472
+ 'aws_s3_bucket',
473
+ 'aws_s3_bucket_analytics_configuration',
474
+ 'aws_s3_bucket_inventory',
475
+ 'aws_s3_bucket_metric',
476
+ 'aws_s3_bucket_notification',
477
+ 'aws_s3_bucket_policy',
478
+ ],
479
+ ],
480
+ [
481
+ 'aws_ec2',
482
+ [
483
+ 'aws_instance',
484
+ 'aws_key_pair',
485
+ 'aws_ami',
486
+ 'aws_ebs_snapshot',
487
+ 'aws_ebs_volume',
488
+ 'aws_eip',
489
+ 'aws_eip_association',
490
+ 'aws_volume_attachment',
491
+ 'aws_launch_configuration',
492
+ 'aws_launch_template',
493
+ ],
494
+ ],
495
+ ['aws_lambda', ['aws_lambda_function', 'aws_lambda_event_source_mapping']],
496
+ [
497
+ 'aws_rds',
498
+ [
499
+ 'aws_db_instance',
500
+ 'aws_db_subnet_group',
501
+ 'aws_rds_cluster',
502
+ 'aws_rds_cluster_endpoint',
503
+ 'aws_rds_cluster_instance',
504
+ ],
505
+ ],
506
+ ['aws_route53', ['aws_route53_record', 'aws_route53_zone']],
507
+ [
508
+ 'aws_iam',
509
+ [
510
+ 'aws_iam_access_key',
511
+ 'aws_iam_policy',
512
+ 'aws_iam_policy_attachment',
513
+ 'aws_iam_role',
514
+ 'aws_iam_role_policy',
515
+ 'aws_iam_role_policy_attachment',
516
+ 'aws_iam_user',
517
+ 'aws_iam_user_policy',
518
+ 'aws_iam_user_policy_attachment',
519
+ ],
520
+ ],
521
+ [
522
+ 'aws_vpc',
523
+ [
524
+ 'aws_security_group',
525
+ 'aws_security_group_rule',
526
+ 'aws_subnet',
527
+ 'aws_default_vpc',
528
+ 'aws_vpc',
529
+ 'aws_default_security_group',
530
+ 'aws_route_table',
531
+ 'aws_default_route_table',
532
+ 'aws_route',
533
+ 'aws_route_table_association',
534
+ 'aws_nat_gateway',
535
+ 'aws_internet_gateway',
536
+ ],
537
+ ],
538
+ [
539
+ 'aws_api_gateway',
540
+ [
541
+ 'aws_api_gateway_resource',
542
+ 'aws_api_gateway_rest_api',
543
+ 'aws_api_gateway_account',
544
+ 'aws_api_gateway_api_key',
545
+ 'aws_api_gateway_authorizer',
546
+ 'aws_api_gateway_base_path_mapping',
547
+ 'aws_api_gateway_domain_name',
548
+ 'aws_api_gateway_gateway_response',
549
+ 'aws_api_gateway_integration',
550
+ 'aws_api_gateway_integration_response',
551
+ 'aws_api_gateway_method',
552
+ 'aws_api_gateway_method_response',
553
+ 'aws_api_gateway_method_settings',
554
+ 'aws_api_gateway_model',
555
+ 'aws_api_gateway_request_validator',
556
+ 'aws_api_gateway_rest_api_policy',
557
+ 'aws_api_gateway_stage',
558
+ 'aws_api_gateway_vpc_link',
559
+ ],
560
+ ],
561
+ [
562
+ 'aws_apigatewayv2',
563
+ [
564
+ 'aws_apigatewayv2_api',
565
+ 'aws_apigatewayv2_api_mapping',
566
+ 'aws_apigatewayv2_authorizer',
567
+ 'aws_apigatewayv2_deployment',
568
+ 'aws_apigatewayv2_domain_name',
569
+ 'aws_apigatewayv2_integration',
570
+ 'aws_apigatewayv2_integration_response',
571
+ 'aws_apigatewayv2_model',
572
+ 'aws_apigatewayv2_route',
573
+ 'aws_apigatewayv2_route_response',
574
+ 'aws_apigatewayv2_stage',
575
+ 'aws_apigatewayv2_vpc_link',
576
+ ],
577
+ ],
578
+ ['aws_sqs', ['aws_sqs_queue', 'aws_sqs_queue_policy']],
579
+ [
580
+ 'aws_sns',
581
+ ['aws_sns_topic', 'aws_sns_topic_policy', 'aws_sns_topic_subscription'],
582
+ ],
583
+ ['aws_ecr', ['aws_ecr_repository']],
584
+ ['aws_cloudfront', ['aws_cloudfront_distribution']],
585
+ ['aws_kms', ['aws_kms_key', 'aws_kms_alias']],
586
+ ['aws_dynamodb', ['aws_dynamodb_table']],
587
+ // Azure
588
+ ['azure_base', ['azurerm_resource_group']],
589
+ ['azure_compute', ['azurerm_image', 'azurerm_ssh_public_key']],
590
+ ['azure_storage', ['azurerm_storage_account', 'azurerm_storage_container']],
591
+ [
592
+ 'azure_network',
593
+ [
594
+ 'azurerm_resource_group',
595
+ 'azurerm_subnet',
596
+ 'azurerm_public_ip',
597
+ 'azurerm_firewall',
598
+ 'azurerm_route',
599
+ 'azurerm_route_table',
600
+ 'azurerm_network_security_group',
601
+ ],
602
+ ],
603
+ ['azure_container', ['azurerm_container_registry']],
604
+ [
605
+ 'azure_database',
606
+ ['azurerm_postgresql_server', 'azurerm_postgresql_database'],
607
+ ],
608
+ ['azure_loadbalancer', ['azurerm_lb', 'azurerm_lb_rule']],
609
+ [
610
+ 'azure_private_dns',
611
+ [
612
+ 'azurerm_private_dns_a_record',
613
+ 'azurerm_private_dns_aaaa_record',
614
+ 'azurerm_private_dns_cname_record',
615
+ 'azurerm_private_dns_mx_record',
616
+ 'azurerm_private_dns_ptr_record',
617
+ 'azurerm_private_dns_srv_record',
618
+ 'azurerm_private_dns_txt_record',
619
+ 'azurerm_private_dns_zone',
620
+ ],
621
+ ],
622
+ // Google
623
+ [
624
+ 'google_cloud_platform',
625
+ [
626
+ 'google_project_iam_binding',
627
+ 'google_project_iam_member',
628
+ 'google_project_iam_policy',
629
+ ],
630
+ ],
631
+ [
632
+ 'google_cloud_storage',
633
+ [
634
+ 'google_storage_bucket',
635
+ 'google_storage_bucket_iam_binding',
636
+ 'google_storage_bucket_iam_member',
637
+ 'google_storage_bucket_iam_policy',
638
+ ],
639
+ ],
640
+ [
641
+ 'google_compute_engine',
642
+ [
643
+ 'google_compute_address',
644
+ 'google_compute_disk',
645
+ 'google_compute_global_address',
646
+ 'google_compute_firewall',
647
+ 'google_compute_health_check',
648
+ 'google_compute_image',
649
+ 'google_compute_instance',
650
+ 'google_compute_instance_group',
651
+ 'google_compute_network',
652
+ 'google_compute_node_group',
653
+ 'google_compute_router',
654
+ 'google_compute_subnetwork',
655
+ ],
656
+ ],
657
+ ['google_cloud_dns', ['google_dns_managed_zone']],
658
+ [
659
+ 'google_cloud_bigtable',
660
+ ['google_bigtable_instance', 'google_bigtable_table'],
661
+ ],
662
+ [
663
+ 'google_cloud_bigquery',
664
+ ['google_bigquery_table', 'google_bigquery_dataset'],
665
+ ],
666
+ ['google_cloud_functions', ['google_cloudfunctions_function']],
667
+ ['google_cloud_sql', ['google_sql_database_instance']],
668
+ ['google_cloud_run', ['google_cloud_run_service']],
669
+ ]);
670
+ function verifyServiceMappingExists(services) {
671
+ if (services.length == 0) {
672
+ throw new InvalidServiceError('');
673
+ }
674
+ for (const s of services) {
675
+ if (!exports.services2resources.has(s)) {
676
+ throw new InvalidServiceError(`We were unable to match service "${s}". Please provide a valid service name: ${existingServiceNames()}`);
677
+ }
678
+ }
679
+ }
680
+ exports.verifyServiceMappingExists = verifyServiceMappingExists;
681
+ function existingServiceNames() {
682
+ let res = '';
683
+ for (const s of exports.services2resources.keys()) {
684
+ res += `${s},`;
685
+ }
686
+ return res.substring(0, res.length - 1);
687
+ }
688
+ function createIgnorePattern(services) {
689
+ return createIgnorePatternWithMap(services, exports.services2resources);
690
+ }
691
+ exports.createIgnorePattern = createIgnorePattern;
692
+ function createIgnorePatternWithMap(services, serviceMap) {
693
+ let res = '*';
694
+ const seenResources = new Set();
695
+ for (const s of services) {
696
+ const resourcePatterns = serviceMap.get(s);
697
+ for (const rp of resourcePatterns || []) {
698
+ // A resource might belong to multiple services, skip it if already processed
699
+ if (seenResources.has(rp)) {
700
+ continue;
701
+ }
702
+ res += `,!${rp}`;
703
+ seenResources.add(rp);
704
+ }
705
+ }
706
+ return res;
707
+ }
708
+ exports.createIgnorePatternWithMap = createIgnorePatternWithMap;
709
+ class InvalidServiceError extends errors_1.CustomError {
710
+ constructor(msg) {
711
+ super(msg);
712
+ this.code = types_1.IaCErrorCodes.InvalidServiceError;
713
+ this.strCode = error_utils_1.getErrorStringCode(this.code);
714
+ this.userMessage = msg;
715
+ }
716
+ }
717
+ exports.InvalidServiceError = InvalidServiceError;
718
+
719
+
720
+ /***/ })
721
+
722
+ };
723
+ ;
724
+ //# sourceMappingURL=269.index.js.map