CONFIG::AWS_SDK['signature_version'] ]; $CONFIG->set("__SS_PARAMS", $__cli_options); $CONFIG->set("__AWS_OPTIONS", $__AWS_OPTIONS); if (!isset($__cli_options['region'])) { __info("--region option is not present. Generating region list..."); $regions = AwsRegionSelector::promptForRegion(); if (!$regions || sizeof(explode(',', $regions)) == 0) { die("No valid region(s) selected. Exiting.") . PHP_EOL; } // Set back to cli options $__cli_options['region'] = $regions; } $regions = explode(',', $__cli_options['region']); $services = explode(',', $__cli_options['services']); $contexts = []; if($regions[0]=='ALL'){ $regions = AwsRegionSelector::getAllEnabledRegions(); } $tempConfig = $__AWS_OPTIONS; $tempConfig['region'] = $regions[0]; CONFIG::setAccountInfo($tempConfig); $CONFIG->set('scanned', ['resources' => 0, 'rules' => 0, 'exceptions' => 0]); $serviceStat = []; global $GLOBALRESOURCES, $CW; $GLOBALRESOURCES = []; $overallTimeStart = microtime(true); exec('cd __fork; rm -f *.json; echo > tail.txt'); $scanInParallel = sizeof($services) > 1 ? true : false; foreach($services as $service){ ## Scripts move to bootstrap.inc.php scanByService($service, $regions, $filters, $scanInParallel); }; if($scanInParallel) while(pcntl_waitpid(0, $status) != -1); $files = scandir(FORK_DIR); $scanned=[ 'resources' => 0, 'rules' => 0, 'exceptions' => 0 ]; $hasGlobal = false; foreach($files as $file){ if($file[0] == '.' || $file == SESSUID_FILENAME || $file == 'tail.txt' || $file == 'error.txt') continue; $f = explode('.', $file); if(sizeof($f) == 2){ $contexts[$f[0]] = json_decode(file_get_contents(FORK_DIR . '/' . $file), true); }else{ list($cnt, $rules, $exceptions) = array_values(json_decode(file_get_contents(FORK_DIR . '/' .$file), true)); $serviceStat[$f[0]] = $cnt; $scanned['resources'] += $cnt; $scanned['rules'] += $rules; $scanned['exceptions'] += $exceptions; if(in_array($f[0], CONFIG::GLOBAL_SERVICES)) $hasGlobal = true; } } if($testmode) exit("Test mode enable, script halted" . PHP_EOL); $timespent = round(microtime(true) - $overallTimeStart, 3); $scanned['timespent'] = $timespent; $CONFIG->set('SCREENER-SUMMARY', $scanned); __info("Total Resources scanned: " . number_format($scanned['resources']) . " | No. Rules executed: " . number_format($scanned['rules'])); __info("Time consumed: " . $timespent); ## Cleanup exec('cd '.HTML_FOLDER.'; rm -f *.html; rm -f error.txt'); if(file_exists(FORK_DIR.'/error.txt')) exec('cd __fork; mv error.txt '.HTML_DIR.'/'); exec('cd __fork; rm -f *.json'); exec('rm -f output.zip'); ## Scripts move to bootstrap.inc.php generateScreenerOutput($runmode, $contexts, $hasGlobal, $serviceStat, $regions, $uploadToS3, $bucket); if($feedbackFlag){ __info("*** Sending feedback ***"); feedback::send($rawServices, $regions); } exec('cd __fork; rm -f tail.txt'); __info("@ Thank you for using ". Config::ADVISOR['TITLE'] ." @");