Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CDN Headers Checker #276

Merged
merged 93 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
8c4645f
Fix. SecFW. Schema updated.
Glomberg Nov 23, 2023
f92c27e
Fix. SecFW. Updating separated by v4 and v6.
Glomberg Nov 23, 2023
d8c371b
Merge remote-tracking branch 'origin/dev' into IP-schema-separated
Glomberg Nov 23, 2023
27bed7a
Fix. Code. Code style and psalm fixed.
Glomberg Nov 23, 2023
607a41d
Main logic done.
alexandergull Nov 29, 2023
fba8f47
Mod. Settings. Known headers taken from IP::$known_headers.
alexandergull Nov 29, 2023
e8512e2
New. RC implemented.
alexandergull Nov 29, 2023
7d9a579
Psalm/PHPunit/PHPCS fixes.
alexandergull Nov 29, 2023
40c5c84
Fix. Header get.
alexandergull Nov 29, 2023
e71298c
Fix. FireWall. Networks data selecting (SQL) fixed.
Glomberg Nov 30, 2023
6fc699f
Fix. FireWall. Stats tab - networks counts stored in the database fixed.
Glomberg Nov 30, 2023
274796d
Fix. Code. Code style fixed.
Glomberg Nov 30, 2023
73e86a5
Merge remote-tracking branch 'origin/dev' into IP-schema-separated
Glomberg Nov 30, 2023
41e592f
Fix. FireWall. Updater implemented for new DB structures.
Glomberg Dec 1, 2023
1f807f4
Version: 2.124.1-fix.
Glomberg Dec 5, 2023
dd8c6cc
Fix. PHP 8.2 deprecated notice fixed (creation of dynamic property ::…
alexandergull Dec 5, 2023
729fb65
Merge remote-tracking branch 'origin/dev' into IP-schema-separated
Glomberg Dec 7, 2023
0402590
Fix. FireWall. `privateRecordsAdd`, `privateRecordsDelete` implemente…
Glomberg Dec 7, 2023
28658ca
Fix. PHP 8.2 deprecated notice fixed (creation of dynamic property ::…
alexandergull Dec 5, 2023
6cdca07
Merge remote-tracking branch 'origin/fix' into fix
alexandergull Dec 9, 2023
d3b5e83
Code. Phpcs fix.
alexandergull Dec 9, 2023
c729e27
Merge branch 'dev' into cdn_self_check.ag
alexandergull Dec 12, 2023
84b115e
Mod. Ip::get(). Get automatic search if no IP provided in selected he…
alexandergull Dec 12, 2023
56ce5fd
Ref. Layout HTML logic rebuilt to template-like.
alexandergull Dec 12, 2023
ea9c1b9
Mod. Docs and refs.
alexandergull Dec 13, 2023
6d6ee69
New. Autotests.
alexandergull Dec 13, 2023
7d8a582
Mod. Now use request check neither response check.
alexandergull Dec 13, 2023
5dd381a
Merge branch 'dev' into cdn_self_check.ag
alexandergull Dec 13, 2023
76328f4
Fix. After dev merge.
alexandergull Dec 13, 2023
7c56c44
New logic to filter known CDN headers from other (like x-forwarded-for)
alexandergull Dec 14, 2023
ed0d499
Do not show changes if the new settings is the same as old.
alexandergull Dec 14, 2023
5faae32
Fix. Scan. Added check for signatures count.
svfcode Dec 14, 2023
68246f6
Settings changed. Do new CDN check call on settings save.
alexandergull Dec 14, 2023
1e38fd4
Psalm fixes.
alexandergull Dec 14, 2023
22e90a4
Revert "Upd.Gulp.Delete gulp-sass"
alexandergull Dec 14, 2023
8b45d1a
Revert "Upd.Lib.Adaptive table and drop-down line"
alexandergull Dec 14, 2023
dd76e56
Revert "Fix. Lib. Delete variable"
alexandergull Dec 14, 2023
1e35210
Upd.Gulp.Delete gulp-sass
AntonV1211 Dec 13, 2023
d2e7806
Merge branch 'fix' into dev
alexandergull Dec 14, 2023
23db725
Js reminify.
alexandergull Dec 14, 2023
6844e68
Fix. Lib. Change headers logic for adaptive
AntonV1211 Dec 14, 2023
ad7c6e0
Fix. Lib. Merge
AntonV1211 Dec 14, 2023
424052f
Partial revert LIst Table
alexandergull Dec 15, 2023
df48246
Fix. Lib. Localization global style
AntonV1211 Dec 15, 2023
53d573c
Fix. Lib. Merge dev
AntonV1211 Dec 15, 2023
def9d35
Version 2.125 and readme updated.
alexandergull Dec 15, 2023
ac20e10
Fix. Lib. Fixs merge dev, delete js func
AntonV1211 Dec 15, 2023
6bac4d5
Merge branch 'dev' of https://github.com/CleanTalk/security-malware-f…
AntonV1211 Dec 15, 2023
a65e1db
New. UploadChecker.php. Extracted from WAF logic.
alexandergull Dec 14, 2023
dfbf30b
Fix. Remove middle action to skip duplicated loggin called in Firewal…
alexandergull Dec 18, 2023
7f97257
Fix. PHP 8.2 Tokens. Magic calls prevented.
alexandergull Dec 18, 2023
78ec220
Version: 2.125.1-dev
alexandergull Dec 18, 2023
63ff708
Version: 2.125.1-fix
alexandergull Dec 18, 2023
a1a6342
Upd. Settings. Remove btn Delete from Approved
AntonV1211 Dec 18, 2023
0f2bae8
Merge branch 'dev' of https://github.com/CleanTalk/security-malware-f…
AntonV1211 Dec 18, 2023
eff4ef9
Merge branch 'adaptive_table-av' of https://github.com/CleanTalk/secu…
AntonV1211 Dec 20, 2023
12583fa
Ref. SecFW. Added last update log.
svfcode Dec 20, 2023
03f4f87
Merge branch 'dev' of https://github.com/CleanTalk/security-malware-f…
AntonV1211 Dec 20, 2023
643c982
Fix. Lib. Add-remove class
AntonV1211 Dec 20, 2023
5377d31
Reminfy.
alexandergull Dec 20, 2023
8514235
Fix. Merge dev
AntonV1211 Dec 20, 2023
127c06e
Restore all accordeons changes from the zip.
alexandergull Dec 20, 2023
4f47773
Fix. Scanner. SQL request for pages selector.
alexandergull Dec 20, 2023
564e860
Fix. Scanner. File sending. Fix DTO and results merging.
alexandergull Dec 20, 2023
0215190
Fix. Arr. mergeWithSavingNumericKeysRecursive() fixed.
alexandergull Dec 20, 2023
ae45090
Fix. DTO test fixed.
alexandergull Dec 20, 2023
2bb208f
Fix. Scanner. SQL request for pages selector.
alexandergull Dec 20, 2023
d4d347e
Fix. Scanner. File sending. Fix DTO and results merging.
alexandergull Dec 20, 2023
b580e3a
Fix. Arr. mergeWithSavingNumericKeysRecursive() fixed.
alexandergull Dec 20, 2023
1c72d06
Fix. DTO test fixed.
alexandergull Dec 20, 2023
10b0f0c
Fix. Accordions. Red dot status fixed.
alexandergull Dec 20, 2023
3eb2935
Fix. Accordions. Red dot status fixed.
alexandergull Dec 20, 2023
85b5524
Merge pull request #282 from CleanTalk/upload_checker.ag
alexandergull Dec 20, 2023
f298845
New. UploadChecker. Checking archive in media uploader.
svfcode Dec 25, 2023
02714e3
Merge branch 'dev' into IP-schema-separated
svfcode Dec 25, 2023
8b6d10f
Fix. Added separated tables to Deactivator.
svfcode Dec 25, 2023
8239e5b
Merge pull request #277 from CleanTalk/IP-schema-separated
svfcode Dec 25, 2023
a08f17f
Fix. Remove redundant code.
svfcode Dec 28, 2023
ec19dc6
Cron. Restored cron.
alexandergull Jan 11, 2024
bce4622
Merge pull request #285 from CleanTalk/check-uploaded-zip
alexandergull Jan 11, 2024
b3c96f1
New. Scanner. Send suspicious files to cloud.
svfcode Jan 11, 2024
4a3f825
Merge branch 'dev' into accordeons_logic_improvements.ag
alexandergull Jan 11, 2024
a1b7ebc
Merge pull request #289 from CleanTalk/accordeons_logic_improvements.ag
alexandergull Jan 11, 2024
97c71cf
Merge pull request #283 from CleanTalk/changes_btn_settings_av
alexandergull Jan 11, 2024
a3a2621
Merge branch 'dev' into adaptive_table-av
alexandergull Jan 11, 2024
6d9a991
Code. JS reminify.
alexandergull Jan 11, 2024
d2f2d9f
Merge pull request #281 from CleanTalk/adaptive_table-av
alexandergull Jan 11, 2024
cd51fca
Merge pull request #284 from CleanTalk/queue-logs
alexandergull Jan 11, 2024
56e2e97
Merge pull request #286 from CleanTalk/send-suspicious-to-cloud
alexandergull Jan 11, 2024
039b206
Merge branch 'fix' into dev
alexandergull Jan 11, 2024
5077a3e
Code. Version 2.125.1-dev.
alexandergull Jan 11, 2024
4838a22
Fix. Settings. Changed the period in the message
antonV3737 Jan 11, 2024
a40e905
Merge remote-tracking branch 'origin/cdn_self_check.ag' into cdn_self…
alexandergull Jan 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 32 additions & 15 deletions inc/spbc-settings.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use CleantalkSP\SpbctWP\HTTP\CDNHeadersChecker;
use CleantalkSP\SpbctWP\Scanner\ScanningLog\ScanningLogFacade;
use CleantalkSP\Variables\Post;
use CleantalkSP\Variables\Server;
Expand Down Expand Up @@ -536,6 +537,12 @@ function spbc_settings__register()
'options' => spbc_settings_field__secfw__get_ip__get_labels(),
'title' => __('Get visitors IP from additional headers', 'security-malware-firewall'),
'description' => spbc_settings_field__secfw__get_ip__get_description(),
'long_description' => true,
),
'secfw__get_ip__enable_cdn_auto_self_check' => array(
'type' => 'field',
'title' => __('Enable automatic CDN headers checker', 'security-malware-firewall'),
'description' => CDNHeadersChecker::getOptionDescriptionText(),
),
),
),
Expand Down Expand Up @@ -1649,6 +1656,16 @@ function spbc_field_statistics()
: __('Unknown last PHP log sending time.', 'security-malware-firewall'));
}

echo '<br/>';


//cdn checker data
add_filter('safe_style_css', function ($styles) {
$styles[] = 'display';
return $styles;
});
echo Escape::escKsesPreset(CDNHeadersChecker::getSummaryBlockHTML(), 'spbc_cdn_checker_table');

echo '<br/>';
echo 'Plugin version: ' . SPBC_VERSION;
echo '</div>';
Expand Down Expand Up @@ -4721,6 +4738,10 @@ function spbc_settings__get_description()
'desc' => __('The file hash is in denied list. It means that the Security analysts have marked this file
as critically dangerous early. We do recommend you to order the Security Audit service.', 'security-malware-firewall')
),
'secfw__get_ip' => array(
'title' => IP::getOptionLongDescriptionArray()['title'],
'desc' => IP::getOptionLongDescriptionArray()['desc'],
),
'no_description' => array(
'title' => esc_html($setting_id),
'desc' => __('No description provided yet for this item. We are sorry about this. Please, contact [email protected] for further help.', 'security-malware-firewall'),
Expand Down Expand Up @@ -4995,6 +5016,16 @@ function spbc__send_local_settings_to_api($settings)
API::methodSendLocalSettings($api_key, $hostname, $settings);
}

add_action('spbc_before_returning_settings', 'spbc_cdn_checker__run_check_on_settings_change');

function spbc_cdn_checker__run_check_on_settings_change($settings)
{
if ( isset($settings['secfw__get_ip__enable_cdn_auto_self_check']) && $settings['secfw__get_ip__enable_cdn_auto_self_check'] != 0) {
CDNHeadersChecker::sendCDNCheckerRequest();
}
}


/**
*
*/
Expand Down Expand Up @@ -5037,24 +5068,10 @@ function spbc_settings_field__secfw__get_ip__get_description()

function spbc_settings_field__secfw__get_ip__get_labels()
{
$available_header = array(
2 => array('slug' => 'remote_addr', 'name' => 'Remote Addr'),
3 => array('slug' => 'x_forwarded_for', 'name' => 'X-Forwarder-For'),
4 => array('slug' => 'x_real_ip', 'name' => 'X-Real-Ip'),
5 => array('slug' => 'incapsula', 'name' => 'Incap-Client-Ip'),
6 => array('slug' => 'ico_x_forwarded_for', 'name' => 'Ico-X-Forwarded-For'),
7 => array('slug' => 'stackpath', 'name' => 'X-Sp-Forwarded-Ip'),
8 => array('slug' => 'x_forwarded_by', 'name' => 'X-Client-Ip'),
9 => array('slug' => 'sucury', 'name' => 'X-Sucuri-Clientip'),
10 => array('slug' => 'ezoic', 'name' => 'X-Middleton-Ip'),
11 => array('slug' => 'gtranslate', 'name' => 'X-Gt-Viewer-Ip'),
12 => array('slug' => 'cloud_flare', 'name' => 'Cf-Connecting-Ip'),
13 => array('slug' => 'ovh', 'name' => 'Remote-Ip'),
);
$options = array();
$options[] = array('val' => 1, 'label' => __('Auto', 'security-malware-firewall'),);

foreach ( $available_header as $key => $header ) {
foreach (IP::$known_headers_collection as $key => $header ) {
IP::get($header['slug'], [], true);
$option_value = $header['name'];
$option_value .= isset(IP::getInstance()->ips_stored[$header['slug']])
Expand Down
2 changes: 1 addition & 1 deletion js/spbc-admin.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 16 additions & 3 deletions js/src/spbc-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ function spbcDisableG2fa( element ) {
}

jQuery(document).ready(function(){
// Auto update banner close handler

// Auto update banner close handler
jQuery('.spbc_update_notice').on('click', 'button', function(){
spbc_setCookie('spbc_update_banner_closed', 1, 86400 * 30);
});
Expand Down Expand Up @@ -137,4 +137,17 @@ jQuery(document).ready(function(){
if (+spbcSettings.needToWhitelist === 1) {
spbc_sendAJAXRequest( { 'action' : 'spbc_private_list_add' }, { 'callback' : null } );
}
});
});

function spbcSummaryShowCDNCheckerTable()
{
event.preventDefault()
let table = document.getElementById('spbc_stats_cdn_checker_table')
if (typeof (table) !== 'undefined') {
if (table.style.display === 'block') {
table.style.display = 'none'
} else {
table.style.display = 'block'
}
}
}
2 changes: 1 addition & 1 deletion js/src/spbc-settings_tab--summary.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
jQuery(document).ready(function(){
console.log('TAB - SUMMARY');
});
});
2 changes: 0 additions & 2 deletions lib/CleantalkSP/Common/HTTP/Request.php
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, clone these changes into the HTTP library

Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ protected function processPresets()
$this->options[CURLOPT_FOLLOWLOCATION] = false;
$this->options[CURLOPT_MAXREDIRS] = 0;
break;
// Get headers only
case 'get_code':
$this->options[CURLOPT_HEADER] = true;
$this->options[CURLOPT_NOBODY] = true;
Expand All @@ -459,7 +458,6 @@ static function (Response $response) {
true
);
break;
// Get headers only
case 'split_to_array':
$this->addCallback(
static function ($response_content) {
Expand Down
3 changes: 3 additions & 0 deletions lib/CleantalkSP/SpbctWP/Activator.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace CleantalkSP\SpbctWP;

use CleantalkSP\SpbctWP\Cron as SpbcCron;
use CleantalkSP\SpbctWP\HTTP\CDNHeadersChecker;

class Activator
{
Expand All @@ -17,6 +18,8 @@ public static function activation($network, $redirect = true)
{
global $wpdb, $spbc;

CDNHeadersChecker::sendCDNCheckerRequest();

if ( current_action() !== 'wp_insert_site' ) {
delete_option('spbc_deactivation_in_process');
}
Expand Down
28 changes: 28 additions & 0 deletions lib/CleantalkSP/SpbctWP/Escape.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,34 @@ public static function escKsesPreset($string, $preset = null, $_allowed_protocol
'href' => true,
),
),
'spbc_cdn_checker_table' => array(
'a' => array(
'style' => true,
'href' => true,
'onclick' => true,
),
'p' => array(),
'b' => array(),
'table' => array(
'id' => true,
'style' => true,
),
'tr' => array(
'class' => true,
'style' => true,
),
'th' => array(
'style' => true,
'class' => true,
),
'td' => array(
'colspan' => true,
'style' => true,
'class' => true,
),
'tbody' => true,
'div' => array()
),
'spbc_settings__notice_autosend' => array(
'div' => array(
'class' => true,
Expand Down
Loading
Loading