Skip to content

Commit

Permalink
Readme updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandergull committed Mar 25, 2024
2 parents e4dab30 + 93a08ce commit 0348dfa
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 20 deletions.
6 changes: 5 additions & 1 deletion lib/CleantalkSP/Common/FSWatcher/Analyzer/Analyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ protected static function compare($first_journal, $second_journal)
* @param $file
* @return false|string
*/
private static function uncompress($file)
protected static function uncompress($file, $do_return_uncompressed_content = false)
{
if ( substr($file, -3) === '.gz' ) {
$content = @gzopen($file, 'r');
Expand All @@ -124,6 +124,10 @@ private static function uncompress($file)
@gzclose($content);
return false;
}
if ($do_return_uncompressed_content) {
gzclose($content);
return $gz_result;
}
$write_result = @file_put_contents(substr($file, 0, -3), $gz_result);
gzclose($content);
if ( false === $write_result ) {
Expand Down
33 changes: 29 additions & 4 deletions lib/CleantalkSP/Common/FSWatcher/assets/fswatcher-logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,15 @@ function FSWCompare(e) {
document.querySelector('#fsw_preloader_compare').style.display = 'inline';
}

if ( typeof document.getElementById('fswatcher__first_date') === 'undefined'
|| typeof document.getElementById('fswatcher__second_date') === 'undefined' ) {
return false;
}

let first_date = document.getElementById('fswatcher__first_date').value;
let second_date = document.getElementById('fswatcher__second_date').value;

if (typeof fswatcherToken !== 'undefined') {
if (typeof fswatcherToken !== 'undefined' && first_date && second_date) {
let data = [
'fswatcher_token=' + fswatcherToken,
'fswatcher_compare=1',
Expand Down Expand Up @@ -259,13 +264,24 @@ function FSWViewFile(el) {
spinner.css({top: dialog_window.height()/2 - (128 * size_multiplier / 2)});

if (typeof fswatcherToken !== 'undefined') {
const firstSelectorId = jQuery('#fswatcher__first_date').val()
const secondSelectorId = jQuery('#fswatcher__second_date').val()
const journalsIDs = [firstSelectorId,secondSelectorId];
let data = [
'fswatcher_token=' + fswatcherToken,
'fswatcher_view_file=1',
'fswatcher_file_path=' + el.dataset.path,
'fswatcher_journals=' + JSON.stringify(journalsIDs),
];
let callback = function(response) {
let content = response.data;
let content = '';
if (typeof response.error !== 'undefined') {
content = response.error
} else if (typeof response.data !== 'undefined') {
content = response.data;
} else {
content = 'Unknown error on reading file. Data is empty.'
}
content = content.split('\n');
let dialog_window = jQuery('#spbc_dialog');
dialog_window.empty();
Expand Down Expand Up @@ -365,14 +381,23 @@ function resetFSWSelectors() {
*/
function toggleFSWSelectorsInfo(enable) {
let infoTag = document.getElementById('spbc--fs-watcher-table-handling-selects-info')
if (enable) {
if (
enable
&& typeof firstFSWSelector.options[firstFSWSelector.selectedIndex] !== 'undefined'
&& typeof secondFSWSelector.options[secondFSWSelector.selectedIndex] !== 'undefined'
)
{
const changesCountOnTRS = document.querySelectorAll('#spbc-table-fs_watcher-comparison > tr').length;
const hasNoChangesTD = document.getElementsByName('fswatcher-event-no-changes').length;
const changesCount = hasNoChangesTD > 0 ? 0 : changesCountOnTRS;

infoTag.style.display = 'inherit';
infoTag.innerHTML= fswatcherTranslations['fs_comparing'] +
' <b>' + firstFSWSelector.options[firstFSWSelector.selectedIndex].text + '</b> ' +
fswatcherTranslations['fs_with'] +
' <b>' + secondFSWSelector.options[secondFSWSelector.selectedIndex].text + '</b> ' +
fswatcherTranslations['fs_total'] +
' <b>' + document.querySelectorAll('#spbc-table-fs_watcher-comparison > tr').length + '</b>'
' <b>' + changesCount + '</b>'
} else {
infoTag.innerText = '';
infoTag.style.display = 'none';
Expand Down
44 changes: 41 additions & 3 deletions lib/CleantalkSP/SpbctWP/FSWatcher/Analyzer/SpbctWpFSWAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

namespace CleantalkSP\SpbctWP\FSWatcher\Analyzer;

use CleantalkSP\Common\FSWatcher\Analyzer\Analyzer;
use CleantalkSP\SpbctWP\FSWatcher\SpbctWpFSWController;
use CleantalkSP\Common\FSWatcher\Logger;
use CleantalkSP\SpbctWP\FSWatcher\Storage\SpbctWpFSWFileStorage;

class SpbctWpFSWAnalyzer extends \CleantalkSP\Common\FSWatcher\Analyzer\Analyzer
{
Expand Down Expand Up @@ -43,11 +45,47 @@ public static function getCompareResult()
*/
public static function getViewFile()
{
$path = $_POST['fswatcher_file_path'];
if (!is_file($path)) {
return false;
$path = isset($_POST['fswatcher_file_path']) ? $_POST['fswatcher_file_path'] : false;
$journals = isset($_POST['fswatcher_journals']) ? json_decode($_POST['fswatcher_journals']) : false;

if (!$path || !is_file($path)) {
throw new \Exception('File path is incorrect.');
}

if (!$journals || !is_array($journals)) {
throw new \Exception('Provided journals paths are incorrect.');
}

$path_found_in_journal = false;

foreach ($journals as $journal_id) {
if (self::isFileOfFSWJournal($path, $journal_id)) {
$path_found_in_journal = true;
break;
}
}

if (!$path_found_in_journal) {
throw new \Exception('The file is out of FSWatcher journals.');
}

return file_get_contents($path);
}

/**
* @param $path
* @param $journal_id
* @return bool
*/
private static function isFileOfFSWJournal($path, $journal_id)
{
$storage = new SpbctWpFSWFileStorage();
$journal_parsed = $storage->getJournal($journal_id);
$analyzer = new Analyzer();
$journal_parsed = $analyzer->uncompress($journal_parsed, true);
if (strpos($journal_parsed, $path) !== false) {
return true;
}
return false;
}
}
11 changes: 6 additions & 5 deletions lib/CleantalkSP/SpbctWP/FSWatcher/SpbctWpFSWController.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,13 @@ public static function work($params)
if (self::$debug) {
Logger::log('run view file method');
}
$view_file = SpbctWpFSWAnalyzer::getViewFile();
if (false === $view_file) {

try {
$view_file = SpbctWpFSWAnalyzer::getViewFile();
echo json_encode(array("data" => $view_file));
} catch (\Exception $e) {
Logger::log('Can not view file');
echo json_encode(array('error' => 'Can not view file'));
} else {
echo json_encode(["data" => $view_file]);
echo json_encode(array('error' => 'Can not view file. ' . $e->getMessage()));
}
die();
}
Expand Down
6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: security, firewall, malware, wordpress security, brute force
Requires at least: 3.0
Tested up to: 6.4
Requires PHP: 5.6
Stable tag: 2.130
Stable tag: 2.130.1
License: GPLv2
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -333,6 +333,10 @@ This is required for the Security FireWall to function properly. Plugins that ar

== Changelog ==

= 2.130.1 Mar 25 2024 =
* Fix. FSWatcher. Security improvements.
* Fix. Scanner. Signatures list updating fixed.

= 2.130 Mar 12 2024 =
* Mod. UploadChecker. Now user can proceed the module installation even if got warning from the UploadChecker.
* Mod. Outbound links accordion. Layout refactored.
Expand Down
12 changes: 6 additions & 6 deletions security-malware-firewall.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Plugin URI: https://wordpress.org/plugins/security-malware-firewall/
Description: Security & Malware scan by CleanTalk to protect your website from online threats and viruses. IP/Country FireWall, Web application FireWall. Detailed stats and logs to have full control.
Author: CleanTalk Security
Version: 2.130
Version: 2.130.1
Author URI: https://cleantalk.org
Text Domain: security-malware-firewall
Domain Path: /i18n
Expand Down Expand Up @@ -756,6 +756,11 @@ function spbc_scanner__signatures_update()
{
global $spbc;

/**
* @psalm-suppress InvalidScalarArgument
*/
$spbc->error_delete('scanner_update_signatures_bad_signatures', 'save');

$latest_signature_submitted_time = SignatureAnalysisFacade::getLatestSignatureSubmittedTime();

$signatures_from_cloud = SignatureAnalysisFacade::getSignaturesFromCloud($latest_signature_submitted_time);
Expand Down Expand Up @@ -783,11 +788,6 @@ function spbc_scanner__signatures_update()

if (isset($signatures_added['bad_signatures'])) {
$spbc->error_add('scanner_update_signatures_bad_signatures', $signatures_added['bad_signatures']);
} else {
/**
* @psalm-suppress InvalidScalarArgument
*/
$spbc->error_delete('scanner_update_signatures_bad_signatures', 'save');
}
}

Expand Down

0 comments on commit 0348dfa

Please sign in to comment.