MCPcopy Index your code
hub / github.com/aquasecurity/cloudsploit / engine

Function engine

engine.js:51–285  ·  view source on GitHub ↗
(cloudConfig, settings)

Source from the content-addressed store, hash-verified

49 * @param settings General purpose settings.
50 */
51var engine = function(cloudConfig, settings) {
52 // Initialize any suppression rules based on the the command line arguments
53 var suppressionFilter = suppress.create(settings.suppress);
54
55 // Initialize the output handler
56 var outputHandler = output.create(settings);
57
58 // Configure Service Provider Collector
59 var collector = require(`./collectors/${settings.cloud}/collector.js`);
60 var plugins = exports[settings.cloud];
61 var apiCalls = [];
62
63 // Load resource mappings
64 var resourceMap;
65 try {
66 resourceMap = require(`./helpers/${settings.cloud}/resources.js`);
67 } catch (e) {
68 resourceMap = {};
69 }
70
71 // Print customization options
72 if (settings.compliance) console.log(`INFO: Using compliance modes: ${settings.compliance.join(', ')}`);
73 if (settings.govcloud) console.log('INFO: Using AWS GovCloud mode');
74 if (settings.china) console.log('INFO: Using AWS China mode');
75 if (settings.ignore_ok) console.log('INFO: Ignoring passing results');
76 if (settings.skip_paginate) console.log('INFO: Skipping AWS pagination mode');
77 if (settings.suppress && settings.suppress.length) console.log('INFO: Suppressing results based on suppress flags');
78 if (settings.remediate && settings.remediate.length) console.log('INFO: Remediate the plugins mentioned here');
79 if (settings.plugin) {
80 if (!plugins[settings.plugin]) return console.log(`ERROR: Invalid plugin: ${settings.plugin}`);
81 console.log(`INFO: Testing plugin: ${plugins[settings.plugin].title}`);
82 }
83
84 // STEP 1 - Obtain API calls to make
85 console.log('INFO: Determining API calls to make...');
86
87 var skippedPlugins = [];
88
89 Object.entries(plugins).forEach(function(p){
90 var pluginId = p[0];
91 var plugin = p[1];
92
93 // Skip plugins that don't match the ID flag
94 var skip = false;
95 if (settings.plugin && settings.plugin !== pluginId) {
96 skip = true;
97 } else {
98 // Skip GitHub plugins that do not match the run type
99 if (settings.cloud == 'github') {
100 if (cloudConfig.organization &&
101 plugin.types.indexOf('org') === -1) {
102 skip = true;
103 console.debug(`DEBUG: Skipping GitHub plugin ${plugin.title} because it is not for Organization accounts`);
104 } else if (!cloudConfig.organization &&
105 plugin.types.indexOf('org') === -1) {
106 skip = true;
107 console.debug(`DEBUG: Skipping GitHub plugin ${plugin.title} because it is not for User accounts`);
108 }

Callers 2

index.jsFile · 0.85
engine.spec.jsFile · 0.85

Calls 2

runAuthFunction · 0.85
executePluginsFunction · 0.85

Tested by

no test coverage detected