Skip to content

Commit

Permalink
Update engine.js
Browse files Browse the repository at this point in the history
  • Loading branch information
AkhtarAmir committed Mar 31, 2021
1 parent 7670ef0 commit 2409824
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ var async = require('async');
var exports = require('./exports.js');
var suppress = require('./postprocess/suppress.js');
var output = require('./postprocess/output.js');
var aslRunner = require('./helpers/asl.js');
var azureHelper = require('./helpers/azure/auth.js');

function runAuth(settings, cloudConfig, callback) {
function runAuth(settings, remediateConfig, callback) {
if (settings.cloud && settings.cloud == 'azure') {
azureHelper.login(cloudConfig.remediate, function(err, loginData) {
azureHelper.login(remediateConfig, function(err, loginData) {
if (err) return (callback(err));
cloudConfig.remediate.token = loginData.token;
remediateConfig.token = loginData.token;
return callback();
});
}
return callback();
} else callback();
}
/**
* The main function to execute CloudSploit scans.
Expand Down Expand Up @@ -209,6 +208,9 @@ var engine = function(cloudConfig, settings) {
console.log(`INFO: Using custom ASL for plugin: ${plugin.title}`);
// Inject APIs and resource maps
plugin.asl.apis = plugin.apis;
var aslConfig = require('./helpers/asl/config.json');
var aslVersion = plugin.asl.version ? plugin.asl.version : aslConfig.current_version;
var aslRunner = require(`./helpers/asl/asl-${aslVersion}.js`);
aslRunner(collection, plugin.asl, resourceMap, postRun);
} else {
plugin.run(collection, settings, postRun);
Expand All @@ -227,13 +229,13 @@ var engine = function(cloudConfig, settings) {
});
}

if (settings.remediate && settings.remediate.length) {
runAuth(settings, cloudConfig, function(err) {
if (settings.remediate && settings.remediate.length && cloudConfig.remediate) {
runAuth(settings, cloudConfig.remediate, function(err) {
if (err) return console.log(err);
executePlugins(cloudConfig.remediate || cloudConfig);
executePlugins(cloudConfig.remediate);
});
} else {
executePlugins();
executePlugins(cloudConfig);
}
});
};
Expand Down

0 comments on commit 2409824

Please sign in to comment.