fix: fix host_list overwriting with eChecklist
This commit is contained in:
parent
5d65d6294f
commit
eec2c371fe
@ -625,13 +625,15 @@ class scan
|
|||||||
*/
|
*/
|
||||||
public function set_Host_Error($tgt_id, $is_error, $err_msg = null)
|
public function set_Host_Error($tgt_id, $is_error, $err_msg = null)
|
||||||
{
|
{
|
||||||
foreach($this->host_list as $x => $h) {
|
if(isset($this->host_list[$tgt_id])) {
|
||||||
/** @var host_list $h */
|
$h = $this->host_list[$tgt_id];
|
||||||
if($h->getTargetId() == $tgt_id) {
|
|
||||||
$this->host_list[$x]->setScanError($is_error);
|
$h->setScanError($is_error);
|
||||||
$this->host_list[$x]->setScanNotes($err_msg);
|
$h->setScanNotes($err_msg);
|
||||||
return true;
|
|
||||||
}
|
$this->host_list[$tgt_id] = $h;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -248,27 +248,29 @@ foreach ($objSS->getWorksheetIterator() as $wksht) {
|
|||||||
$tgts[] = $tgt;
|
$tgts[] = $tgt;
|
||||||
|
|
||||||
$log->debug("Adding new target to host list", ['row_count' => $row_count, 'tgt_id' => $tgt->get_ID(), 'tgt_name' => $tgt->get_Name()]);
|
$log->debug("Adding new target to host list", ['row_count' => $row_count, 'tgt_id' => $tgt->get_ID(), 'tgt_name' => $tgt->get_Name()]);
|
||||||
$hl = new host_list();
|
|
||||||
$hl->setFindingCount($row_count);
|
|
||||||
$hl->setTargetId($tgt->get_ID());
|
|
||||||
$hl->setTargetName($tgt->get_Name());
|
|
||||||
if ($ip) {
|
|
||||||
$hl->setTargetIp($ip);
|
|
||||||
} elseif (is_array($tgt->interfaces) && count($tgt->interfaces)) {
|
|
||||||
foreach ($tgt->interfaces as $int) {
|
|
||||||
if (!in_array($int->get_IPv4(), ['0.0.0.0', '127.0.0.1'])) {
|
|
||||||
$ip = $int->get_IPv4();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$hl->setTargetIp($ip);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!isset($scan->get_Host_List()[$tgt->get_ID()])) {
|
if(!isset($scan->get_Host_List()[$tgt->get_ID()])) {
|
||||||
|
$hl = new host_list();
|
||||||
|
$hl->setFindingCount($row_count);
|
||||||
|
$hl->setTargetId($tgt->get_ID());
|
||||||
|
$hl->setTargetName($tgt->get_Name());
|
||||||
|
if ($ip) {
|
||||||
|
$hl->setTargetIp($ip);
|
||||||
|
} elseif (is_array($tgt->interfaces) && count($tgt->interfaces)) {
|
||||||
|
foreach ($tgt->interfaces as $int) {
|
||||||
|
if (!in_array($int->get_IPv4(), ['0.0.0.0', '127.0.0.1'])) {
|
||||||
|
$ip = $int->get_IPv4();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$hl->setTargetIp($ip);
|
||||||
|
}
|
||||||
|
|
||||||
$scan->add_Target_to_Host_List($hl);
|
$scan->add_Target_to_Host_List($hl);
|
||||||
} else {
|
} else {
|
||||||
$existingFindingCount = $scan->get_Host_List()[$tgt->get_ID()]->getFindingCount();
|
$hl = $scan->get_Host_List()[$tgt->get_ID()];
|
||||||
$hl->addFindingCount($existingFindingCount);
|
|
||||||
|
$hl->addFindingCount($row_count);
|
||||||
|
|
||||||
$scan->add_Target_to_Host_List($hl);
|
$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)) {
|
if (!$db->add_Findings_By_Target($updated_findings, $new_findings)) {
|
||||||
print "Error adding finding" . PHP_EOL;
|
print "Error adding finding" . PHP_EOL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->update_Scan_Host_List($scan);
|
|
||||||
|
|
||||||
unset($objSS);
|
unset($objSS);
|
||||||
if (!isset($cmd['debug'])) {
|
if (!isset($cmd['debug'])) {
|
||||||
rename($cmd['f'], TMP . "/echecklist/$base_name");
|
rename($cmd['f'], TMP . "/echecklist/$base_name");
|
||||||
|
Loading…
Reference in New Issue
Block a user