fix: fix host_list overwriting with eChecklist

This commit is contained in:
Ryan Prather 2019-01-15 14:56:57 -05:00
parent 5d65d6294f
commit eec2c371fe
No known key found for this signature in database
GPG Key ID: 66FDE2B4E8AB87A7
2 changed files with 31 additions and 27 deletions

View File

@ -625,14 +625,16 @@ class scan
*/
public function set_Host_Error($tgt_id, $is_error, $err_msg = null)
{
foreach($this->host_list as $x => $h) {
/** @var host_list $h */
if($h->getTargetId() == $tgt_id) {
$this->host_list[$x]->setScanError($is_error);
$this->host_list[$x]->setScanNotes($err_msg);
if(isset($this->host_list[$tgt_id])) {
$h = $this->host_list[$tgt_id];
$h->setScanError($is_error);
$h->setScanNotes($err_msg);
$this->host_list[$tgt_id] = $h;
return true;
}
}
return false;
}

View File

@ -248,6 +248,7 @@ foreach ($objSS->getWorksheetIterator() as $wksht) {
$tgts[] = $tgt;
$log->debug("Adding new target to host list", ['row_count' => $row_count, 'tgt_id' => $tgt->get_ID(), 'tgt_name' => $tgt->get_Name()]);
if(!isset($scan->get_Host_List()[$tgt->get_ID()])) {
$hl = new host_list();
$hl->setFindingCount($row_count);
$hl->setTargetId($tgt->get_ID());
@ -264,11 +265,12 @@ foreach ($objSS->getWorksheetIterator() as $wksht) {
$hl->setTargetIp($ip);
}
if(!isset($scan->get_Host_List()[$tgt->get_ID()])) {
$scan->add_Target_to_Host_List($hl);
} else {
$existingFindingCount = $scan->get_Host_List()[$tgt->get_ID()]->getFindingCount();
$hl->addFindingCount($existingFindingCount);
$hl = $scan->get_Host_List()[$tgt->get_ID()];
$hl->addFindingCount($row_count);
$scan->add_Target_to_Host_List($hl);
}
}
@ -401,13 +403,13 @@ foreach ($objSS->getWorksheetIterator() as $wksht) {
}
}
$db->update_Scan_Host_List($scan);
if (!$db->add_Findings_By_Target($updated_findings, $new_findings)) {
print "Error adding finding" . PHP_EOL;
}
}
$db->update_Scan_Host_List($scan);
unset($objSS);
if (!isset($cmd['debug'])) {
rename($cmd['f'], TMP . "/echecklist/$base_name");