Changeset 3428251
- Timestamp:
- 12/27/2025 01:30:40 PM (3 months ago)
- Location:
- wp-guardian/trunk
- Files:
-
- 4 edited
-
assets/templates/guardian-security-measures.php (modified) (3 diffs)
-
modules/obfuscated-script-cleaner.php (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
-
wp-guardian.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-guardian/trunk/assets/templates/guardian-security-measures.php
r3404328 r3428251 9 9 echo '<div class="error notice is-dismissible"><p>' . esc_html__( 'Security check failed. Settings not saved.', 'wp-guardian' ) . '</p></div>'; 10 10 } else { 11 11 12 $measures = [ 12 13 'restrict_file_access', … … 31 32 } 32 33 34 // Handle Obfuscated Script Cleaner aggressive filter toggle 35 $osc_aggressive = isset( $_POST['dtjwpg_osc_aggressive_filter'] ) ? 1 : 0; 36 update_option( 'dtjwpg_osc_aggressive_filter', $osc_aggressive ); 37 33 38 // Apply PHP execution hardening for wp-content and wp-includes 34 39 if ( isset( $_POST['dtjwpg_security_measure_prevent_php_execution'] ) && (int) $_POST['dtjwpg_security_measure_prevent_php_execution'] === 1 ) { … … 54 59 <tr> 55 60 <th scope="row"> 61 <label for="dtjwpg_osc_aggressive_filter"><?php esc_html_e( 'Obfuscated Script Cleaner: Aggressive Filtering', 'wp-guardian' ); ?></label> 62 </th> 63 <td> 64 <input type="checkbox" value="1" id="dtjwpg_osc_aggressive_filter" name="dtjwpg_osc_aggressive_filter" <?php checked( 1, (int) get_option( 'dtjwpg_osc_aggressive_filter', 0 ) ); ?>> 65 <p class="description"> 66 <?php esc_html_e( 'If enabled, all HTML will be stripped from post/page content when malicious patterns are detected. If disabled (recommended), only the detected malicious scripts will be removed and normal HTML will be preserved.', 'wp-guardian' ); ?> 67 </p> 68 </td> 69 </tr> 70 </tbody> 71 <tbody> 72 <tr> 73 <th scope="row"> 56 74 <label><?php esc_html_e( 'Restrict access to files and directories', 'wp-guardian' ); ?></label> 57 75 </th> -
wp-guardian/trunk/modules/obfuscated-script-cleaner.php
r3423816 r3428251 84 84 ]; 85 85 86 // Build the SQL with the correct number of placeholders, and pass post types as variadic args (splat operator) 86 87 $placeholders = implode( ',', array_fill( 0, count( $post_types ), '%s' ) ); 88 $sql = "SELECT ID, post_type, post_content, post_excerpt FROM {$wpdb->posts} WHERE post_type IN ($placeholders)"; 89 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared 90 $posts = $wpdb->get_results( $wpdb->prepare( $sql, ...$post_types ) ); 87 91 88 $sql = $wpdb->prepare(89 "90 SELECT ID, post_type, post_content, post_excerpt91 FROM {$wpdb->posts}92 WHERE post_type IN ($placeholders)93 ",94 $post_types95 );96 97 $posts = $wpdb->get_results( $sql );98 92 $cleaned = 0; 99 93 … … 135 129 136 130 echo '<div class="notice notice-success"><p>'; 131 // translators: %d: Number of cleaned items. 137 132 echo esc_html( sprintf( __( 'Cleaning complete. %d items cleaned.', 'wp-guardian' ), $cleaned ) ); 138 133 echo '</p></div>'; … … 142 137 * Filter to block malicious content on save 143 138 */ 139 140 // Add a setting to toggle aggressive filtering (off by default) 141 if ( false === get_option( 'dtjwpg_osc_aggressive_filter', false ) ) { 142 add_option( 'dtjwpg_osc_aggressive_filter', 0 ); 143 } 144 144 145 add_filter( 145 146 'content_save_pre', 146 147 function ( $content ) { 148 $aggressive = (int) get_option( 'dtjwpg_osc_aggressive_filter', 0 ); 147 149 if ( preg_match( '/_0x[a-f0-9]{3,}|urshort\.live|atob|eval/i', $content ) ) { 148 150 error_log( 'Blocked malicious content save' ); 149 return wp_strip_all_tags( $content ); 151 if ( $aggressive ) { 152 // Strip all HTML (aggressive) 153 return wp_strip_all_tags( $content ); 154 } else { 155 // Only remove the detected malicious scripts, keep other HTML 156 $patterns = [ 157 '#<script[^>]*>.*?(_0x[a-f0-9]{3,}|urshort\.live|atob|eval).*?</script>#is', 158 ]; 159 foreach ( $patterns as $pattern ) { 160 $content = preg_replace( $pattern, '', $content ); 161 } 162 return $content; 163 } 150 164 } 151 165 return $content; -
wp-guardian/trunk/readme.txt
r3423816 r3428251 7 7 Requires PHP: 7.0 8 8 Requires CP: 2.0 9 Stable tag: 1. 7.39 Stable tag: 1.8.0 10 10 License: GPLv3 or later 11 11 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 43 43 44 44 == Changelog == 45 46 = 1.8.0 = 47 * Add UI toggle for Obfuscated Script Cleaner aggressive filtering (off by default) 48 * Obfuscated Script Cleaner is now less aggressive: only removes detected malicious scripts, not all HTML 49 * Fix: HTML is no longer stripped from post/page content unless aggressive mode is enabled 45 50 46 51 = 1.7.3 = -
wp-guardian/trunk/wp-guardian.php
r3423816 r3428251 4 4 * Plugin URI: https://getbutterfly.com/wordpress-plugins/wp-guardian/ 5 5 * Description: An easy way to harden your website's security effectively. 6 * Version: 1. 7.36 * Version: 1.8.0 7 7 * Author: Ciprian Popescu 8 8 * Author URI: https://getbutterfly.com/ … … 33 33 } 34 34 35 define( 'DTJWPG_VERSION', '1. 7.3' );35 define( 'DTJWPG_VERSION', '1.8.0' ); 36 36 define( 'DTJWPG_URL', __FILE__ ); 37 37 define( 'DTJWPG_BASENAME', plugin_basename( DTJWPG_URL ) );
Note: See TracChangeset
for help on using the changeset viewer.