ajax.php - sort checklists
background_stigs.php - change to support adding sunset STIGs to update_db.php parse_nessus.php/parse_nmap.php - disable post processing until the end of reading the file update_db.php - Add sunset STIGs downloading and parsing database.inc - Removed unnecessary variables ($key, etc), fixed typo (proc_ia_control v. proc_ia_controls), fix typo line 11072, added query_type to other queries in post_Processing method, call update_Target_Count method at the end of post_Processing, convert update_Target_Count to use queries instead of get_pdi_count and get_finding_count views (caused a performance hit), removed calling update_Target_Count from save_Target method to support previously mentioned changes index.php - removed ajax timeout when bulk removing targets
This commit is contained in:
@ -48,7 +48,8 @@
|
||||
* - Apr 29, 2018 - Added extract parameter to only extract nasl archive file, fixed a couple bugs
|
||||
* - May 10, 2018 - Removed ping of cve.mitre.org, and added 'po' and 'do' parameters for NVD CVE
|
||||
* - Jun 5, 2018 - Fixed a couple setting updates
|
||||
*/
|
||||
* - Sep 18, 2018 - Jeff - Added --sunset switch for Installing Sunset STIGs from https://iase.disa.mil/stigs/sunset/Pages/index.aspx
|
||||
*/
|
||||
include_once 'config.inc';
|
||||
include_once 'helper.inc';
|
||||
include_once 'error.inc';
|
||||
@ -61,11 +62,10 @@ use Monolog\Handler\StreamHandler;
|
||||
use Monolog\Formatter\LineFormatter;
|
||||
|
||||
$current_date = new DateTime();
|
||||
$total_time = null;
|
||||
$total_diff = 0;
|
||||
$summary_stats = [];
|
||||
$total_complete = 0;
|
||||
$threads = [];
|
||||
|
||||
$cmd = getopt("h::u::p::", ['cpe::', 'cce::', 'cve::', 'nvd::', 'nasl::', 'stig::', 'do::', 'po::', 'help::', 'debug::', 'extract::', 'exclude::']);
|
||||
$cmd = getopt("h::u::p::", ['cpe::', 'cce::', 'cve::', 'nvd::', 'nasl::', 'stig::', 'sunset::', 'do::', 'po::', 'help::', 'debug::', 'extract::', 'exclude::']);
|
||||
|
||||
$db = new db();
|
||||
$diff = new DateTimeDiff();
|
||||
@ -94,7 +94,7 @@ $log->pushHandler(new StreamHandler(LOG_PATH . "/update_db.log", $log_level));
|
||||
$log->pushHandler($stream);
|
||||
|
||||
if (isset($cmd['h'], $cmd['help']) ||
|
||||
(!isset($cmd['cpe']) && !isset($cmd['cve']) && !isset($cmd['nasl']) && !isset($cmd['stig']) && !isset($cmd['nvd']))) {
|
||||
(!isset($cmd['cpe']) && !isset($cmd['cve']) && !isset($cmd['nasl']) && !isset($cmd['stig']) && !isset($cmd['sunset']) && !isset($cmd['nvd']))) {
|
||||
die(usage());
|
||||
}
|
||||
|
||||
@ -460,6 +460,7 @@ if (isset($cmd['nasl'])) {
|
||||
'nasl-progress' => 0,
|
||||
'nasl-count' => 0
|
||||
]);
|
||||
$count = 0;
|
||||
|
||||
// Capture start time for performance monitoring
|
||||
$diff->resetClock();
|
||||
@ -702,6 +703,75 @@ if (isset($cmd['stig'])) {
|
||||
sleep(3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Sunset STIG library from DISA content
|
||||
*/
|
||||
if (isset($cmd['sunset'])) {
|
||||
$db->set_Setting_Array([
|
||||
'stig-dl-progress' => 0,
|
||||
'stig-progress' => 0,
|
||||
'stig-count' => 0
|
||||
]);
|
||||
$path = TMP . "/stigs/zip";
|
||||
check_path($path);
|
||||
$sunset_array = [];
|
||||
|
||||
$diff->resetClock();
|
||||
print "Started Sunset STIG ingestion ({$diff->getStartClockTime()})" . PHP_EOL;
|
||||
|
||||
$sunset_url="https://iase.disa.mil/stigs/Lists/Sunset%20Master%20List/FinalView.aspx";
|
||||
|
||||
if (ping("disa.mil") && !isset($cmd['po'])) {
|
||||
$log->debug("Checking for $sunset_url");
|
||||
if ($found = url_exists($sunset_url)) {
|
||||
$contents=file_get_contents($sunset_url);
|
||||
}
|
||||
|
||||
if (!$found) {
|
||||
$log->debug("Unable to download $sunset_url, aborting Sunset");
|
||||
die("Unable to open $sunset_url, aborting Sunset");
|
||||
}
|
||||
|
||||
preg_match_all("/a href=\"([^ ]+zip\/U_[^ ]+STIG\.zip)/", $contents, $sunset_array);
|
||||
|
||||
foreach($sunset_array[1] as $url) {
|
||||
$sunset_fname = basename($url);
|
||||
download_file($url, "{$path}/$sunset_fname");
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($cmd['do']) || isset($cmd['po'])) {
|
||||
$stig_files = array_merge(
|
||||
glob("{$path}/*.zip"), glob("{$path}/*.xml"),
|
||||
glob(TMP . "/*.zip"), glob(TMP . "/*.xml"), glob(TMP . "/stigs/xml/*.xml")
|
||||
);
|
||||
if (!count($stig_files)) {
|
||||
die("Could not find any other zip files in " . realpath(TMP));
|
||||
}
|
||||
|
||||
$script = realpath(defined('PHP_BIN') ? PHP_BIN : PHP) .
|
||||
" -c " . realpath(PHP_CONF) .
|
||||
" -f " . realpath(DOC_ROOT . "/exec/background_stigs.php") . " --" .
|
||||
(isset($cmd['exclude']) && $cmd['exclude'] ? " --exclude=\"{$cmd['exclude']}\"" : "") .
|
||||
" --delete";
|
||||
|
||||
$log->debug("Script to run $script");
|
||||
passthru($script);
|
||||
}
|
||||
|
||||
$db->help->select_count("sagacity.stigs");
|
||||
$stig_count = $db->help->execute();
|
||||
|
||||
$db->set_Setting("stig-count", $stig_count);
|
||||
|
||||
$diff->stopClock();
|
||||
|
||||
print PHP_EOL . "Finished at {$diff->getEndClockTime()}" . PHP_EOL .
|
||||
"Total Time: {$diff->getDiffString()}" . PHP_EOL;
|
||||
|
||||
sleep(3);
|
||||
}
|
||||
|
||||
if (is_a($diff->getTotalDiff(), 'DateInterval')) {
|
||||
print "Total Script Time: {$diff->getTotalDiffString()}" . PHP_EOL;
|
||||
}
|
||||
@ -723,6 +793,7 @@ Usage: php update_db.php [--cpe] [--cve] [--nvd] [--nasl] [--stig] [-u={URL}] [-
|
||||
--nasl To download OpenVAS NVT library and update NASL files
|
||||
You can also extract *.nasl files from the Nessus library to $tmp/nessus_plugins and it will include these in the update
|
||||
--stig To download and update the STIG library
|
||||
--sunset To download and update the STIG library with the STIGs DISA has archived
|
||||
|
||||
--do To download the files only...do not call the parsers will overwrite any existing files
|
||||
--po To parse the downloaded files only, do not download
|
||||
|
Reference in New Issue
Block a user