diff --git a/exec/parse_excel_echecklist.php b/exec/parse_excel_echecklist.php index 3091e6f..e740d15 100644 --- a/exec/parse_excel_echecklist.php +++ b/exec/parse_excel_echecklist.php @@ -358,12 +358,11 @@ foreach ($objSS->getWorksheetIterator() as $wksht) { $status = $wksht->getCell(Coordinate::stringFromColumnIndex($idx['target'] + $x) . $row->getRowIndex()) ->getValue(); if(!in_array(strtolower($status), ['not reviewed', 'not a finding', 'open', 'not applicable', 'no data', 'exception', 'false positive'])) { - if(!preg_match("/Formula found in status column/", $notes)) { + if(stripos($notes, "Formula found in status column") === false) { $notes .= "Formula found in status column"; } $status = "Not Reviewed"; $scan->set_Host_Error($tgt->get_ID(), true, "Formula found in the status column"); - $scan->setScanError(true); } $findings = $tgt_findings[$tgt->get_ID()]; @@ -380,13 +379,12 @@ foreach ($objSS->getWorksheetIterator() as $wksht) { } else { $tmp = new finding($tgt->get_ID(), $stig->get_PDI_ID(), $scan->get_ID(), $status, $notes, null, null, null); $tmp->set_Category($cat_lvl); - $tmp->set_Scan_ID($scan->get_ID()); $new_findings[] = $tmp; } $log->debug("{$tgt->get_Name()} {$stig->get_ID()} ({$tmp->get_Finding_Status_String()})"); $x++; - } + } if(count($updated_findings) + count($new_findings) >= 1000) { if(!$db->add_Findings_By_Target($updated_findings, $new_findings)) { @@ -408,10 +406,7 @@ foreach ($objSS->getWorksheetIterator() as $wksht) { } } -/** @var host_list $h */ -foreach($scan->get_Host_List() as $h) { - $db->update_Target_Counts($h->getTargetId()); -} +$db->update_Scan_Host_List($scan); unset($objSS); if (!isset($cmd['debug'])) { diff --git a/inc/database.inc b/inc/database.inc index 275c6e0..531638e 100644 --- a/inc/database.inc +++ b/inc/database.inc @@ -3427,7 +3427,9 @@ class db } } else { $ret[$worksheet_name]['stigs'][$row['stig_id']][$row['tgt_name']] = $row['finding_status']; - $ret[$worksheet_name]['stigs'][$row['stig_id']]['echecklist']->append_Notes($row['notes'] . PHP_EOL); + if(stripos($ret[$worksheet_name]['stigs'][$row['stig_id']]['echecklist']->get_Notes(), $row['notes']) === false) { + $ret[$worksheet_name]['stigs'][$row['stig_id']]['echecklist']->append_Notes($row['notes'] . PHP_EOL); + } } if ($row['chk_type'] == 'manual') { @@ -8417,8 +8419,7 @@ EOQ; } if ($new_Scan->get_ID()) { $this->help->update("scans", [ - 'src_id' => $new_Scan->get_Source() - ->get_ID(), + 'src_id' => $new_Scan->get_Source()->get_ID(), 'itr' => $new_Scan->get_Itr(), 'file_date' => $new_Scan->get_File_DateTime(), 'pid' => $new_Scan->get_PID(), @@ -8439,14 +8440,10 @@ EOQ; if (! $this->help->execute()) { $this->help->debug(E_ERROR); } - - $this->update_Scan_Host_List($new_Scan, $new_Scan->get_Host_List()); } else { $this->help->insert("scans", [ - 'src_id' => $new_Scan->get_Source() - ->get_ID(), - 'ste_id' => $new_Scan->get_STE() - ->get_ID(), + 'src_id' => $new_Scan->get_Source()->get_ID(), + 'ste_id' => $new_Scan->get_STE()->get_ID(), 'itr' => $new_Scan->get_Itr(), 'file_name' => $new_Scan->get_File_Name(), 'file_date' => $new_Scan->get_File_DateTime(), @@ -8466,9 +8463,10 @@ EOQ; } $new_Scan->set_ID($this->conn->insert_id); - - $this->update_Scan_Host_List($new_Scan, $new_Scan->get_Host_List()); } + + $this->update_Scan_Host_List($new_Scan, $new_Scan->get_Host_List()); + return $new_Scan->get_ID(); } @@ -8598,6 +8596,8 @@ EOQ; $host->getScanError(), $host->getScanNotes() ]; + + $this->update_Target_Counts($host->getTargetId()); } } else { foreach ($host_list as $host) { @@ -8611,6 +8611,8 @@ EOQ; $host->getScanError(), $host->getScanNotes() ]; + + $this->update_Target_Counts($host->getTargetId()); } }