33namespace CleantalkSP \SpbctWP ;
44
55use CleantalkSP \SpbctWP \AdjustToEnvironmentModule \AdjustToEnvironmentHandler ;
6+ use CleantalkSP \SpbctWP \Scanner \ScannerAjaxEndpoints ;
7+ use CleantalkSP \SpbctWP \Scanner \ScanRepository ;
68use CleantalkSP \SpbctWP \Settings \FilesScanPathExclusion ;
79
810class Sync
@@ -17,6 +19,7 @@ class Sync
1719 'settings_exclusions ' => 'Handling exclusions... ' ,
1820 'adjust_env ' => 'Adjusting environment... ' ,
1921 'vulnerability_check ' => 'Running vulnerability check... ' ,
22+ 'analysis_log_update ' => 'Updating cloud analysis verdicts... ' ,
2023 'finalize ' => 'Sync end... ' ,
2124 );
2225
@@ -101,6 +104,7 @@ public static function run()
101104 self ::stepSettingsExclusions ();
102105 self ::stepAdjustEnv ();
103106 self ::stepVulnerabilityCheck ();
107+ self ::stepAnalysisLogUpdate ($ account_is_ok );
104108
105109 $ out = array (
106110 'success ' => true ,
@@ -179,6 +183,9 @@ public static function runCurrentStep()
179183 case 'vulnerability_check ' :
180184 self ::stepVulnerabilityCheck ();
181185 break ;
186+ case 'analysis_log_update ' :
187+ self ::stepAnalysisLogUpdate ($ account_is_ok );
188+ break ;
182189 case 'finalize ' :
183190 self ::stepFinalize ();
184191
@@ -392,6 +399,36 @@ private static function stepVulnerabilityCheck()
392399 Cron::updateTask ('check_vulnerabilities ' , 'spbc_security_check_vulnerabilities ' , 86400 , time ());
393400 }
394401
402+ /**
403+ * Pull actual cloud verdicts for the scan results files.
404+ * The cloud verdict may be changed after the file processing is done,
405+ * so the files with the final verdict have to be re-checked too.
406+ *
407+ * @param bool $account_is_ok
408+ */
409+ private static function stepAnalysisLogUpdate ($ account_is_ok )
410+ {
411+ global $ spbc ;
412+
413+ if ( ! $ account_is_ok || ! is_main_site () ) {
414+ return ;
415+ }
416+
417+ $ file_ids = ScanRepository::getCloudAnalysisFilesFastHashes ();
418+
419+ if ( empty ($ file_ids ) ) {
420+ return ;
421+ }
422+
423+ $ result = ScannerAjaxEndpoints::checkFilesAnalysisStatus (true , $ file_ids );
424+
425+ if ( ! empty ($ result ['error ' ]) ) {
426+ $ spbc ->error_add ('analysis_log_update ' , $ result );
427+ } else {
428+ $ spbc ->error_delete ('analysis_log_update ' );
429+ }
430+ }
431+
395432 private static function stepFinalize ()
396433 {
397434 global $ spbc ;
0 commit comments