Plugin Directory

Changeset 3466579


Ignore:
Timestamp:
02/21/2026 08:22:40 PM (5 weeks ago)
Author:
Marc4
Message:

v0.6

Location:
security-hardener
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • security-hardener/trunk/readme.txt

    r3457528 r3466579  
    55Tested up to: 6.9
    66Requires PHP: 8.0
    7 Stable tag: 0.5
     7Stable tag: 0.6
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    161161== Changelog ==
    162162
    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 =
    164174* Complete rewrite following WordPress hardening best practices
    165175* Increased minimum PHP requirement to 8.0 (PHP 7.4 is end-of-life)
  • security-hardener/trunk/security-hardener.php

    r3457528 r3466579  
    44Plugin URI: https://wordpress.org/plugins/security-hardener/
    55Description: 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.5
     6Version: 0.6
    77Requires at least: 6.0
    8 Tested up to: 6.8
     8Tested up to: 6.9
    99Requires PHP: 8.0
    1010Author: Marc Armengou
     
    8383         */
    8484        public function init() {
    85             // Load text domain
    86             load_plugin_textdomain( 'security-hardener', false, dirname( WPSH_BASENAME ) . '/languages' );
    87 
    8885            // Define security constants early
    8986            $this->define_security_constants();
     
    252249            // Disable file editing in WordPress admin
    253250            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
    255252            }
    256253
    257254            // Disable all file modifications (updates, installs) - CAUTION: This breaks updates!
    258255            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
    260257            }
    261258        }
     
    334331            // Check for author query parameter with numeric value
    335332            // 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;
    337334
    338335            // Block numeric author parameter
     
    429426                function ( $message ) {
    430427                    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>';
    432429                    }
    433430                    return $message;
     
    865862                esc_attr( $field_id ),
    866863                esc_attr( $value ),
    867                 $min,
    868                 $max
     864                absint( $min ),
     865                absint( $max )
    869866            );
    870867        }
  • security-hardener/trunk/uninstall.php

    r3457528 r3466579  
    2323global $wpdb;
    2424
    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_%'
    2932    OR option_name LIKE '_transient_timeout_wpsh_login_attempts_%'
    3033    OR option_name LIKE '_transient_wpsh_login_blocked_%'
     
    3235);
    3336
    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.
     38wp_cache_flush();
Note: See TracChangeset for help on using the changeset viewer.