(cloudRemediateConfig)
| 181 | var resultsObject = {}; // Initialize resultsObject for azure gov cloud |
| 182 | |
| 183 | function executePlugins(cloudRemediateConfig) { |
| 184 | async.mapValuesLimit(plugins, 10, function(plugin, key, pluginDone) { |
| 185 | if (skippedPlugins.indexOf(key) > -1) return pluginDone(null, 0); |
| 186 | var postRun = function(err, results) { |
| 187 | if (err) return console.log(`ERROR: ${err}`); |
| 188 | if (!results || !results.length) { |
| 189 | console.log(`Plugin ${plugin.title} returned no results. There may be a problem with this plugin.`); |
| 190 | } else { |
| 191 | if (!resultsObject[plugin.title]) { |
| 192 | resultsObject[plugin.title] = []; |
| 193 | } |
| 194 | for (var r in results) { |
| 195 | // If we have suppressed this result, then don't process it |
| 196 | // so that it doesn't affect the return code. |
| 197 | if (suppressionFilter([key, results[r].region || 'any', results[r].resource || 'any'].join(':'))) { |
| 198 | continue; |
| 199 | } |
| 200 | |
| 201 | resultsObject[plugin.title].push(results[r]); |
| 202 | |
| 203 | var complianceMsg = []; |
| 204 | if (settings.compliance && settings.compliance.length) { |
| 205 | settings.compliance.forEach(function(c) { |
| 206 | if (plugin.compliance && plugin.compliance[c]) { |
| 207 | complianceMsg.push(`${c.toUpperCase()}: ${plugin.compliance[c]}`); |
| 208 | } |
| 209 | }); |
| 210 | } |
| 211 | complianceMsg = complianceMsg.join('; '); |
| 212 | if (!complianceMsg.length) complianceMsg = null; |
| 213 | |
| 214 | // Write out the result (to console or elsewhere) |
| 215 | outputHandler.writeResult(results[r], plugin, key, complianceMsg); |
| 216 | |
| 217 | // Add this to our tracking for the worst status to calculate |
| 218 | // the exit code |
| 219 | maximumStatus = Math.max(maximumStatus, results[r].status); |
| 220 | // Remediation |
| 221 | if (settings.remediate && settings.remediate.length) { |
| 222 | if (settings.remediate.indexOf(key) > -1) { |
| 223 | if (results[r].status === 2) { |
| 224 | var resource = results[r].resource; |
| 225 | var event = {}; |
| 226 | event.region = results[r].region; |
| 227 | event['remediation_file'] = {}; |
| 228 | event['remediation_file'] = initializeFile(event['remediation_file'], 'execute', key, resource); |
| 229 | plugin.remediate(cloudRemediateConfig, collection, event, resource, (err, result) => { |
| 230 | if (err) return console.log(err); |
| 231 | return console.log(result); |
| 232 | }); |
| 233 | } |
| 234 | } |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | } |
| 239 | setTimeout(function() { pluginDone(err, maximumStatus); }, 0); |
| 240 | }; |
no test coverage detected