Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion css/spbc-settings.min.css

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions css/src/spbc-settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@ div.pagination{
left: -50px;
}

.spbc_settings_description_status_php_execution {
margin-top: 5px;
margin-left: 18px;
font-size: 10pt;
color: red;
font-weight: 600;
list-style-type: disc;
}
.spbc_tab-settings_general input[type=text] {
min-width: 255px; width: 100%;
}
Expand Down
17 changes: 17 additions & 0 deletions inc/spbc-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use CleantalkSP\SpbctWP\VulnerabilityAlarm\VulnerabilityAlarmView;
use CleantalkSP\Variables\Post;
use CleantalkSP\Variables\Server;
use CleantalkSP\SpbctWP\UploadDirPreventPhpExecutionModule\UploadDirPreventPhpExecution;

// Prevent direct call
if ( ! defined('ABSPATH') ) {
Expand Down Expand Up @@ -983,6 +984,14 @@ function spbc_settings__register()
'description' => __('Add these headers to the HTTP responses on the public pages: X-Content-Type-Options, X-XSS-Protection to get protection from XSS and drive-by download attacks.', 'security-malware-firewall'),
'long_description' => true,
),
'wp__upload_dir_prevent_php_execution' => array(
'display' => is_main_site(),
'type' => 'field',
'title' => __('Disable PHP execution in uploads folder', 'security-malware-firewall'),
'description' => \CleantalkSP\SpbctWP\UploadDirPreventPhpExecutionModule\UploadDirPreventPhpExecution::getDescription(
isset($spbc->data['upload_dir_prevent_php_execution_status']) ? $spbc->data['upload_dir_prevent_php_execution_status'] : null
),
),
'wp__use_builtin_http_api' => array(
'display' => is_main_site(),
'type' => 'field',
Expand Down Expand Up @@ -4860,6 +4869,14 @@ function spbc_sanitize_settings($settings)
}
FileEditorDisabler::syncDisallowFileEditBySettings($settings);

// Try to add|remove content to .htaccess file
if ($settings['wp__upload_dir_prevent_php_execution'] !== $spbc->settings['wp__upload_dir_prevent_php_execution']) {
$spbc->settings['wp__upload_dir_prevent_php_execution'] = $settings['wp__upload_dir_prevent_php_execution'];
$spbc->save('data');

UploadDirPreventPhpExecution::handle();
}

return $settings;
}

Expand Down
1 change: 1 addition & 0 deletions lib/CleantalkSP/SpbctWP/Activator.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public static function activation($network, $redirect = true)
SpbcCron::updateTask('check_vulnerabilities', 'spbc_security_check_vulnerabilities', 86400, time() + 100);
SpbcCron::addTask('send_php_logs', 'spbc_PHP_logs__send', 3600, time() + 300);
SpbcCron::updateTask('users_pass_check', 'spbc_users_pass_check', 86400 * 10, time() + 1800);
SpbcCron::updateTask('upload_dir_prevent_php_execution', 'spbc_upload_dir_prevent_php_execution', 86400, time() + 1800);

if ( empty($spbc->errors['configuration']) ) {
$scanner_launch_data = spbc_get_custom_scanner_launch_data(true);
Expand Down
16 changes: 14 additions & 2 deletions lib/CleantalkSP/SpbctWP/Deactivator.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace CleantalkSP\SpbctWP;

use CleantalkSP\SpbctWP\Variables\Cookie;
use CleantalkSP\SpbctWP\UploadDirPreventPhpExecutionModule\UploadDirPreventPhpExecution;

class Deactivator
{
Expand All @@ -29,6 +30,7 @@ class Deactivator
'unregister_plugin_settings_page',
'remove_admin_bar',
'reset_admin_cookies',
'delete_upload_dir_prevent_php_execution',
),
'on_complete' => array(
'mu_uninstall',
Expand All @@ -46,7 +48,9 @@ class Deactivator
'delete_fw_dir',
'delete_frontend_meta',
//
'delete_fs_watcher_journals'
'delete_fs_watcher_journals',
//
'delete_upload_dir_prevent_php_execution',
)
),
'network_wide' => array(
Expand All @@ -73,6 +77,7 @@ class Deactivator
'on_simple' => array(
'reset_admin_cookies',
'remove_admin_bar',
'delete_upload_dir_prevent_php_execution',
),
'on_complete' => array(
'reset_admin_cookies',
Expand All @@ -81,7 +86,8 @@ class Deactivator
'delete_blog_meta',
'delete_fw_dir',
'delete_frontend_meta',
'delete_fs_watcher_journals'
'delete_fs_watcher_journals',
'delete_upload_dir_prevent_php_execution',
)
),
);
Expand All @@ -101,6 +107,7 @@ private static function runActions($call_instance_config)
global $wpdb;
$deactivation_type = self::$is_complete_deactivation ? $call_instance_config['on_complete'] : $call_instance_config['on_simple'];
foreach ($deactivation_type as $action) {
error_log('action: ' . $action);
switch ($action) {
case 'mu_uninstall':
self::muPluginUninstall();
Expand Down Expand Up @@ -166,6 +173,11 @@ private static function runActions($call_instance_config)
if (is_dir($journals_path) && is_writable($journals_path)) {
\CleantalkSP\SpbctWP\Helpers\Data::removeDirectoryRecursively($journals_path);
}
break;
case 'delete_upload_dir_prevent_php_execution':
error_log('delete_upload_dir_prevent_php_execution deactivation');
UploadDirPreventPhpExecution::deactivate();
break;
}
self::logThis($action . ' ok');
}
Expand Down
1 change: 1 addition & 0 deletions lib/CleantalkSP/SpbctWP/Scanner/ScannerQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,7 @@ public function file_system_analysis($offset = null, $amount = null, $path_to_sc
$spbc->data['scanner']['files_total'] = $scanner->output_files_count;
$spbc->save('data');
$output['total'] = $scanner->output_files_count;
Cron::updateTask('upload_dir_prevent_php_execution', 'spbc_upload_dir_prevent_php_execution', 86400, time() + 100);
}

$scanning_stages_storage->saveToDb();
Expand Down
1 change: 1 addition & 0 deletions lib/CleantalkSP/SpbctWP/State.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class State extends \CleantalkSP\Common\State
'monitoring__users' => 1,

// WP
'wp__upload_dir_prevent_php_execution' => 1,
'wp__use_builtin_http_api' => 1,
'wp__disable_xmlrpc' => 0,
'wp__disable_rest_api_for_non_authenticated' => 0,
Expand Down
Loading