Changeset 3466579
- Timestamp:
- 02/21/2026 08:22:40 PM (5 weeks ago)
- Location:
- security-hardener
- Files:
-
- 4 added
- 3 edited
-
tags/0.6 (added)
-
tags/0.6/readme.txt (added)
-
tags/0.6/security-hardener.php (added)
-
tags/0.6/uninstall.php (added)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/security-hardener.php (modified) (6 diffs)
-
trunk/uninstall.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
security-hardener/trunk/readme.txt
r3457528 r3466579 5 5 Tested up to: 6.9 6 6 Requires PHP: 8.0 7 Stable tag: 0. 57 Stable tag: 0.6 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 161 161 == Changelog == 162 162 163 = 0.5 - 2026-02-09 = 163 = 0.6 - 2026-21-02 = 164 * Fixed: Removed deprecated load_plugin_textdomain() call (automatic since WordPress 4.6) 165 * Fixed: Added wp_unslash() and sanitize_text_field() to $_GET['author'] before sanitization 166 * Fixed: Moved HTML markup outside translatable string in login confirmation message 167 * Fixed: Escaped $min and $max output in render_number_field() using absint() 168 * Fixed: Added phpcs:ignore for native WordPress constants DISALLOW_FILE_EDIT and DISALLOW_FILE_MODS 169 * Fixed: Removed error_log() debug call from uninstall.php 170 * Fixed: Suppressed false-positive direct database query warning in uninstall.php with inline justification comment 171 * Fixed: Removed redundant function_exists() check for wp_cache_flush() in uninstall.php 172 173 = 0.5 - 2026-09-02 = 164 174 * Complete rewrite following WordPress hardening best practices 165 175 * Increased minimum PHP requirement to 8.0 (PHP 7.4 is end-of-life) -
security-hardener/trunk/security-hardener.php
r3457528 r3466579 4 4 Plugin URI: https://wordpress.org/plugins/security-hardener/ 5 5 Description: Basic hardening: secure headers, disable XML-RPC/pingbacks, hide version, block user enumeration, login errors, IP-based rate limiting, and optional restriction of the REST API. 6 Version: 0. 56 Version: 0.6 7 7 Requires at least: 6.0 8 Tested up to: 6. 88 Tested up to: 6.9 9 9 Requires PHP: 8.0 10 10 Author: Marc Armengou … … 83 83 */ 84 84 public function init() { 85 // Load text domain86 load_plugin_textdomain( 'security-hardener', false, dirname( WPSH_BASENAME ) . '/languages' );87 88 85 // Define security constants early 89 86 $this->define_security_constants(); … … 252 249 // Disable file editing in WordPress admin 253 250 if ( $this->get_option( 'disable_file_edit', true ) && ! defined( 'DISALLOW_FILE_EDIT' ) ) { 254 define( 'DISALLOW_FILE_EDIT', true ); 251 define( 'DISALLOW_FILE_EDIT', true ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- Native WordPress constant 255 252 } 256 253 257 254 // Disable all file modifications (updates, installs) - CAUTION: This breaks updates! 258 255 if ( $this->get_option( 'disable_file_mods', false ) && ! defined( 'DISALLOW_FILE_MODS' ) ) { 259 define( 'DISALLOW_FILE_MODS', true ); 256 define( 'DISALLOW_FILE_MODS', true ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- Native WordPress constant 260 257 } 261 258 } … … 334 331 // Check for author query parameter with numeric value 335 332 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only check 336 $author = isset( $_GET['author'] ) ? $_GET['author']: null;333 $author = isset( $_GET['author'] ) ? sanitize_text_field( wp_unslash( $_GET['author'] ) ) : null; 337 334 338 335 // Block numeric author parameter … … 429 426 function ( $message ) { 430 427 if ( strpos( $message, 'check your email' ) !== false ) { 431 return __( '<strong>Check your email for the confirmation link.</strong>', 'security-hardener' );428 return '<strong>' . esc_html__( 'Check your email for the confirmation link.', 'security-hardener' ) . '</strong>'; 432 429 } 433 430 return $message; … … 865 862 esc_attr( $field_id ), 866 863 esc_attr( $value ), 867 $min,868 $max864 absint( $min ), 865 absint( $max ) 869 866 ); 870 867 } -
security-hardener/trunk/uninstall.php
r3457528 r3466579 23 23 global $wpdb; 24 24 25 // Delete login attempts transients using efficient SQL query 26 $wpdb->query( 27 "DELETE FROM {$wpdb->options} 28 WHERE option_name LIKE '_transient_wpsh_login_attempts_%' 25 // Delete login attempts transients using a direct SQL query. 26 // There is no WordPress API to delete transients by pattern, so a direct query 27 // is the only reliable approach here. Caching is intentionally skipped in an 28 // uninstall context; the object cache is flushed immediately afterwards. 29 $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching 30 "DELETE FROM {$wpdb->options} 31 WHERE option_name LIKE '_transient_wpsh_login_attempts_%' 29 32 OR option_name LIKE '_transient_timeout_wpsh_login_attempts_%' 30 33 OR option_name LIKE '_transient_wpsh_login_blocked_%' … … 32 35 ); 33 36 34 // If using object cache, flush it to remove any cached transients 35 if ( function_exists( 'wp_cache_flush' ) ) { 36 wp_cache_flush(); 37 } 38 39 // Optional: Clear any scheduled cron jobs if we add them in the future 40 // Example: wp_clear_scheduled_hook( 'wpsh_cleanup_logs' ); 41 42 // Log uninstallation (optional - only if you want to keep a record) 43 // Note: This creates a log entry before deleting options 44 if ( function_exists( 'error_log' ) ) { 45 error_log( 'Security Hardener plugin uninstalled at ' . current_time( 'mysql' ) ); 46 } 37 // Flush the object cache to remove any in-memory copies of the deleted transients. 38 wp_cache_flush();
Note: See TracChangeset
for help on using the changeset viewer.