From d8fd934fd2b8d5eb84165192bb305ab129694ce8 Mon Sep 17 00:00:00 2001 From: Glomberg Date: Tue, 23 Jul 2024 17:10:46 +0300 Subject: [PATCH 1/5] Fix. FSWatcher. The module logic fixed. --- .../Common/FSWatcher/Controller.php | 11 ------ lib/CleantalkSP/Common/FSWatcher/Service.php | 34 ------------------- .../Common/FSWatcher/View/View.php | 2 +- .../FSWatcher/assets/fswatcher-logic.js | 2 +- .../Common/FSWatcher/assets/fswatcher.js | 8 ----- .../FSWatcher/SpbctWpFSWController.php | 12 ------- .../SpbctWP/FSWatcher/SpbctWpFSWService.php | 5 --- .../SpbctWP/FSWatcher/View/View.php | 2 +- 8 files changed, 3 insertions(+), 73 deletions(-) delete mode 100755 lib/CleantalkSP/Common/FSWatcher/assets/fswatcher.js diff --git a/lib/CleantalkSP/Common/FSWatcher/Controller.php b/lib/CleantalkSP/Common/FSWatcher/Controller.php index ecc57f8a3..77cff0cee 100755 --- a/lib/CleantalkSP/Common/FSWatcher/Controller.php +++ b/lib/CleantalkSP/Common/FSWatcher/Controller.php @@ -70,17 +70,6 @@ public static function work($params) return; } - if (!Service::isRC()) { - if (Service::isMinIntervalPassed(self::EXECUTION_MIN_INTERVAL)) { - if (self::$debug) { - Logger::log('attach js to make remote request'); - } - ob_start(['CleantalkSP\Common\FSWatcher\Service', 'attachJS']); - } - - return; - } - if (!Service::isRateLimitPass()) { http_response_code(403); die('Rate limit exceeded. Protected - Security by CleanTalk.'); diff --git a/lib/CleantalkSP/Common/FSWatcher/Service.php b/lib/CleantalkSP/Common/FSWatcher/Service.php index eb8bc8f63..761d87292 100755 --- a/lib/CleantalkSP/Common/FSWatcher/Service.php +++ b/lib/CleantalkSP/Common/FSWatcher/Service.php @@ -51,40 +51,6 @@ public static function isMinIntervalPassed($interval) return (time() - $last_exec_time) > $interval; } - /** - * Attach JS file for start ajax call - * - * @param $buffer string - * @return string - * - * @psalm-suppress PossiblyUnusedReturnValue - */ - public static function attachJS($buffer, $file_to_get_md5 = null) - { - if (empty($file_to_get_md5)) { - $file_to_get_md5 = __FILE__; - } - $is_ajax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'; - $is_html = preg_match('/^\s*(var fswatcherToken = "' . md5((string)filemtime($file_to_get_md5)) . '";' - . '' - . ''; - - $buffer = preg_replace( - '/<\/body>(\s|<.*>)*<\/html>\s*$/i', - $addition . '', - $buffer, - 1 - ); - } - - return $buffer; - } - /** * Is ajax call is in process * diff --git a/lib/CleantalkSP/Common/FSWatcher/View/View.php b/lib/CleantalkSP/Common/FSWatcher/View/View.php index 6614d9c43..7aca189d9 100755 --- a/lib/CleantalkSP/Common/FSWatcher/View/View.php +++ b/lib/CleantalkSP/Common/FSWatcher/View/View.php @@ -61,7 +61,7 @@ public static function renderSelectors(Phrases $phrases) $html .= ''; $html .= ''; diff --git a/lib/CleantalkSP/Common/FSWatcher/assets/fswatcher-logic.js b/lib/CleantalkSP/Common/FSWatcher/assets/fswatcher-logic.js index bb4a9fa02..401d92d21 100644 --- a/lib/CleantalkSP/Common/FSWatcher/assets/fswatcher-logic.js +++ b/lib/CleantalkSP/Common/FSWatcher/assets/fswatcher-logic.js @@ -411,7 +411,7 @@ function toggleFSWSelectorsInfo(enable) { */ function FSWrequest(data, callback) { let xhr = new XMLHttpRequest(); - xhr.open("POST", fswatcherWebsiteUrl + '/'); + xhr.open("POST", fswatcherWebsiteUrl); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.send(data.join('&')); xhr.onreadystatechange = function() { diff --git a/lib/CleantalkSP/Common/FSWatcher/assets/fswatcher.js b/lib/CleantalkSP/Common/FSWatcher/assets/fswatcher.js deleted file mode 100755 index 802b34332..000000000 --- a/lib/CleantalkSP/Common/FSWatcher/assets/fswatcher.js +++ /dev/null @@ -1,8 +0,0 @@ -document.addEventListener('DOMContentLoaded', function() { - if (typeof fswatcherToken !== 'undefined' && fswatcherWebsiteUrl !== 'undefined') { - let xhr = new XMLHttpRequest(); - xhr.open("POST", fswatcherWebsiteUrl + '/'); - xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); - xhr.send('fswatcher_token=' + fswatcherToken); - } -}); diff --git a/lib/CleantalkSP/SpbctWP/FSWatcher/SpbctWpFSWController.php b/lib/CleantalkSP/SpbctWP/FSWatcher/SpbctWpFSWController.php index 9000b7bd4..da3add856 100644 --- a/lib/CleantalkSP/SpbctWP/FSWatcher/SpbctWpFSWController.php +++ b/lib/CleantalkSP/SpbctWP/FSWatcher/SpbctWpFSWController.php @@ -75,18 +75,6 @@ public static function work($params) return; } - if (!SpbctWpFSWService::isRC()) { - $min_exec_time = $spbc->settings['scanner__fs_watcher__snapshots_period'] ?: parent::EXECUTION_MIN_INTERVAL; - if (SpbctWpFSWService::isMinIntervalPassed($min_exec_time)) { - if (self::$debug) { - Logger::log('attach js to make remote request'); - } - ob_start(['CleantalkSP\SpbctWP\FSWatcher\SpbctWpFSWService', 'attachJS']); - } - - return; - } - if (!SpbctWpFSWService::isRateLimitPass()) { echo json_encode(array('error' => 'Rate limit exceeded. Protected - Security by CleanTalk.')); die(); diff --git a/lib/CleantalkSP/SpbctWP/FSWatcher/SpbctWpFSWService.php b/lib/CleantalkSP/SpbctWP/FSWatcher/SpbctWpFSWService.php index 7c329ee51..7155a43ff 100644 --- a/lib/CleantalkSP/SpbctWP/FSWatcher/SpbctWpFSWService.php +++ b/lib/CleantalkSP/SpbctWP/FSWatcher/SpbctWpFSWService.php @@ -67,11 +67,6 @@ public static function setAllJournalsAsCompleted() $storage::setAllJournalsAsCompleted(); } - public static function attachJS($buffer, $file_to_get_md5 = null) - { - return parent::attachJS($buffer, __FILE__); - } - public static function generateFsWatcherToken($salt = '') { return wp_create_nonce('spbc_secret_fs_watcher_token'); diff --git a/lib/CleantalkSP/SpbctWP/FSWatcher/View/View.php b/lib/CleantalkSP/SpbctWP/FSWatcher/View/View.php index dfd611da5..9e8e3c705 100644 --- a/lib/CleantalkSP/SpbctWP/FSWatcher/View/View.php +++ b/lib/CleantalkSP/SpbctWP/FSWatcher/View/View.php @@ -66,7 +66,7 @@ public static function renderSelectors(\CleantalkSP\Common\FSWatcher\View\Phrase $html .= ''; From 40ad8184ce32340af0b108a49b15ebd34a693214 Mon Sep 17 00:00:00 2001 From: Glomberg Date: Thu, 24 Oct 2024 21:17:47 +0300 Subject: [PATCH 2/5] Fix. FSWatcher. The huge refactoring has been completed. --- inc/spbc-settings.php | 3 +- js/spbc-scanner-plugin.min.js | 2 +- js/spbc-scanner-plugin.min.js.map | 2 +- js/spbc-settings_tab--fswatcher.min.js | 2 + js/spbc-settings_tab--fswatcher.min.js.map | 1 + js/spbc-table.min.js | 2 +- js/spbc-table.min.js.map | 2 +- .../src/spbc-settings_tab--fswatcher.js | 313 ++++++++---------- .../Common/FSWatcher/Analyzer/index.php | 1 - .../Common/FSWatcher/Controller.php | 139 -------- .../Common/FSWatcher/Repository/index.php | 1 - .../Common/FSWatcher/Scan/Scan.php | 45 --- .../Common/FSWatcher/Scan/index.php | 1 - lib/CleantalkSP/Common/FSWatcher/Service.php | 157 --------- .../Common/FSWatcher/Storage/FileStorage.php | 188 ----------- .../Common/FSWatcher/Storage/data/index.php | 1 - .../Common/FSWatcher/Storage/index.php | 1 - .../Common/FSWatcher/View/Phrases.php | 23 -- .../Common/FSWatcher/View/View.php | 136 -------- .../Common/FSWatcher/View/index.php | 1 - .../Common/FSWatcher/assets/index.php | 1 - lib/CleantalkSP/Common/FSWatcher/index.php | 1 - .../Common/FSWatcher/logs/index.php | 3 - .../FSWatcher/Analyzer/Analyzer.php | 93 +++++- .../FSWatcher/Analyzer/SpbctWpFSWAnalyzer.php | 120 ------- .../SpbctWP/FSWatcher/Controller.php | 161 +++++++++ .../SpbctWP/FSWatcher/Dto/FSWatcherParams.php | 10 + .../{Common => SpbctWP}/FSWatcher/Logger.php | 2 +- .../FSWatcher/Repository/FileRepository.php | 7 +- .../FSWatcher/Repository/Repository.php | 5 +- .../Repository/SpbctWpFSWFileRepository.php | 21 -- .../SpbctWP/FSWatcher/Scan/Scan.php | 38 +++ .../SpbctWP/FSWatcher/Scan/SpbctWpFSWScan.php | 33 -- .../{SpbctWpFSWService.php => Service.php} | 52 +-- .../FSWatcher/SpbctWpFSWController.php | 179 ---------- ...ctWpFSWFileStorage.php => FileStorage.php} | 32 +- .../FSWatcher/Storage/Storage.php | 5 +- .../SpbctWP/FSWatcher/View/Phrases.php | 2 +- .../SpbctWP/FSWatcher/View/View.php | 80 ++++- security-malware-firewall.php | 14 +- 40 files changed, 555 insertions(+), 1325 deletions(-) create mode 100644 js/spbc-settings_tab--fswatcher.min.js create mode 100644 js/spbc-settings_tab--fswatcher.min.js.map rename lib/CleantalkSP/Common/FSWatcher/assets/fswatcher-logic.js => js/src/spbc-settings_tab--fswatcher.js (59%) delete mode 100644 lib/CleantalkSP/Common/FSWatcher/Analyzer/index.php delete mode 100755 lib/CleantalkSP/Common/FSWatcher/Controller.php delete mode 100644 lib/CleantalkSP/Common/FSWatcher/Repository/index.php delete mode 100755 lib/CleantalkSP/Common/FSWatcher/Scan/Scan.php delete mode 100644 lib/CleantalkSP/Common/FSWatcher/Scan/index.php delete mode 100755 lib/CleantalkSP/Common/FSWatcher/Service.php delete mode 100755 lib/CleantalkSP/Common/FSWatcher/Storage/FileStorage.php delete mode 100644 lib/CleantalkSP/Common/FSWatcher/Storage/data/index.php delete mode 100644 lib/CleantalkSP/Common/FSWatcher/Storage/index.php delete mode 100644 lib/CleantalkSP/Common/FSWatcher/View/Phrases.php delete mode 100755 lib/CleantalkSP/Common/FSWatcher/View/View.php delete mode 100644 lib/CleantalkSP/Common/FSWatcher/View/index.php delete mode 100644 lib/CleantalkSP/Common/FSWatcher/assets/index.php delete mode 100644 lib/CleantalkSP/Common/FSWatcher/index.php delete mode 100644 lib/CleantalkSP/Common/FSWatcher/logs/index.php rename lib/CleantalkSP/{Common => SpbctWP}/FSWatcher/Analyzer/Analyzer.php (59%) mode change 100755 => 100644 delete mode 100644 lib/CleantalkSP/SpbctWP/FSWatcher/Analyzer/SpbctWpFSWAnalyzer.php create mode 100644 lib/CleantalkSP/SpbctWP/FSWatcher/Controller.php create mode 100644 lib/CleantalkSP/SpbctWP/FSWatcher/Dto/FSWatcherParams.php rename lib/CleantalkSP/{Common => SpbctWP}/FSWatcher/Logger.php (97%) mode change 100755 => 100644 rename lib/CleantalkSP/{Common => SpbctWP}/FSWatcher/Repository/FileRepository.php (64%) mode change 100755 => 100644 rename lib/CleantalkSP/{Common => SpbctWP}/FSWatcher/Repository/Repository.php (64%) mode change 100755 => 100644 delete mode 100644 lib/CleantalkSP/SpbctWP/FSWatcher/Repository/SpbctWpFSWFileRepository.php create mode 100644 lib/CleantalkSP/SpbctWP/FSWatcher/Scan/Scan.php delete mode 100644 lib/CleantalkSP/SpbctWP/FSWatcher/Scan/SpbctWpFSWScan.php rename lib/CleantalkSP/SpbctWP/FSWatcher/{SpbctWpFSWService.php => Service.php} (50%) delete mode 100644 lib/CleantalkSP/SpbctWP/FSWatcher/SpbctWpFSWController.php rename lib/CleantalkSP/SpbctWP/FSWatcher/Storage/{SpbctWpFSWFileStorage.php => FileStorage.php} (90%) rename lib/CleantalkSP/{Common => SpbctWP}/FSWatcher/Storage/Storage.php (92%) mode change 100755 => 100644 diff --git a/inc/spbc-settings.php b/inc/spbc-settings.php index 6d8c8600b..c2bfa224c 100644 --- a/inc/spbc-settings.php +++ b/inc/spbc-settings.php @@ -1090,7 +1090,8 @@ function spbc_settings__register() ), ), ), - 'display' => $spbc->settings['scanner__fs_watcher'] + 'display' => $spbc->settings['scanner__fs_watcher'], + 'js_after' => 'settings_tab--fswatcher.min.js', ), // Debug 'debug' => array( diff --git a/js/spbc-scanner-plugin.min.js b/js/spbc-scanner-plugin.min.js index abc8af228..028c8cf0a 100644 --- a/js/spbc-scanner-plugin.min.js +++ b/js/spbc-scanner-plugin.min.js @@ -1,2 +1,2 @@ -"use strict";class SpbcMalwareScanner{first_start=!0;active=!1;root="";settings=[];states=["get_cms_hashes","get_modules_hashes","clean_results","file_system_analysis","get_approved_hashes","get_denied_hashes","signature_analysis","heuristic_analysis","schedule_send_heuristic_suspicious_files","auto_cure_backup","auto_cure","outbound_links","frontend_analysis","important_files_listing","send_results"];state=null;offset=0;amount=0;amount_coefficient=1;total_scanned=0;scan_percent=0;percent_completed=0;paused=!1;button=null;spinner=null;progress_overall=null;progressbar=null;progressbar_text=null;timeout=6e4;state_timer=0;constructor(t){for(var e in console.log("init"),jQuery("#spbcscan-results-log-module").length&&jQuery(".spbc-scan-log-title").removeClass("spbc---hidden"),void 0!==t.settings.auto_cure&&(t.settings.scanner__auto_cure_backup="1"),t)void 0!==this[e]&&(this[e]=t[e])}actionControl(){null===this.state?this.start():this.paused?(this.resume(),this.controller()):this.pause()}start(){this.active=!0,this.state_timer=Math.round((new Date).getTime()/1e3),this.state=this.getNextState(null),this.setPercents(0),this.scan_percent=0,this.offset=0,this.progress_overall.children("span").removeClass("spbc_bold").filter(".spbc_overall_scan_status_"+this.state).addClass("spbc_bold"),this.progressbar.show(500),this.progress_overall.show(500),this.button.html(spbcScaner.button_scan_pause),this.spinner.css({display:"inline"}),setTimeout(()=>{this.controller()},1e3)}pause(t,e,s){console.log("PAUSE"),this.button.html(spbcScaner.button_scan_resume),this.spinner.css({display:"none"}),this.paused=!0,this.active=!1}resume(t){console.log("RESUME"),this.button.html(spbcScaner.button_scan_pause),this.spinner.css({display:"inline"}),this.paused=!1,this.active=!0}end(t){this.progressbar.hide(500),this.progress_overall.hide(500),this.button.html(spbcScaner.button_scan_perform),this.spinner.css({display:"none"}),this.state=null,this.plug=!1,this.total_scanned=0,this.active=!1,t?document.location=document.location:(spbcSendAJAXRequest({action:"spbc_scanner_tab__reload_accordion"},{notJson:!0,callback:function(t,e,s,i){jQuery(i).accordion("destroy").html(t).accordion({header:"h3",heightStyle:"content",collapsible:!0,active:!1}),spbcTblBulkActionsListen(),spbcTblRowActionsListen(),spbcTblPaginationListen(),spbcTblSortListen(),spbcStartShowHide(),spbcScannerReloadScanInfo()}},jQuery("#spbc_scan_accordion")),jQuery("#spbc_scanner_clear").length||jQuery('
').insertBefore("#spbcscan-scanner-caption"))}controller(t){if(console.log(this.state),void 0!==t&&t.end){if(this.state=this.getNextState(this.state),void 0===this.state)return void this.end();this.setPercents(0),this.scan_percent=0,this.offset=0,this.progress_overall.children("span").removeClass("spbc_bold").filter(".spbc_overall_scan_status_"+this.state).addClass("spbc_bold")}if(!0!==this.paused){var e={action:"spbc_scanner_controller_front",method:this.state,offset:this.offset},t={type:"GET",success:this.success,callback:this.successCallback,error:this.error,errorOutput:this.errorOutput,complete:null,context:this,timeout:12e4};switch(this.state){case"get_modules_hashes":this.amount=2;break;case"clear_table":this.amount=1e4;break;case"file_system_analysis":this.amount=700;break;case"auto_cure":this.amount=5;break;case"outbound_links":this.amount=10;break;case"frontend_analysis":this.amount=spbcSettings.frontendAnalysisAmount;break;case"signature_analysis":this.amount=10,e.status="UNKNOWN,MODIFIED,OK,INFECTED,ERROR";break;case"heuristic_analysis":this.amount=4,e.status="UNKNOWN,MODIFIED,OK,INFECTED,ERROR";break;case"schedule_send_heuristic_suspicious_files":this.amount=1}e.amount=Math.round(this.amount*this.amount_coefficient),spbcSendAJAXRequest(e,t,jQuery("#spbc_scan_accordion"))}}setCoefficients(t){let e=this.amount_coefficient;"file_system_analysis"===t&&(e*=1.5),this.amount_coefficient=e}getNextState(t){return t=null===t?this.states[0]:this.states[this.states.indexOf(t)+1],t=void 0!==this.settings["scanner__"+t]&&0==+this.settings["scanner__"+t]?this.getNextState(t):t}setPercents(t){this.percent_completed=Math.floor(100*t)/100,this.progressbar.progressbar("option","value",this.percent_completed),this.progressbar_text.text(spbcScaner["progressbar_"+this.state]+" - "+this.percent_completed+"%")}success(t){t.error?this.error({status:200,responseText:t.error},t.error,t.msg):this.successCallback&&this.successCallback(t,this.data,this.obj)}successCallback(e){if(console.log(e),this.interactAccordion(e),void 0!==e.total&&(this.scan_percent=100/e.total),void 0!==e.processed_items&&("heuristic_analysis"===this.state&&0!==typeof e.total&&this.logRaw('

Heuristic Analysis

'),"signature_analysis"===this.state&&0!==typeof e.total&&this.logRaw('

Signature Analysis

'),this.logFileEntry(e.processed_items)),void 0!==e.stage_data_for_logging&&this.logStageEntry(e.stage_data_for_logging),void 0!==e.cured&&0{this.controller(e)},300)}interactAccordion(t){t.hasOwnProperty("interactivity_data")&&t.interactivity_data.hasOwnProperty("update_text")&&t.interactivity_data.update_text&&t.interactivity_data.hasOwnProperty("refresh_data")&&t.interactivity_data.refresh_data.hasOwnProperty("do_refresh")&&t.interactivity_data.refresh_data.do_refresh&&t.interactivity_data.refresh_data.hasOwnProperty("control_tab")&&t.interactivity_data.refresh_data.control_tab&&spbcReloadAccordion(t.interactivity_data.refresh_data.control_tab,t.interactivity_data.update_text)}error(t,e,s){var i=this.errorOutput;if(console.log("%c APBCT_AJAX_ERROR","color: red;"),console.log(e),console.log(s),console.log(t),"error"==e&&(""==s||"Not found"==s)&&(this.tryCount||(this.tryCount=0,this.retryLimit=30),this.tryCount++,console.log("Try #"+this.tryCount),this.setCoefficients(this.state),this.tryCount<=this.retryLimit))this.pause(),this.resume(),this.controller();else{if(200===t.status)if("parsererror"===e)i("Unexpected response from server. See console for details.",this.state),console.log("%c "+t.responseText,"color: pink;");else{let t=e;void 0!==s&&(t+=" Additional info: "+s),i(t,this.state)}else 500===t.status?i("Internal server error.",this.state):i("Unexpected response code: "+t.status+". Error: "+e,this.state);this.progressbar&&this.progressbar.fadeOut("slow"),this.end()}}errorOutput(t,e){spbcModal.open().putError(t+"
Stage: "+e)}logRaw(t){jQuery(".spbc-scan-log-title").removeClass("spbc---hidden"),jQuery(".spbc_log-wrapper").removeClass("spbc---hidden"),jQuery(".spbc_log-wrapper .panel-body").prepend(t)}logFileEntry(t){for(var e in t)e&&this.logRaw('

'+this.getSiteUTCShiftedTimeString()+" - "+t[e].path+" - "+t[e].module+": "+t[e].status+"

")}logStageEntry(t){void 0!==jQuery(".panel-body .spbc_log-line span").first()&&void 0!==jQuery(".panel-body .spbc_log-line span").first()[0]&&jQuery(".panel-body .spbc_log-line span").first()[0].textContent===t.description||this.logRaw('

test '+this.getSiteUTCShiftedTimeString()+" - "+t.title+" "+t.description+"

")}showLinkForShuffleSalts(t){jQuery("#spbc_notice_about_shuffle_link").remove(),jQuery(jQuery(".spbc_tab--active .spbc_wrapper_field p")[1]).after('")}getSiteUTCShiftedTimeString(){let t=!1;var e=-1*(new Date).getTimezoneOffset()*1e3*60,e=(t="undefined"!=typeof spbcScaner&&void 0!==spbcScaner.timezone_shift&&!1!==spbcScaner.timezone_shift?Date.now()-e+1e3*spbcScaner.timezone_shift:t)?new Date(t):new Date,s=new Intl.DateTimeFormat("en-US",{month:"short"}).format,i=String(e.getMinutes()).padStart(2,"0"),a=String(e.getSeconds()).padStart(2,"0");return s(e)+" "+e.getDate()+" "+e.getFullYear()+" "+e.getHours()+":"+i+":"+a}} +class SpbcMalwareScanner{first_start=!0;active=!1;root="";settings=[];states=["get_cms_hashes","get_modules_hashes","clean_results","file_system_analysis","get_approved_hashes","get_denied_hashes","signature_analysis","heuristic_analysis","schedule_send_heuristic_suspicious_files","auto_cure_backup","auto_cure","outbound_links","frontend_analysis","important_files_listing","send_results"];state=null;offset=0;amount=0;amount_coefficient=1;total_scanned=0;scan_percent=0;percent_completed=0;paused=!1;button=null;spinner=null;progress_overall=null;progressbar=null;progressbar_text=null;timeout=6e4;state_timer=0;constructor(t){for(var e in console.log("init"),jQuery("#spbcscan-results-log-module").length&&jQuery(".spbc-scan-log-title").removeClass("spbc---hidden"),void 0!==t.settings.auto_cure&&(t.settings.scanner__auto_cure_backup="1"),t)void 0!==this[e]&&(this[e]=t[e])}actionControl(){null===this.state?this.start():this.paused?(this.resume(),this.controller()):this.pause()}start(){this.active=!0,this.state_timer=Math.round((new Date).getTime()/1e3),this.state=this.getNextState(null),this.setPercents(0),this.scan_percent=0,this.offset=0,this.progress_overall.children("span").removeClass("spbc_bold").filter(".spbc_overall_scan_status_"+this.state).addClass("spbc_bold"),this.progressbar.show(500),this.progress_overall.show(500),this.button.html(spbcScaner.button_scan_pause),this.spinner.css({display:"inline"}),setTimeout(()=>{this.controller()},1e3)}pause(t,e,s){console.log("PAUSE"),this.button.html(spbcScaner.button_scan_resume),this.spinner.css({display:"none"}),this.paused=!0,this.active=!1}resume(t){console.log("RESUME"),this.button.html(spbcScaner.button_scan_pause),this.spinner.css({display:"inline"}),this.paused=!1,this.active=!0}end(t){this.progressbar.hide(500),this.progress_overall.hide(500),this.button.html(spbcScaner.button_scan_perform),this.spinner.css({display:"none"}),this.state=null,this.plug=!1,this.total_scanned=0,this.active=!1,t?document.location=document.location:(spbcSendAJAXRequest({action:"spbc_scanner_tab__reload_accordion"},{notJson:!0,callback:function(t,e,s,a){jQuery(a).accordion("destroy").html(t).accordion({header:"h3",heightStyle:"content",collapsible:!0,active:!1}),spbcTblBulkActionsListen(),spbcTblRowActionsListen(),spbcTblPaginationListen(),spbcTblSortListen(),spbcStartShowHide(),spbcScannerReloadScanInfo()}},jQuery("#spbc_scan_accordion")),jQuery("#spbc_scanner_clear").length||jQuery('
').insertBefore("#spbcscan-scanner-caption"))}controller(t){if(console.log(this.state),void 0!==t&&t.end){if(this.state=this.getNextState(this.state),void 0===this.state)return void this.end();this.setPercents(0),this.scan_percent=0,this.offset=0,this.progress_overall.children("span").removeClass("spbc_bold").filter(".spbc_overall_scan_status_"+this.state).addClass("spbc_bold")}if(!0!==this.paused){var e={action:"spbc_scanner_controller_front",method:this.state,offset:this.offset},t={type:"GET",success:this.success,callback:this.successCallback,error:this.error,errorOutput:this.errorOutput,complete:null,context:this,timeout:12e4};switch(this.state){case"get_modules_hashes":this.amount=2;break;case"clear_table":this.amount=1e4;break;case"file_system_analysis":this.amount=700;break;case"auto_cure":this.amount=5;break;case"outbound_links":this.amount=10;break;case"frontend_analysis":this.amount=spbcSettings.frontendAnalysisAmount;break;case"signature_analysis":this.amount=10,e.status="UNKNOWN,MODIFIED,OK,INFECTED,ERROR";break;case"heuristic_analysis":this.amount=4,e.status="UNKNOWN,MODIFIED,OK,INFECTED,ERROR";break;case"schedule_send_heuristic_suspicious_files":this.amount=1}e.amount=Math.round(this.amount*this.amount_coefficient),spbcSendAJAXRequest(e,t,jQuery("#spbc_scan_accordion"))}}setCoefficients(t){let e=this.amount_coefficient;"file_system_analysis"===t&&(e*=1.5),this.amount_coefficient=e}getNextState(t){return t=null===t?this.states[0]:this.states[this.states.indexOf(t)+1],t=void 0!==this.settings["scanner__"+t]&&0==+this.settings["scanner__"+t]?this.getNextState(t):t}setPercents(t){this.percent_completed=Math.floor(100*t)/100,this.progressbar.progressbar("option","value",this.percent_completed),this.progressbar_text.text(spbcScaner["progressbar_"+this.state]+" - "+this.percent_completed+"%")}success(t){t.error?this.error({status:200,responseText:t.error},t.error,t.msg):this.successCallback&&this.successCallback(t,this.data,this.obj)}successCallback(e){if(console.log(e),this.interactAccordion(e),void 0!==e.total&&(this.scan_percent=100/e.total),void 0!==e.processed_items&&("heuristic_analysis"===this.state&&0!==typeof e.total&&this.logRaw('

Heuristic Analysis

'),"signature_analysis"===this.state&&0!==typeof e.total&&this.logRaw('

Signature Analysis

'),this.logFileEntry(e.processed_items)),void 0!==e.stage_data_for_logging&&this.logStageEntry(e.stage_data_for_logging),void 0!==e.cured&&0{this.controller(e)},300)}interactAccordion(t){t.hasOwnProperty("interactivity_data")&&t.interactivity_data.hasOwnProperty("update_text")&&t.interactivity_data.update_text&&t.interactivity_data.hasOwnProperty("refresh_data")&&t.interactivity_data.refresh_data.hasOwnProperty("do_refresh")&&t.interactivity_data.refresh_data.do_refresh&&t.interactivity_data.refresh_data.hasOwnProperty("control_tab")&&t.interactivity_data.refresh_data.control_tab&&spbcReloadAccordion(t.interactivity_data.refresh_data.control_tab,t.interactivity_data.update_text)}error(t,e,s){var a=this.errorOutput;if(console.log("%c APBCT_AJAX_ERROR","color: red;"),console.log(e),console.log(s),console.log(t),"error"==e&&(""==s||"Not found"==s)&&(this.tryCount||(this.tryCount=0,this.retryLimit=30),this.tryCount++,console.log("Try #"+this.tryCount),this.setCoefficients(this.state),this.tryCount<=this.retryLimit))this.pause(),this.resume(),this.controller();else{if(200===t.status)if("parsererror"===e)a("Unexpected response from server. See console for details.",this.state),console.log("%c "+t.responseText,"color: pink;");else{let t=e;void 0!==s&&(t+=" Additional info: "+s),a(t,this.state)}else 500===t.status?a("Internal server error.",this.state):a("Unexpected response code: "+t.status+". Error: "+e,this.state);this.progressbar&&this.progressbar.fadeOut("slow"),this.end()}}errorOutput(t,e){spbcModal.open().putError(t+"
Stage: "+e)}logRaw(t){jQuery(".spbc-scan-log-title").removeClass("spbc---hidden"),jQuery(".spbc_log-wrapper").removeClass("spbc---hidden"),jQuery(".spbc_log-wrapper .panel-body").prepend(t)}logFileEntry(t){for(var e in t)e&&this.logRaw('

'+this.getSiteUTCShiftedTimeString()+" - "+t[e].path+" - "+t[e].module+": "+t[e].status+"

")}logStageEntry(t){void 0!==jQuery(".panel-body .spbc_log-line span").first()&&void 0!==jQuery(".panel-body .spbc_log-line span").first()[0]&&jQuery(".panel-body .spbc_log-line span").first()[0].textContent===t.description||this.logRaw('

test '+this.getSiteUTCShiftedTimeString()+" - "+t.title+" "+t.description+"

")}showLinkForShuffleSalts(t){jQuery("#spbc_notice_about_shuffle_link").remove(),jQuery(jQuery(".spbc_tab--active .spbc_wrapper_field p")[1]).after('")}getSiteUTCShiftedTimeString(){let t=!1;var e=-1*(new Date).getTimezoneOffset()*1e3*60,e=(t="undefined"!=typeof spbcScaner&&void 0!==spbcScaner.timezone_shift&&!1!==spbcScaner.timezone_shift?Date.now()-e+1e3*spbcScaner.timezone_shift:t)?new Date(t):new Date,s=new Intl.DateTimeFormat("en-US",{month:"short"}).format,a=String(e.getMinutes()).padStart(2,"0"),i=String(e.getSeconds()).padStart(2,"0");return s(e)+" "+e.getDate()+" "+e.getFullYear()+" "+e.getHours()+":"+a+":"+i}} //# sourceMappingURL=spbc-scanner-plugin.min.js.map diff --git a/js/spbc-scanner-plugin.min.js.map b/js/spbc-scanner-plugin.min.js.map index 41611b1ba..03c3ec17b 100644 --- a/js/spbc-scanner-plugin.min.js.map +++ b/js/spbc-scanner-plugin.min.js.map @@ -1 +1 @@ -{"version":3,"file":"spbc-scanner-plugin.min.js","sources":["spbc-scanner-plugin.js"],"sourcesContent":["'use strict';\n\n/**\n * class SpbcMalwareScanner\n */\nclass SpbcMalwareScanner {/* eslint-disable-line no-unused-vars */\n first_start = true;\n\n active = false;\n\n root = '';\n settings = [];\n states = [\n 'get_cms_hashes',\n 'get_modules_hashes',\n 'clean_results',\n 'file_system_analysis',\n 'get_approved_hashes',\n 'get_denied_hashes',\n 'signature_analysis',\n 'heuristic_analysis',\n 'schedule_send_heuristic_suspicious_files',\n 'auto_cure_backup',\n 'auto_cure',\n 'outbound_links',\n 'frontend_analysis',\n 'important_files_listing',\n 'send_results',\n ];\n state = null;\n offset = 0;\n amount = 0;\n amount_coefficient = 1;\n total_scanned = 0;\n scan_percent = 0;\n percent_completed = 0;\n\n paused = false;\n\n button = null;\n spinner = null;\n\n progress_overall = null;\n progressbar = null;\n progressbar_text = null;\n\n timeout = 60000;\n\n state_timer = 0;\n\n /**\n * constructor\n * @param {array} properties\n */\n constructor( properties ) {\n console.log('init');\n if (jQuery('#spbcscan-results-log-module').length) {\n jQuery('.spbc-scan-log-title').removeClass('spbc---hidden');\n }\n\n // Crunch for cure backups\n if ( typeof properties['settings']['auto_cure'] !== 'undefined' ) {\n properties['settings']['scanner__auto_cure_backup'] = '1';\n }\n\n for ( let key in properties ) {\n if ( typeof this[key] !== 'undefined' ) {\n this[key] = properties[key];\n }\n }\n };\n\n /**\n * Function Action Control\n */\n actionControl() {\n if (this.state === null) {\n this.start();\n } else if (this.paused) {\n this.resume();\n this.controller();\n } else {\n this.pause();\n }\n };\n\n /**\n * Function Start\n */\n start() {\n this.active = true;\n this.state_timer = Math.round(new Date().getTime() /1000);\n\n this.state = this.getNextState( null );\n\n this.setPercents( 0 );\n this.scan_percent = 0;\n this.offset = 0;\n this.progress_overall.children('span')\n .removeClass('spbc_bold')\n .filter('.spbc_overall_scan_status_' + this.state)\n .addClass('spbc_bold');\n\n this.progressbar.show(500);\n this.progress_overall.show(500);\n this.button.html(spbcScaner.button_scan_pause);\n this.spinner.css({display: 'inline'});\n\n setTimeout(() => {\n this.controller();\n }, 1000);\n };\n\n /**\n * Function Pause\n * @param {*} result\n * @param {*} data\n * @param {*} opt\n */\n pause( result, data, opt ) {\n console.log('PAUSE');\n this.button.html(spbcScaner.button_scan_resume);\n this.spinner.css({display: 'none'});\n this.paused = true;\n this.active = false;\n };\n\n /**\n * Function Resume\n * @param {*} opt\n */\n resume( opt ) {\n console.log('RESUME');\n this.button.html(spbcScaner.button_scan_pause);\n this.spinner.css({display: 'inline'});\n this.paused = false;\n this.active = true;\n };\n\n /**\n * Function End\n * @param {bool} reload\n */\n end( reload ) {\n this.progressbar.hide(500);\n this.progress_overall.hide(500);\n this.button.html(spbcScaner.button_scan_perform);\n this.spinner.css({display: 'none'});\n this.state = null;\n this.plug = false;\n this.total_scanned = 0;\n this.active = false;\n\n if (reload) {\n document.location = document.location;\n } else {\n spbcSendAJAXRequest(\n {action: 'spbc_scanner_tab__reload_accordion'},\n {\n notJson: true,\n callback: function(result, data, params, obj) {\n jQuery(obj).accordion('destroy')\n .html(result)\n .accordion({\n header: 'h3',\n heightStyle: 'content',\n collapsible: true,\n active: false,\n });\n spbcTblBulkActionsListen();\n spbcTblRowActionsListen();\n spbcTblPaginationListen();\n spbcTblSortListen();\n spbcStartShowHide();\n spbcScannerReloadScanInfo();\n },\n },\n jQuery('#spbc_scan_accordion'),\n );\n\n if (!jQuery('#spbc_scanner_clear').length) {\n let clearLink = '

Clear scanner logs


';\n jQuery(clearLink).insertBefore('#spbcscan-scanner-caption');\n }\n }\n };\n\n /**\n * Function Controller\n * @param {obj} result\n */\n controller( result ) {\n console.log(this.state);\n\n // The current stage is over. Switching to the new one\n if ( typeof result !== 'undefined' && result.end ) {\n this.state = this.getNextState( this.state );\n\n // End condition\n if (typeof this.state === 'undefined') {\n this.end();\n return;\n }\n\n // Set percent to 0\n this.setPercents( 0 );\n this.scan_percent = 0;\n this.offset = 0;\n\n // Changing visualizing of the current stage\n this.progress_overall.children('span')\n .removeClass('spbc_bold')\n .filter('.spbc_overall_scan_status_' + this.state)\n .addClass('spbc_bold');\n }\n\n // Break execution if paused\n if ( this.paused === true ) {\n return;\n }\n\n // // AJAX params\n let data = {\n action: 'spbc_scanner_controller_front',\n method: this.state,\n offset: this.offset,\n };\n\n let params = {\n type: 'GET',\n success: this.success,\n callback: this.successCallback,\n error: this.error,\n errorOutput: this.errorOutput,\n complete: null,\n context: this,\n timeout: 120000,\n };\n\n switch (this.state) {\n case 'get_modules_hashes': this.amount = 2; break;\n case 'clear_table': this.amount = 10000; break;\n case 'file_system_analysis': this.amount = 700; break;\n case 'auto_cure': this.amount = 5; break;\n case 'outbound_links': this.amount = 10; break;\n case 'frontend_analysis': this.amount = spbcSettings.frontendAnalysisAmount; break;\n case 'signature_analysis': this.amount = 10; data.status = 'UNKNOWN,MODIFIED,OK,INFECTED,ERROR'; break;\n case 'heuristic_analysis': this.amount = 4; data.status = 'UNKNOWN,MODIFIED,OK,INFECTED,ERROR'; break;\n case 'schedule_send_heuristic_suspicious_files': this.amount = 1; break;\n }\n\n data.amount = Math.round(this.amount * this.amount_coefficient);\n\n spbcSendAJAXRequest(\n data,\n params,\n jQuery('#spbc_scan_accordion'),\n );\n };\n\n /**\n * Set Coefficients\n * @param {string} state\n */\n setCoefficients( state ) {\n let coefficient = this.amount_coefficient;\n switch (state) {\n case 'file_system_analysis': coefficient *= 1.5; break;\n }\n this.amount_coefficient = coefficient;\n };\n\n /**\n * Get Next State\n * @param {string} state\n * @return {number}\n */\n getNextState( state ) {\n state = state === null ? this.states[0] : this.states[this.states.indexOf( state ) + 1];\n\n if (typeof this.settings['scanner__' + state] !== 'undefined' && +this.settings['scanner__' + state] === 0) {\n state = this.getNextState( state );\n }\n\n return state;\n };\n\n /**\n * Set Percents\n * @param {number} percents\n */\n setPercents( percents ) {\n this.percent_completed = Math.floor( percents * 100 ) / 100;\n this.progressbar.progressbar( 'option', 'value', this.percent_completed );\n this.progressbar_text.text( spbcScaner['progressbar_' + this.state] + ' - ' + this.percent_completed + '%' );\n };\n\n /**\n * Function Success\n * @param {obj} response\n */\n success( response ) {\n if ( !! response.error ) {\n this.error(\n {status: 200, responseText: response.error},\n response.error,\n response.msg,\n );\n } else {\n if ( this.successCallback ) {\n this.successCallback( response, this.data, this.obj );\n }\n }\n };\n\n // Processing response from backend\n /**\n * Success Callback\n * @param {obj} result\n */\n successCallback( result ) {\n console.log( result );\n\n this.interactAccordion(result);\n\n if ( typeof result.total !== 'undefined' ) {\n this.scan_percent = 100 / result.total;\n }\n\n if ( typeof result.processed_items !== 'undefined') {\n if ( this.state === 'heuristic_analysis' && typeof result.total !== 0 ) {\n this.logRaw('

Heuristic Analysis

');\n }\n if ( this.state === 'signature_analysis' && typeof result.total !== 0 ) {\n this.logRaw('

Signature Analysis

');\n }\n\n this.logFileEntry( result.processed_items );\n }\n\n if ( typeof result.stage_data_for_logging !== 'undefined') {\n this.logStageEntry( result.stage_data_for_logging );\n }\n\n // Add link on shuffle salt if cured\n if (result.cured !== undefined && Number(result.cured) > 0) {\n this.showLinkForShuffleSalts(result.message);\n }\n\n if ( result.end !== true && result.end !== 1 ) {\n let processedPercents = this.percent_completed + result.processed * this.scan_percent;\n if (result.stage_data_for_logging.title === 'File System Analysis' && processedPercents > 100) {\n processedPercents = 100;\n }\n this.setPercents(processedPercents);\n this.offset = this.offset + result.processed;\n this.controller( result );\n } else {\n console.log( this.state +\n ' stage took ' +\n ( Math.round(new Date().getTime() /1000) - this.state_timer ) +\n ' seconds to complete' );\n this.state_timer = Math.round(new Date().getTime()/1000);\n this.setPercents( 100 );\n this.scan_percent = 0;\n this.offset = 0;\n setTimeout(() => {\n this.controller( result );\n }, 300);\n }\n };\n\n /**\n * Run interactive refresh for accordion.\n * @param {obj|string[]} result\n */\n interactAccordion(result) {\n // validation control\n if (result.hasOwnProperty('interactivity_data') &&\n result.interactivity_data.hasOwnProperty('update_text') &&\n result.interactivity_data.update_text &&\n result.interactivity_data.hasOwnProperty('refresh_data') &&\n result.interactivity_data.refresh_data.hasOwnProperty('do_refresh') &&\n result.interactivity_data.refresh_data.do_refresh &&\n result.interactivity_data.refresh_data.hasOwnProperty('control_tab') &&\n result.interactivity_data.refresh_data.control_tab\n ) {\n spbcReloadAccordion(\n result.interactivity_data.refresh_data.control_tab,\n result.interactivity_data.update_text,\n );\n }\n }\n\n /**\n * Function Error\n * @param {object} xhr\n * @param {string} status\n * @param {string} error\n */\n error( xhr, status, error ) {\n let errorOutput = this.errorOutput;\n\n console.log( '%c APBCT_AJAX_ERROR', 'color: red;' );\n console.log( status );\n console.log( error );\n console.log( xhr );\n\n if (status == 'error' && (error == '' || error == 'Not found')) {\n if (!this.tryCount) {\n this.tryCount = 0;\n this.retryLimit = 30;\n }\n this.tryCount++;\n console.log('Try #' + this.tryCount);\n this.setCoefficients(this.state);\n if (this.tryCount <= this.retryLimit) {\n this.pause();\n this.resume();\n this.controller();\n return;\n }\n }\n\n if ( xhr.status === 200 ) {\n if ( status === 'parsererror' ) {\n errorOutput( 'Unexpected response from server. See console for details.', this.state );\n console.log( '%c ' + xhr.responseText, 'color: pink;' );\n } else {\n let errorString = status;\n if ( typeof error !== 'undefined' ) {\n errorString += ' Additional info: ' + error;\n }\n errorOutput( errorString, this.state );\n }\n } else if (xhr.status === 500) {\n errorOutput( 'Internal server error.', this.state);\n } else {\n errorOutput('Unexpected response code: ' + xhr.status + '. Error: ' + status, this.state);\n }\n\n if ( this.progressbar ) {\n this.progressbar.fadeOut('slow');\n }\n\n this.end();\n };\n\n /**\n * Error Output\n * @param {string} errorMsg\n * @param {string} stage\n */\n errorOutput( errorMsg, stage ) {\n spbcModal.open().putError( errorMsg + '
Stage: ' + stage);\n };\n\n /**\n * Log Raw\n * @param {htmlString|Element|Text|Array|jQuery} messageToLog\n */\n logRaw(messageToLog) {\n jQuery('.spbc-scan-log-title').removeClass('spbc---hidden');\n jQuery('.spbc_log-wrapper').removeClass('spbc---hidden');\n jQuery('.spbc_log-wrapper .panel-body').prepend( messageToLog );\n };\n\n /**\n * Log File Entry\n * @param {array} items\n */\n logFileEntry(items) {\n for ( let key in items ) {\n if ( key ) {\n this.logRaw(\n '

' +\n this.getSiteUTCShiftedTimeString() + ' - ' +\n items[key].path + ' - ' + items[key].module +\n ': ' + items[key].status + '' +\n '

');\n }\n }\n };\n\n /**\n * Log Stage Entry\n * @param {obj} data\n */\n logStageEntry(data) {\n if (typeof jQuery('.panel-body .spbc_log-line span').first() !== 'undefined' &&\n typeof jQuery('.panel-body .spbc_log-line span').first()[0] !== 'undefined' &&\n jQuery('.panel-body .spbc_log-line span').first()[0].textContent === data.description\n ) {\n return;\n }\n this.logRaw( '

test ' +\n this.getSiteUTCShiftedTimeString() + ' - ' + '' +\n data.title + ' ' + '' + data.description + '

' );\n };\n\n /**\n * Show Link For Shuffle Salts\n * @param {string} message\n */\n showLinkForShuffleSalts(message) {\n jQuery('#spbc_notice_about_shuffle_link').remove();\n jQuery(jQuery('.spbc_tab--active .spbc_wrapper_field p')[1])\n .after(\n '
' +\n '' +\n message +\n '' +\n '
',\n );\n }\n\n /**\n * Get Site UTC Shifted Time String\n * @return {string}\n */\n getSiteUTCShiftedTimeString() {\n let utcShiftedTs = false;\n // gettings current system/browser offset\n let currentBrowserOffset = new Date().getTimezoneOffset();\n currentBrowserOffset = currentBrowserOffset * -1 * 1000 * 60;\n // chek if global ct object is defined\n if (typeof spbcScaner !== 'undefined' &&\n typeof spbcScaner.timezone_shift !== 'undefined' &&\n spbcScaner.timezone_shift !== false) {\n utcShiftedTs = Date.now() - currentBrowserOffset + (spbcScaner.timezone_shift * 1000);\n }\n let ctDate = utcShiftedTs ? new Date(utcShiftedTs) : new Date();\n // construct date string\n let shortMonthName = new Intl.DateTimeFormat('en-US', {month: 'short'}).format;\n let minutes = String(ctDate.getMinutes()).padStart(2, '0');\n let seconds = String(ctDate.getSeconds()).padStart(2, '0');\n return shortMonthName(ctDate) + ' ' +\n ctDate.getDate() + ' ' + ctDate.getFullYear() + ' ' +\n ctDate.getHours() + ':' + minutes + ':' + seconds;\n }\n}\n"],"names":["SpbcMalwareScanner","first_start","active","root","settings","states","state","offset","amount","amount_coefficient","total_scanned","scan_percent","percent_completed","paused","button","spinner","progress_overall","progressbar","progressbar_text","timeout","state_timer","constructor","properties","let","key","console","log","jQuery","length","removeClass","this","actionControl","start","resume","controller","pause","Math","round","Date","getTime","getNextState","setPercents","children","filter","addClass","show","html","spbcScaner","button_scan_pause","css","display","setTimeout","result","data","opt","button_scan_resume","end","reload","hide","button_scan_perform","plug","document","location","spbcSendAJAXRequest","action","notJson","callback","params","obj","accordion","header","heightStyle","collapsible","spbcTblBulkActionsListen","spbcTblRowActionsListen","spbcTblPaginationListen","spbcTblSortListen","spbcStartShowHide","spbcScannerReloadScanInfo","insertBefore","method","type","success","successCallback","error","errorOutput","complete","context","spbcSettings","frontendAnalysisAmount","status","setCoefficients","coefficient","indexOf","percents","floor","text","response","responseText","msg","interactAccordion","total","processed_items","logRaw","logFileEntry","stage_data_for_logging","logStageEntry","undefined","cured","Number","showLinkForShuffleSalts","message","processedPercents","processed","title","hasOwnProperty","interactivity_data","update_text","refresh_data","do_refresh","control_tab","spbcReloadAccordion","xhr","tryCount","retryLimit","errorString","fadeOut","errorMsg","stage","spbcModal","open","putError","messageToLog","prepend","items","getSiteUTCShiftedTimeString","path","module","first","textContent","description","remove","after","utcShiftedTs","currentBrowserOffset","getTimezoneOffset","ctDate","timezone_shift","now","shortMonthName","Intl","DateTimeFormat","month","format","minutes","String","getMinutes","padStart","seconds","getSeconds","getDate","getFullYear","getHours"],"mappings":"AAAA,mBAKMA,mBACFC,YAAc,CAAA,EAEdC,OAAS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OU,WAAW,CAAC,EAAEC,SAAS,EAAG,GAAG,EACrDC,EAAUH,OAAOT,EAAOa,WAAW,CAAC,EAAEF,SAAS,EAAG,GAAG,EACzD,OAAOR,EAAeH,CAAM,EAAI,IAC5BA,EAAOc,QAAQ,EAAI,IAAMd,EAAOe,YAAY,EAAI,IAChDf,EAAOgB,SAAS,EAAI,IAAMR,EAAU,IAAMI,CAClD,CACJ"} \ No newline at end of file +{"version":3,"file":"spbc-scanner-plugin.min.js","sources":["spbc-scanner-plugin.js"],"sourcesContent":["'use strict';\n\n/**\n * class SpbcMalwareScanner\n */\nclass SpbcMalwareScanner {/* eslint-disable-line no-unused-vars */\n first_start = true;\n\n active = false;\n\n root = '';\n settings = [];\n states = [\n 'get_cms_hashes',\n 'get_modules_hashes',\n 'clean_results',\n 'file_system_analysis',\n 'get_approved_hashes',\n 'get_denied_hashes',\n 'signature_analysis',\n 'heuristic_analysis',\n 'schedule_send_heuristic_suspicious_files',\n 'auto_cure_backup',\n 'auto_cure',\n 'outbound_links',\n 'frontend_analysis',\n 'important_files_listing',\n 'send_results',\n ];\n state = null;\n offset = 0;\n amount = 0;\n amount_coefficient = 1;\n total_scanned = 0;\n scan_percent = 0;\n percent_completed = 0;\n\n paused = false;\n\n button = null;\n spinner = null;\n\n progress_overall = null;\n progressbar = null;\n progressbar_text = null;\n\n timeout = 60000;\n\n state_timer = 0;\n\n /**\n * constructor\n * @param {array} properties\n */\n constructor( properties ) {\n console.log('init');\n if (jQuery('#spbcscan-results-log-module').length) {\n jQuery('.spbc-scan-log-title').removeClass('spbc---hidden');\n }\n\n // Crunch for cure backups\n if ( typeof properties['settings']['auto_cure'] !== 'undefined' ) {\n properties['settings']['scanner__auto_cure_backup'] = '1';\n }\n\n for ( let key in properties ) {\n if ( typeof this[key] !== 'undefined' ) {\n this[key] = properties[key];\n }\n }\n };\n\n /**\n * Function Action Control\n */\n actionControl() {\n if (this.state === null) {\n this.start();\n } else if (this.paused) {\n this.resume();\n this.controller();\n } else {\n this.pause();\n }\n };\n\n /**\n * Function Start\n */\n start() {\n this.active = true;\n this.state_timer = Math.round(new Date().getTime() /1000);\n\n this.state = this.getNextState( null );\n\n this.setPercents( 0 );\n this.scan_percent = 0;\n this.offset = 0;\n this.progress_overall.children('span')\n .removeClass('spbc_bold')\n .filter('.spbc_overall_scan_status_' + this.state)\n .addClass('spbc_bold');\n\n this.progressbar.show(500);\n this.progress_overall.show(500);\n this.button.html(spbcScaner.button_scan_pause);\n this.spinner.css({display: 'inline'});\n\n setTimeout(() => {\n this.controller();\n }, 1000);\n };\n\n /**\n * Function Pause\n * @param {*} result\n * @param {*} data\n * @param {*} opt\n */\n pause( result, data, opt ) {\n console.log('PAUSE');\n this.button.html(spbcScaner.button_scan_resume);\n this.spinner.css({display: 'none'});\n this.paused = true;\n this.active = false;\n };\n\n /**\n * Function Resume\n * @param {*} opt\n */\n resume( opt ) {\n console.log('RESUME');\n this.button.html(spbcScaner.button_scan_pause);\n this.spinner.css({display: 'inline'});\n this.paused = false;\n this.active = true;\n };\n\n /**\n * Function End\n * @param {bool} reload\n */\n end( reload ) {\n this.progressbar.hide(500);\n this.progress_overall.hide(500);\n this.button.html(spbcScaner.button_scan_perform);\n this.spinner.css({display: 'none'});\n this.state = null;\n this.plug = false;\n this.total_scanned = 0;\n this.active = false;\n\n if (reload) {\n document.location = document.location;\n } else {\n spbcSendAJAXRequest(\n {action: 'spbc_scanner_tab__reload_accordion'},\n {\n notJson: true,\n callback: function(result, data, params, obj) {\n jQuery(obj).accordion('destroy')\n .html(result)\n .accordion({\n header: 'h3',\n heightStyle: 'content',\n collapsible: true,\n active: false,\n });\n spbcTblBulkActionsListen();\n spbcTblRowActionsListen();\n spbcTblPaginationListen();\n spbcTblSortListen();\n spbcStartShowHide();\n spbcScannerReloadScanInfo();\n },\n },\n jQuery('#spbc_scan_accordion'),\n );\n\n if (!jQuery('#spbc_scanner_clear').length) {\n let clearLink = '

Clear scanner logs


';\n jQuery(clearLink).insertBefore('#spbcscan-scanner-caption');\n }\n }\n };\n\n /**\n * Function Controller\n * @param {obj} result\n */\n controller( result ) {\n console.log(this.state);\n\n // The current stage is over. Switching to the new one\n if ( typeof result !== 'undefined' && result.end ) {\n this.state = this.getNextState( this.state );\n\n // End condition\n if (typeof this.state === 'undefined') {\n this.end();\n return;\n }\n\n // Set percent to 0\n this.setPercents( 0 );\n this.scan_percent = 0;\n this.offset = 0;\n\n // Changing visualizing of the current stage\n this.progress_overall.children('span')\n .removeClass('spbc_bold')\n .filter('.spbc_overall_scan_status_' + this.state)\n .addClass('spbc_bold');\n }\n\n // Break execution if paused\n if ( this.paused === true ) {\n return;\n }\n\n // // AJAX params\n let data = {\n action: 'spbc_scanner_controller_front',\n method: this.state,\n offset: this.offset,\n };\n\n let params = {\n type: 'GET',\n success: this.success,\n callback: this.successCallback,\n error: this.error,\n errorOutput: this.errorOutput,\n complete: null,\n context: this,\n timeout: 120000,\n };\n\n switch (this.state) {\n case 'get_modules_hashes': this.amount = 2; break;\n case 'clear_table': this.amount = 10000; break;\n case 'file_system_analysis': this.amount = 700; break;\n case 'auto_cure': this.amount = 5; break;\n case 'outbound_links': this.amount = 10; break;\n case 'frontend_analysis': this.amount = spbcSettings.frontendAnalysisAmount; break;\n case 'signature_analysis': this.amount = 10; data.status = 'UNKNOWN,MODIFIED,OK,INFECTED,ERROR'; break;\n case 'heuristic_analysis': this.amount = 4; data.status = 'UNKNOWN,MODIFIED,OK,INFECTED,ERROR'; break;\n case 'schedule_send_heuristic_suspicious_files': this.amount = 1; break;\n }\n\n data.amount = Math.round(this.amount * this.amount_coefficient);\n\n spbcSendAJAXRequest(\n data,\n params,\n jQuery('#spbc_scan_accordion'),\n );\n };\n\n /**\n * Set Coefficients\n * @param {string} state\n */\n setCoefficients( state ) {\n let coefficient = this.amount_coefficient;\n switch (state) {\n case 'file_system_analysis': coefficient *= 1.5; break;\n }\n this.amount_coefficient = coefficient;\n };\n\n /**\n * Get Next State\n * @param {string} state\n * @return {number}\n */\n getNextState( state ) {\n state = state === null ? this.states[0] : this.states[this.states.indexOf( state ) + 1];\n\n if (typeof this.settings['scanner__' + state] !== 'undefined' && +this.settings['scanner__' + state] === 0) {\n state = this.getNextState( state );\n }\n\n return state;\n };\n\n /**\n * Set Percents\n * @param {number} percents\n */\n setPercents( percents ) {\n this.percent_completed = Math.floor( percents * 100 ) / 100;\n this.progressbar.progressbar( 'option', 'value', this.percent_completed );\n this.progressbar_text.text( spbcScaner['progressbar_' + this.state] + ' - ' + this.percent_completed + '%' );\n };\n\n /**\n * Function Success\n * @param {obj} response\n */\n success( response ) {\n if ( !! response.error ) {\n this.error(\n {status: 200, responseText: response.error},\n response.error,\n response.msg,\n );\n } else {\n if ( this.successCallback ) {\n this.successCallback( response, this.data, this.obj );\n }\n }\n };\n\n // Processing response from backend\n /**\n * Success Callback\n * @param {obj} result\n */\n successCallback( result ) {\n console.log( result );\n\n this.interactAccordion(result);\n\n if ( typeof result.total !== 'undefined' ) {\n this.scan_percent = 100 / result.total;\n }\n\n if ( typeof result.processed_items !== 'undefined') {\n if ( this.state === 'heuristic_analysis' && typeof result.total !== 0 ) {\n this.logRaw('

Heuristic Analysis

');\n }\n if ( this.state === 'signature_analysis' && typeof result.total !== 0 ) {\n this.logRaw('

Signature Analysis

');\n }\n\n this.logFileEntry( result.processed_items );\n }\n\n if ( typeof result.stage_data_for_logging !== 'undefined') {\n this.logStageEntry( result.stage_data_for_logging );\n }\n\n // Add link on shuffle salt if cured\n if (result.cured !== undefined && Number(result.cured) > 0) {\n this.showLinkForShuffleSalts(result.message);\n }\n\n if ( result.end !== true && result.end !== 1 ) {\n let processedPercents = this.percent_completed + result.processed * this.scan_percent;\n if (result.stage_data_for_logging.title === 'File System Analysis' && processedPercents > 100) {\n processedPercents = 100;\n }\n this.setPercents(processedPercents);\n this.offset = this.offset + result.processed;\n this.controller( result );\n } else {\n console.log( this.state +\n ' stage took ' +\n ( Math.round(new Date().getTime() /1000) - this.state_timer ) +\n ' seconds to complete' );\n this.state_timer = Math.round(new Date().getTime()/1000);\n this.setPercents( 100 );\n this.scan_percent = 0;\n this.offset = 0;\n setTimeout(() => {\n this.controller( result );\n }, 300);\n }\n };\n\n /**\n * Run interactive refresh for accordion.\n * @param {obj|string[]} result\n */\n interactAccordion(result) {\n // validation control\n if (result.hasOwnProperty('interactivity_data') &&\n result.interactivity_data.hasOwnProperty('update_text') &&\n result.interactivity_data.update_text &&\n result.interactivity_data.hasOwnProperty('refresh_data') &&\n result.interactivity_data.refresh_data.hasOwnProperty('do_refresh') &&\n result.interactivity_data.refresh_data.do_refresh &&\n result.interactivity_data.refresh_data.hasOwnProperty('control_tab') &&\n result.interactivity_data.refresh_data.control_tab\n ) {\n spbcReloadAccordion(\n result.interactivity_data.refresh_data.control_tab,\n result.interactivity_data.update_text,\n );\n }\n }\n\n /**\n * Function Error\n * @param {object} xhr\n * @param {string} status\n * @param {string} error\n */\n error( xhr, status, error ) {\n let errorOutput = this.errorOutput;\n\n console.log( '%c APBCT_AJAX_ERROR', 'color: red;' );\n console.log( status );\n console.log( error );\n console.log( xhr );\n\n if (status == 'error' && (error == '' || error == 'Not found')) {\n if (!this.tryCount) {\n this.tryCount = 0;\n this.retryLimit = 30;\n }\n this.tryCount++;\n console.log('Try #' + this.tryCount);\n this.setCoefficients(this.state);\n if (this.tryCount <= this.retryLimit) {\n this.pause();\n this.resume();\n this.controller();\n return;\n }\n }\n\n if ( xhr.status === 200 ) {\n if ( status === 'parsererror' ) {\n errorOutput( 'Unexpected response from server. See console for details.', this.state );\n console.log( '%c ' + xhr.responseText, 'color: pink;' );\n } else {\n let errorString = status;\n if ( typeof error !== 'undefined' ) {\n errorString += ' Additional info: ' + error;\n }\n errorOutput( errorString, this.state );\n }\n } else if (xhr.status === 500) {\n errorOutput( 'Internal server error.', this.state);\n } else {\n errorOutput('Unexpected response code: ' + xhr.status + '. Error: ' + status, this.state);\n }\n\n if ( this.progressbar ) {\n this.progressbar.fadeOut('slow');\n }\n\n this.end();\n };\n\n /**\n * Error Output\n * @param {string} errorMsg\n * @param {string} stage\n */\n errorOutput( errorMsg, stage ) {\n spbcModal.open().putError( errorMsg + '
Stage: ' + stage);\n };\n\n /**\n * Log Raw\n * @param {htmlString|Element|Text|Array|jQuery} messageToLog\n */\n logRaw(messageToLog) {\n jQuery('.spbc-scan-log-title').removeClass('spbc---hidden');\n jQuery('.spbc_log-wrapper').removeClass('spbc---hidden');\n jQuery('.spbc_log-wrapper .panel-body').prepend( messageToLog );\n };\n\n /**\n * Log File Entry\n * @param {array} items\n */\n logFileEntry(items) {\n for ( let key in items ) {\n if ( key ) {\n this.logRaw(\n '

' +\n this.getSiteUTCShiftedTimeString() + ' - ' +\n items[key].path + ' - ' + items[key].module +\n ': ' + items[key].status + '' +\n '

');\n }\n }\n };\n\n /**\n * Log Stage Entry\n * @param {obj} data\n */\n logStageEntry(data) {\n if (typeof jQuery('.panel-body .spbc_log-line span').first() !== 'undefined' &&\n typeof jQuery('.panel-body .spbc_log-line span').first()[0] !== 'undefined' &&\n jQuery('.panel-body .spbc_log-line span').first()[0].textContent === data.description\n ) {\n return;\n }\n this.logRaw( '

test ' +\n this.getSiteUTCShiftedTimeString() + ' - ' + '' +\n data.title + ' ' + '' + data.description + '

' );\n };\n\n /**\n * Show Link For Shuffle Salts\n * @param {string} message\n */\n showLinkForShuffleSalts(message) {\n jQuery('#spbc_notice_about_shuffle_link').remove();\n jQuery(jQuery('.spbc_tab--active .spbc_wrapper_field p')[1])\n .after(\n '
' +\n '' +\n message +\n '' +\n '
',\n );\n }\n\n /**\n * Get Site UTC Shifted Time String\n * @return {string}\n */\n getSiteUTCShiftedTimeString() {\n let utcShiftedTs = false;\n // gettings current system/browser offset\n let currentBrowserOffset = new Date().getTimezoneOffset();\n currentBrowserOffset = currentBrowserOffset * -1 * 1000 * 60;\n // chek if global ct object is defined\n if (typeof spbcScaner !== 'undefined' &&\n typeof spbcScaner.timezone_shift !== 'undefined' &&\n spbcScaner.timezone_shift !== false) {\n utcShiftedTs = Date.now() - currentBrowserOffset + (spbcScaner.timezone_shift * 1000);\n }\n let ctDate = utcShiftedTs ? new Date(utcShiftedTs) : new Date();\n // construct date string\n let shortMonthName = new Intl.DateTimeFormat('en-US', {month: 'short'}).format;\n let minutes = String(ctDate.getMinutes()).padStart(2, '0');\n let seconds = String(ctDate.getSeconds()).padStart(2, '0');\n return shortMonthName(ctDate) + ' ' +\n ctDate.getDate() + ' ' + ctDate.getFullYear() + ' ' +\n ctDate.getHours() + ':' + minutes + ':' + seconds;\n }\n}\n"],"names":["SpbcMalwareScanner","first_start","active","root","settings","states","state","offset","amount","amount_coefficient","total_scanned","scan_percent","percent_completed","paused","button","spinner","progress_overall","progressbar","progressbar_text","timeout","state_timer","constructor","properties","let","key","console","log","jQuery","length","removeClass","this","actionControl","start","resume","controller","pause","Math","round","Date","getTime","getNextState","setPercents","children","filter","addClass","show","html","spbcScaner","button_scan_pause","css","display","setTimeout","result","data","opt","button_scan_resume","end","reload","hide","button_scan_perform","plug","document","location","spbcSendAJAXRequest","action","notJson","callback","params","obj","accordion","header","heightStyle","collapsible","spbcTblBulkActionsListen","spbcTblRowActionsListen","spbcTblPaginationListen","spbcTblSortListen","spbcStartShowHide","spbcScannerReloadScanInfo","insertBefore","method","type","success","successCallback","error","errorOutput","complete","context","spbcSettings","frontendAnalysisAmount","status","setCoefficients","coefficient","indexOf","percents","floor","text","response","responseText","msg","interactAccordion","total","processed_items","logRaw","logFileEntry","stage_data_for_logging","logStageEntry","undefined","cured","Number","showLinkForShuffleSalts","message","processedPercents","processed","title","hasOwnProperty","interactivity_data","update_text","refresh_data","do_refresh","control_tab","spbcReloadAccordion","xhr","tryCount","retryLimit","errorString","fadeOut","errorMsg","stage","spbcModal","open","putError","messageToLog","prepend","items","getSiteUTCShiftedTimeString","path","module","first","textContent","description","remove","after","utcShiftedTs","currentBrowserOffset","getTimezoneOffset","ctDate","timezone_shift","now","shortMonthName","Intl","DateTimeFormat","month","format","minutes","String","getMinutes","padStart","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KAAKC,eAAe,QAAS,CAACC,MAAO,OAAO,CAAC,EAAEC,OACpEC,EAAUC,OAAOT,EAAOU,WAAW,CAAC,EAAEC,SAAS,EAAG,GAAG,EACrDC,EAAUH,OAAOT,EAAOa,WAAW,CAAC,EAAEF,SAAS,EAAG,GAAG,EACzD,OAAOR,EAAeH,CAAM,EAAI,IAC5BA,EAAOc,QAAQ,EAAI,IAAMd,EAAOe,YAAY,EAAI,IAChDf,EAAOgB,SAAS,EAAI,IAAMR,EAAU,IAAMI,CAClD,CACJ"} \ No newline at end of file diff --git a/js/spbc-settings_tab--fswatcher.min.js b/js/spbc-settings_tab--fswatcher.min.js new file mode 100644 index 000000000..712449d5d --- /dev/null +++ b/js/spbc-settings_tab--fswatcher.min.js @@ -0,0 +1,2 @@ +let noFSWChangesDetected=!0,firstFSWSelector=document.getElementById("fswatcher__first_date"),secondFSWSelector=document.getElementById("fswatcher__second_date"),fsWatcherTableBody=document.getElementById("spbc-table-fs_watcher-comparison"),availableFSWDataSetNames=["added","changed","deleted"];function FSWOnload(){document.querySelector("#fswatcher__first_date").selectedIndex=0;var e=document.querySelector("#fswatcher__second_date");e.selectedIndex=e.options.length-1,FSWCompare(new Event({}))}function FSWCompare(e){if(e.preventDefault(),null!==e.currentTarget&&(document.querySelector("#fsw_preloader_compare").style.display="inline"),void 0===document.getElementById("fswatcher__first_date")||void 0===document.getElementById("fswatcher__second_date"))return!1;var e=document.getElementById("fswatcher__first_date").value,t=document.getElementById("fswatcher__second_date").value;spbcSendAJAXRequest({action:"spbct_fswatcher_compare",fswatcher__first_date:e,fswatcher__second_date:t},{callback:function(e){let t={};if(noFSWChangesDetected=!0,"object"==typeof e)t=e;else if("string"==typeof e&&(t=FSWDecodeJSON(e)).hasOwnProperty("error"))return alert(fswatcherTranslations.fs_err_parse_json),void console.log("File System watcher JSON parse error: "+t.error);e=validateFSWResponse(t);!0===e?(renderFSWatcherTableContent(t),noFSWChangesDetected&&renderFSWTableRow("","no_changes","")):(alert(e+" "+fswatcherTranslations.fs_err_valid_result+" support@cleantalk.org"),console.log("File System watcher response validating error: "+e)),resetFSWSelectors(),toggleFSWSelectorsInfo(!0),document.querySelector("#fsw_preloader_compare").style.display="none"}})}function FSWCreate(e){e.preventDefault(),null!==e.currentTarget&&(document.querySelector("#fsw_preloader_create").style.display="inline");e={callback:function(e){"string"==typeof e&&FSWDecodeJSON(e),document.querySelector("#fsw_preloader_create").style.display="none"},button:e.target,timeout:3e4};spbcSendAJAXRequest({action:"spbct_fswatcher_create_snapshot"},e)}function FSWViewFile(e){var t=jQuery("#wpwrap"),r=jQuery("#spbc_dialog"),n=(r.dialog({modal:!0,title:fswatcherTranslations.fs_modal+" "+e.dataset.path,position:{my:"center top",at:"center top+100px",of:window},width:t.width()/100*90,show:{effect:"blind",duration:500},draggable:!1,resizable:!1,closeText:"X",classes:{"ui-dialog":"spbc---top"},open:function(e,t){e.target.style.overflow="auto",jQuery("#spbc_dialog").height(document.documentElement.clientHeight/100*25)},beforeClose:function(e,t){document.body.style.overflow="auto",jQuery("#spbc_dialog").empty()}}),r.append('Wait for downloading'),jQuery("#spbc_file_view_preloader")),t=4e-4*t.width(),n=(n.height(128*t),n.width(128*t),n.css({left:r.width()/2-128*t/2}),n.css({top:r.height()/2-128*t/2}),jQuery("#fswatcher__first_date").val()),r=jQuery("#fswatcher__second_date").val(),t={action:"spbct_fswatcher_view_file",fswatcher_file_path:e.dataset.path,fswatcher__first_date:n,fswatcher__second_date:r};spbcSendAJAXRequest(t,{callback:function(e){let t="";t=(t=void 0!==e.error?e.error:void 0!==e.data?e.data:"Unknown error on reading file. Data is empty.").split("\n");var r,n=jQuery("#spbc_dialog");n.empty(),jQuery("#spbc_file_view_preloader").css({display:"none"});for(r in t)n.append('
%s

%s


'.printf(+r+1,t[r]));var e=19*Object.keys(t).length<76?76:19*Object.keys(t).length,a=document.documentElement.clientHeight/100*75,o=eView'),"string"==typeof e[1])&&(e=new Date(1e3*Number(e[1])),shortMonthName=new Intl.DateTimeFormat("en-US",{month:"short"}).format,r=String(e.getMinutes()).padStart(2,"0"),n=String(e.getSeconds()).padStart(2,"0"),t.date=shortMonthName(e)+" "+e.getDate()+" "+e.getFullYear()+" "+e.getHours()+":"+r+":"+n),t}function renderFSWTableRow(e,t,r){var n,a;"no_changes"===t?(a=document.createElement("tr"),(n=document.createElement("td")).setAttribute("name","fswatcher-event-no-changes"),n.setAttribute("colspan","3"),n.innerText=fswatcherTranslations.fs_no_changes,a.appendChild(n),fsWatcherTableBody.appendChild(a)):(n=document.createElement("tr"),(a=document.createElement("td")).setAttribute("name","fswatcher-event-path"),a.setAttribute("data-before","Path"),a.innerHTML=e,n.appendChild(a),(e=document.createElement("td")).setAttribute("name","fswatcher-event-type"),e.setAttribute("data-before","Event"),e.innerText=t,n.appendChild(e),(a=document.createElement("td")).setAttribute("name","fswatcher-event-date"),a.setAttribute("data-before","Changed on date"),a.innerText=r,n.appendChild(a),fsWatcherTableBody.appendChild(n))}function filterFSWSecondSelector(){toggleFSWSelectorsInfo(!1)}function filterFSWFirstSelector(){toggleFSWSelectorsInfo(!1)}function resetFSWSelectors(){for(let e=0;e tr").length,e=0"+firstFSWSelector.options[firstFSWSelector.selectedIndex].text+" "+fswatcherTranslations.fs_with+" "+secondFSWSelector.options[secondFSWSelector.selectedIndex].text+" "+fswatcherTranslations.fs_total+" "+e+""):(t.innerText="",t.style.display="none")}"loading"!==document.readyState?FSWOnload():document.addEventListener("DOMContentLoaded",FSWOnload),document.getElementById("fswatcher__compare").addEventListener("click",FSWCompare),document.getElementById("fswatcher__create_snapshot").addEventListener("click",FSWCreate),firstFSWSelector.addEventListener("change",filterFSWSecondSelector),secondFSWSelector.addEventListener("change",filterFSWFirstSelector); +//# sourceMappingURL=spbc-settings_tab--fswatcher.min.js.map diff --git a/js/spbc-settings_tab--fswatcher.min.js.map b/js/spbc-settings_tab--fswatcher.min.js.map new file mode 100644 index 000000000..ddcec68f1 --- /dev/null +++ b/js/spbc-settings_tab--fswatcher.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"spbc-settings_tab--fswatcher.min.js","sources":["spbc-settings_tab--fswatcher.js"],"sourcesContent":["// if no changes detected after comparison\nlet noFSWChangesDetected = true;\n// first selector elem\nconst firstFSWSelector = document.getElementById('fswatcher__first_date');\n// second selector elem\nconst secondFSWSelector = document.getElementById('fswatcher__second_date');\n// FSW table body\nconst fsWatcherTableBody = document.getElementById('spbc-table-fs_watcher-comparison');\n// available types of events\nconst availableFSWDataSetNames = ['added','changed','deleted'];\n\nif( document.readyState !== 'loading' ) {\n FSWOnload();\n} else {\n document.addEventListener('DOMContentLoaded', FSWOnload);\n}\n\n// listeners\ndocument.getElementById('fswatcher__compare').addEventListener('click', FSWCompare);\ndocument.getElementById('fswatcher__create_snapshot').addEventListener('click', FSWCreate);\nfirstFSWSelector.addEventListener('change', filterFSWSecondSelector);\nsecondFSWSelector.addEventListener('change', filterFSWFirstSelector);\n\n\nfunction FSWOnload() {\n document.querySelector('#fswatcher__first_date').selectedIndex = 0;\n let secondDate = document.querySelector('#fswatcher__second_date');\n secondDate.selectedIndex = secondDate.options.length - 1;\n FSWCompare(new Event({}));\n}\n\n/**\n * Main handler function. Run this on the button click.\n * @param {Event} e click event.\n */\nfunction FSWCompare(e) {\n e.preventDefault();\n\n if (e.currentTarget !== null) {\n document.querySelector('#fsw_preloader_compare').style.display = 'inline';\n }\n\n if ( typeof document.getElementById('fswatcher__first_date') === 'undefined'\n || typeof document.getElementById('fswatcher__second_date') === 'undefined' ) {\n return false;\n }\n\n let first_date = document.getElementById('fswatcher__first_date').value;\n let second_date = document.getElementById('fswatcher__second_date').value;\n\n let data = {\n action: 'spbct_fswatcher_compare',\n fswatcher__first_date: first_date,\n fswatcher__second_date: second_date\n };\n\n let params = {\n callback: function (response) {\n let responseDataObj = {};\n noFSWChangesDetected = true;\n if (typeof response === 'object') {\n responseDataObj = response;\n } else if (typeof response === 'string') {\n responseDataObj = FSWDecodeJSON(response)\n if (responseDataObj.hasOwnProperty('error')) {\n alert(fswatcherTranslations['fs_err_parse_json']);\n console.log('File System watcher JSON parse error: ' + responseDataObj.error)\n return;\n }\n }\n\n const validate_result = validateFSWResponse(responseDataObj)\n if (true === validate_result) {\n renderFSWatcherTableContent(responseDataObj)\n if (noFSWChangesDetected) {\n renderFSWTableRow( '', 'no_changes', '')\n }\n } else {\n alert(validate_result + ' ' + fswatcherTranslations['fs_err_valid_result'] + ' support@cleantalk.org');\n console.log('File System watcher response validating error: ' + validate_result)\n }\n resetFSWSelectors();\n toggleFSWSelectorsInfo(true);\n document.querySelector('#fsw_preloader_compare').style.display = 'none';\n }\n };\n\n spbcSendAJAXRequest(data, params);\n}\n\nfunction FSWCreate(e) {\n e.preventDefault();\n\n if (e.currentTarget !== null) {\n document.querySelector('#fsw_preloader_create').style.display = 'inline';\n }\n\n let data = {\n action: 'spbct_fswatcher_create_snapshot'\n };\n\n let params = {\n callback: function (response) {\n let responseDataObj = {};\n if (typeof response === 'string') {\n responseDataObj = FSWDecodeJSON(response);\n }\n document.querySelector('#fsw_preloader_create').style.display = 'none';\n },\n button: e.target,\n timeout: 30000\n };\n\n spbcSendAJAXRequest(data, params);\n}\n\n/**\n * Show file view.\n * @param {Node} el.\n */\nfunction FSWViewFile(el) {\n let wp_wrap = jQuery('#wpwrap')\n let dialog_window = jQuery('#spbc_dialog')\n\n dialog_window.dialog({\n modal:true,\n title: fswatcherTranslations['fs_modal'] + ' ' + el.dataset.path,\n position: { my: \"center top\", at: \"center top+100px\" , of: window },\n width: +(wp_wrap.width() / 100 * 90),\n show: { effect: \"blind\", duration: 500 },\n draggable: false,\n resizable: false,\n closeText: \"X\",\n classes: {\"ui-dialog\": 'spbc---top'},\n open: function(event, ui) {\n event.target.style.overflow = 'auto';\n jQuery('#spbc_dialog').height((document.documentElement.clientHeight) / 100 * 25);\n },\n beforeClose: function(event, ui) {\n document.body.style.overflow = 'auto';\n jQuery('#spbc_dialog').empty();\n },\n });\n\n dialog_window.append('\"Wait');\n\n let spinner = jQuery('#spbc_file_view_preloader');\n let size_multiplier = (wp_wrap.width() * 0.0004);\n\n spinner.height(128 * size_multiplier);\n spinner.width(128 * size_multiplier);\n spinner.css({left: dialog_window.width()/2 - (128 * size_multiplier / 2)});\n spinner.css({top: dialog_window.height()/2 - (128 * size_multiplier / 2)});\n\n const firstSelectorId = jQuery('#fswatcher__first_date').val()\n const secondSelectorId = jQuery('#fswatcher__second_date').val()\n\n let data = {\n action: 'spbct_fswatcher_view_file',\n fswatcher_file_path: el.dataset.path,\n fswatcher__first_date: firstSelectorId,\n fswatcher__second_date: secondSelectorId,\n };\n\n let callback = function(response) {\n let content = '';\n if (typeof response.error !== 'undefined') {\n content = response.error\n } else if (typeof response.data !== 'undefined') {\n content = response.data;\n } else {\n content = 'Unknown error on reading file. Data is empty.'\n }\n content = content.split('\\n');\n let dialog_window = jQuery('#spbc_dialog');\n dialog_window.empty();\n jQuery('#spbc_file_view_preloader').css({display:'none'})\n let row_template = '
%s

%s


';\n for (let row in content) {\n dialog_window.append(row_template.printf(+row + 1, content[row]));\n }\n\n let content_height = Object.keys(content).length * 19 < 76 ? 76 : Object.keys(content).length * 19,\n visible_height = (document.documentElement.clientHeight) / 100 * 75,\n overflow = content_height < visible_height ? 'hidden' : 'scroll',\n height = overflow === 'scroll' ? visible_height : content_height;\n\n dialog_window.css({\n height: height,\n overflow: overflow\n });\n };\n\n spbcSendAJAXRequest(data, {callback: callback});\n}\n\n/**\n * Try to decode JSON string from site response.\n * @param {string} response\n */\nfunction FSWDecodeJSON(response) {\n try {\n return JSON.parse(response)\n } catch (e) {\n return {'error': e};\n }\n}\n\n/**\n * Run rendering comparison table in dependence of response object\n * @param {{}} responseDataObj\n */\nfunction renderFSWatcherTableContent(responseDataObj) {\n fsWatcherTableBody.innerHTML = '';\n for (const dataSetName of availableFSWDataSetNames) {\n if (handleFSWDataObject(responseDataObj, dataSetName))\n {\n noFSWChangesDetected = false;\n }\n }\n}\n\nfunction validateFSWResponse(responseDataObj) {\n if (\n !responseDataObj ||\n typeof responseDataObj !== 'object'\n ) {\n return fswatcherTranslations['fs_err_resp_obj']\n }\n\n if (typeof responseDataObj.error !== 'undefined') {\n return responseDataObj.error\n }\n\n for (const dataSetName of availableFSWDataSetNames) {\n if (\n !responseDataObj.hasOwnProperty(dataSetName)\n ) {\n return fswatcherTranslations['fs_err_property']\n }\n }\n\n return true;\n}\n\n/**\n * @param {object} responseDataObj\n * @param {string|number} event_type\n */\nfunction handleFSWDataObject(responseDataObj, event_type) {\n const events_array = responseDataObj[event_type]\n if (events_array.length > 0) {\n for (let i = 0; i < events_array.length; i++) {\n const row = convertFSWEventToRow(events_array[i], event_type);\n renderFSWTableRow(row.path, row.event_type, row.date)\n }\n } else {\n return false;\n }\n return true;\n}\n\n/**\n * Convert a row of site response to the formatted data.\n * @param {object} event contains the date and the file path\n * @param {string} event_type contains event type\n */\nfunction convertFSWEventToRow(event, event_type) {\n let row = {\n 'path': 'unknown',\n 'event_type': event_type.toUpperCase(),\n 'date': 'unknown'\n }\n\n if (event.length === 2) {\n if (typeof event[0] === 'string') {\n row.path = event[0];\n if (row.event_type !== 'DELETED') {\n row.path += '
View';\n }\n }\n if (typeof event[1] === 'string') {\n let d = new Date(Number(event[1]) * 1000);\n shortMonthName = new Intl.DateTimeFormat(\"en-US\", { month: \"short\" }).format;\n let minutes = String(d.getMinutes()).padStart(2, '0');\n let seconds = String(d.getSeconds()).padStart(2, '0');\n row.date = shortMonthName(d) + ' ' + d.getDate() + ' ' + d.getFullYear() + ' ' + d.getHours() + ':' + minutes + ':' + seconds\n }\n }\n\n return row;\n}\n\n/**\n * Render the row of FSW table.\n * @param {string} path the file path\n * @param {string} event_type the event type\n * @param {string} date the date of event\n */\nfunction renderFSWTableRow(path, event_type, date) {\n\n if (event_type === 'no_changes') {\n let tr = document.createElement('tr');\n let td = document.createElement('td');\n td.setAttribute('name', 'fswatcher-event-no-changes');\n td.setAttribute('colspan', '3');\n td.innerText = fswatcherTranslations['fs_no_changes'];\n tr.appendChild(td);\n fsWatcherTableBody.appendChild(tr);\n return;\n }\n\n let tr = document.createElement('tr');\n\n let td_path = document.createElement('td');\n td_path.setAttribute('name', 'fswatcher-event-path');\n td_path.setAttribute('data-before', 'Path');\n td_path.innerHTML = path;\n tr.appendChild(td_path);\n\n let td_type = document.createElement('td');\n td_type.setAttribute('name', 'fswatcher-event-type');\n td_type.setAttribute('data-before', 'Event');\n td_type.innerText = event_type;\n tr.appendChild(td_type);\n\n let td_date = document.createElement('td');\n td_date.setAttribute('name', 'fswatcher-event-date');\n td_date.setAttribute('data-before', 'Changed on date');\n td_date.innerText = date;\n tr.appendChild(td_date);\n\n fsWatcherTableBody.appendChild(tr);\n}\n\n/**\n * Filter options for the first selector and disable it to keep it from changes.\n */\nfunction filterFSWSecondSelector() {\n toggleFSWSelectorsInfo(false);\n}\n\n/**\n * Filter options for the second selector and disable it to keep it from changes.\n */\nfunction filterFSWFirstSelector() {\n toggleFSWSelectorsInfo(false);\n}\n\n/**\n * Reset selectors to its initial statements.\n */\nfunction resetFSWSelectors() {\n for (let i = 0; i < firstFSWSelector.options.length; i++) {\n firstFSWSelector.options[i].style.display = 'inherit';\n }\n for (let i = 0; i < secondFSWSelector.options.length; i++) {\n secondFSWSelector.options[i].style.display = 'inherit';\n }\n secondFSWSelector.removeAttribute('disabled');\n firstFSWSelector.removeAttribute('disabled');\n}\n\n/**\n * Toggle info string.\n * @param {boolean} enable Set logs names if true, disable content if false.\n */\nfunction toggleFSWSelectorsInfo(enable) {\n let infoTag = document.getElementById('spbc--fs-watcher-table-handling-selects-info')\n if (\n enable\n && typeof firstFSWSelector.options[firstFSWSelector.selectedIndex] !== 'undefined'\n && typeof secondFSWSelector.options[secondFSWSelector.selectedIndex] !== 'undefined'\n )\n {\n const changesCountOnTRS = document.querySelectorAll('#spbc-table-fs_watcher-comparison > tr').length;\n const hasNoChangesTD = document.getElementsByName('fswatcher-event-no-changes').length;\n const changesCount = hasNoChangesTD > 0 ? 0 : changesCountOnTRS;\n\n infoTag.style.display = 'inherit';\n infoTag.innerHTML= fswatcherTranslations['fs_comparing'] +\n ' ' + firstFSWSelector.options[firstFSWSelector.selectedIndex].text + ' ' +\n fswatcherTranslations['fs_with'] +\n ' ' + secondFSWSelector.options[secondFSWSelector.selectedIndex].text + ' ' +\n fswatcherTranslations['fs_total'] +\n ' ' + changesCount + ''\n } else {\n infoTag.innerText = '';\n infoTag.style.display = 'none';\n }\n}\n\n\n\n\n"],"names":["let","noFSWChangesDetected","firstFSWSelector","document","getElementById","secondFSWSelector","fsWatcherTableBody","availableFSWDataSetNames","FSWOnload","querySelector","selectedIndex","secondDate","options","length","FSWCompare","Event","e","preventDefault","currentTarget","style","display","first_date","value","second_date","spbcSendAJAXRequest","action","fswatcher__first_date","fswatcher__second_date","callback","response","responseDataObj","FSWDecodeJSON","hasOwnProperty","alert","fswatcherTranslations","console","log","error","validate_result","validateFSWResponse","renderFSWatcherTableContent","renderFSWTableRow","resetFSWSelectors","toggleFSWSelectorsInfo","FSWCreate","params","button","target","timeout","FSWViewFile","el","wp_wrap","jQuery","dialog_window","spinner","dialog","modal","title","dataset","path","position","my","at","of","window","width","show","effect","duration","draggable","resizable","closeText","classes","ui-dialog","open","event","ui","overflow","height","documentElement","beforeClose","body","empty","append","size_multiplier","firstSelectorId","css","left","top","val","secondSelectorId","data","fswatcher_file_path","content","split","row","printf","content_height","Object","keys","visible_height","JSON","parse","innerHTML","dataSetName","handleFSWDataObject","event_type","events_array","i","convertFSWEventToRow","date","minutes","seconds","toUpperCase","d","Date","Number","shortMonthName","Intl","DateTimeFormat","month","format","String","getMinutes","padStart","getSeconds","getDate","getFullYear","getHours","tr","td_date","createElement","td","setAttribute","innerText","appendChild","td_path","td_type","filterFSWSecondSelector","filterFSWFirstSelector","removeAttribute","enable","infoTag","changesCountOnTRS","querySelectorAll","changesCount","getElementsByName","text","readyState","addEventListener"],"mappings":"AACAA,IAAIC,qBAAuB,CAAA,EAErBC,iBAAmBC,SAASC,eA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diff --git a/js/spbc-table.min.js b/js/spbc-table.min.js index 399a1f82e..80f86869d 100644 --- a/js/spbc-table.min.js +++ b/js/spbc-table.min.js @@ -1,2 +1,2 @@ -let spbcBulkAction=null;const noConfirmActions=spbcGetNoConfirmActions(spbcPublic);function spbcReloadAccordion(c=null,s=""){spbcSendAJAXRequest({action:"spbc_scanner_tab__reload_accordion"},{notJson:!0,callback:function(e,t,n,a){jQuery(a).accordion("destroy"),jQuery(a).html(e),jQuery(a).accordion({header:"h3",heightStyle:"content",collapsible:!0,active:!1}),spbcTblBulkActionsListen(),spbcTblRowActionsListen(),spbcTblPaginationListen(),spbcTblSortListen(),spbcStartShowHide(),null!==c&&null!==s&&interactScannerTab(c,s)}},jQuery("#spbc_scan_accordion"))}function interactScannerTab(e,t){var n,a;"string"==typeof e&&""!==e&&"string"==typeof t&&""!==t&&(n=jQuery('#spbc_scan_accordion div[refresh_control_tab="'+e+'"]')[0],e="h3[aria-controls=spbc_scan_accordion_tab_"+e+"]",e=jQuery(e)[0],void 0!==n)&&void 0!==e&&(jQuery('
').appendTo(e),a=jQuery(".spbc_accordion_header_caption__update_status"),jQuery('
'+t+"
").appendTo(a),e.click(),n.setAttribute("class","ui-accordion-header ui-corner-top ui-state-default ui-accordion-icons ui-accordion-header-active"),jQuery(".row-actions").hide())}function spbcTblBulkActionsListen(){jQuery(".tbl-bulk_actions-all--apply").off("click").on("click",function(){if(spbcScanner.active)alert(spbcTableLocalize.scannerIsActive);else{var e=jQuery(this);let n=e.siblings("select").children()[e.siblings("select").first()[0].selectedIndex].value;if(-1!==["approve","disapprove","send","check_analysis_status","approve_page","disapprove_page","cure","delete_from_analysis_log"].indexOf(n)){if(noConfirmActions.any.includes(n)||confirm(spbcTable.warning_bulk)){var t={action:"spbc_tbl-action--bulk",add_action:n,status:e.parents(".tbl-root").attr("type")};if("cure"===n){var a=e.closest("#spbc_tbl__scanner_cure_log").find(".cb-select");let n=[];a.each(function(e,t){t=jQuery(t).val();n.push(t)}),t.selectedIds=n}if("delete_from_analysis_log"===n){a=e.closest("#spbc_tbl__scanner_analysis_log").find(".cb-select");let n=[];a.each(function(e,t){t=jQuery(t).val();n.push(t)}),t.file_ids=n}a={button:this,spinner:e.children(".tbl-preloader--small"),callback:function(e){var t;spbcReloadAccordion(),"check_analysis_status"===n&&void 0!==e&&(t="

Analysis status updated. Total: "+e.counters.total+", updated: "+e.counters.updated+", skipped: "+e.counters.skipped+", failed: "+e.counters.failed+", queued: "+e.counters.queued+"

",spbcModal.open().put(t)),"send"===n&&void 0!==e&&(t="

Files have been sent: "+e.files_sent_counter+"

",spbcModal.open().put(t))},errorOutput:function(e,t){t&&(e=e+"
Additional information:
"+t),spbcModal.open().putError(e)},timeout:6e4};spbcSendAJAXRequest(t,a)}}else alert("This action is not supported for all files yet =(")}}),jQuery(".tbl-bulk_actions--apply").off("click").on("click",function(e){var n=spbcBulkAction||jQuery(this);let a=(spbcBulkAction=n).siblings("select").children()[n.siblings("select").first()[0].selectedIndex].value;if(spbcBulkAction||noConfirmActions.any.includes(a)||confirm(spbcTable.warning_bulk))if("cure"===a)spbcScannerCureSelected(jQuery(this));else if("delete_from_analysis_log"===a)spbcScannerAnalysisLogDeleteFromLog(jQuery(this));else if("allow"===a||"ban"===a){let t="ban"===a?"deny":a;var c=n.parents(".tbl-root").find(".cb-select:checked"),c=(c&&(n.children(".tbl-preloader--small").show(),c.each(function(){var e=jQuery(this).parents("tr").find(".tbl-row_action--"+a).data("ip");spbcSecLogsFilterIp(e,t,!0),jQuery(this).prop("checked",!1)})),n.children(".tbl-preloader--small").hide(),"allow"===a?"Allowed":"Banned"),c="

Success. Selected IPs have been "+c+". Changes will be applied within 10 minutes.

";spbcModal.open().put(c),void setTimeout(spbcReloadAccordion,1900)}else"-1"!==a&&n.parents(".tbl-root").find(".cb-select").is(":checked")?(n.children(".tbl-preloader--small").show(),n.parents(".tbl-root").find(".cb-select:checked").first().parents("tr").find(".tbl-row_action--"+a)[0]?(n.parents(".tbl-root").find(".cb-select:checked").first().parents("tr").find(".tbl-row_action--"+a).click(),n.parents(".tbl-root").find(".cb-select:checked").first().prop("checked",!1)):(n.parents(".tbl-root").find(".cb-select:checked").first().prop("checked",!1),n.click())):(n.children(".tbl-preloader--small").hide(),spbcBulkAction=null,"check_analysis_status"!==a&&"disapprove"!==a||spbcModal.open().put("

All available files are updated.

"),"send"===a&&spbcModal.open().put("

All available files are sent.

"),setTimeout(spbcReloadAccordion,1900)),noConfirmActions.restricted.includes(a)&&(spbcBulkAction=null)})}function spbcScannerCureSelected(t){var e=t.closest("#spbc_tbl__scanner_cure_log").find(".cb-select:checked");let n=[];0===e.length&&alert("Please, select elements."),e.each(function(e,t){t=jQuery(t).val();n.push(t)});e={action:"spbc_cure_selected",security:spbcSettings.ajax_nonce,selectedIds:n};jQuery.ajax({type:"POST",url:spbcSettings.ajaxurl,data:e,beforeSend:function(){t.closest("#spbc_tbl__scanner_cure_log").find(".tbl-button---white_blue .tbl-preloader--in_button").show()},success:function(e){t.closest("#spbc_tbl__scanner_cure_log").find(".tbl-button---white_blue .tbl-preloader--in_button").hide(),e.success?(spbcModal.open().put(e.data),document.addEventListener("spbcModalClosed",function(e){document.location.reload()})):spbcModal.open().putError(e.data)}})}function spbcTblRowActionsListen(){jQuery(".tbl-row_action--ajax").off("click").on("click",function(){if(spbcScanner.active)alert(spbcTableLocalize.scannerIsActive);else{let t=jQuery(this),n={action:"spbc_tbl-action--row",add_action:t.attr("row-action"),id:t.parents(".row-actions").attr("uid"),cols:t.parents(".row-actions").attr("cols_amount"),page_url:t.parent().attr("uid"),page_id:t.parent().attr("page_id")},a={callback:spbcTblRowActionsCallback,errorOutput:function(e,t,n){spbcModal.open().putError(e,n)},spinner:t.parent().siblings(".tbl-preloader--tiny")};"delete"===t.attr("row-action")&&(a.timeout=6e4);var e,c,s=t.parent().parent()[0].firstChild.innerHTML,i=spbcTable["warning_h_"+t.attr("row-action")]||spbcTable.warning_default,o=spbcTable["warning_t_"+t.attr("row-action")]||"";spbcBulkAction||noConfirmActions.any.includes(n.add_action)?spbcSendAJAXRequest(n,a,t.parents("tr")):(e="quarantine"===t.attr("row-action")?"Quarantine":"Yes",c="quarantine"===t.attr("row-action")?"Cancel":"No",spbcModal.open().confirm(i,o,s,e=>{e&&spbcSendAJAXRequest(n,a,t.parents("tr"))},e,c))}})}function spbcGetNoConfirmActions(e){var t={any:[],restricted:[],defaults:[]};let n=t;try{"function"==typeof(n=void 0!==e&&e.hasOwnProperty("no_confirm_row_actions")?JSON.parse(e.no_confirm_row_actions):n).any.includes&&"function"==typeof n.restricted.includes&&"function"==typeof n.defaults.includes||(n=t)}catch(e){n=t}return n}function spbcTblRowActionsCallback(t,n,e,a){if(t.color&&a.css({background:t.background,color:t.color}),t.html&&(a.parent().parent().parent().prepend(t.html),setTimeout(function(){a.fadeOut(300)},1500),spbcBulkAction||setTimeout(spbcReloadAccordion,1900)),"copy_file_info"===n.add_action&&(!0===t.success&&t.data.file_info?window.prompt("Copy the file info below and send it to support@cleantalk.org: ",t.data.file_info):(c=void 0!==t.data.error?t.data.error:"Unknown copy_file_info error",spbcModal.open().putError(c))),t.temp_html){let e=a.html();if(a.html(t.temp_html),void 0!==t.updated_template){var c=t.updated_template_type,t=t.updated_template,s=jQuery(t).find(".wp-list-table tbody tr").length,i=jQuery('[aria-controls="spbc_scan_accordion_tab_'+c+'"]');if(0n&&jQuery(t).css("outline","1px solid green")}),i.click()}else"analysis_log"===c&&(o='",c='