From 170b9c2fc70501234dd3851648c32a168c44680c Mon Sep 17 00:00:00 2001 From: Yakir Sitbon Date: Wed, 19 Aug 2026 19:09:34 +0300 Subject: [PATCH 1/4] Tweak: Added more escaping --- .github/workflows/php-coding-standards.yml | 2 +- aryo-activity-log.php | 20 +++--- classes/class-aal-activity-log-list-table.php | 66 +++++++++++-------- classes/class-aal-admin-ui.php | 2 +- classes/class-aal-maintenance.php | 2 +- classes/class-aal-notifications.php | 2 +- classes/class-aal-settings.php | 28 ++++---- .../abstract-class-aal-notification-base.php | 2 +- ruleset.xml | 8 ++- 9 files changed, 76 insertions(+), 56 deletions(-) diff --git a/.github/workflows/php-coding-standards.yml b/.github/workflows/php-coding-standards.yml index 3eae26c..d6bf8e0 100644 --- a/.github/workflows/php-coding-standards.yml +++ b/.github/workflows/php-coding-standards.yml @@ -47,5 +47,5 @@ jobs: run: | export PATH=$HOME/.composer/vendor/bin:$PATH composer run lint -- --report=checkstyle - # Also show warnings as PR annotations (non-blocking) + # Errors (including EscapeOutput) fail the job; remaining Security sniffs stay warnings vendor/bin/phpcs --standard=./ruleset.xml --extensions=php --error-severity=0 . --report=checkstyle || true diff --git a/aryo-activity-log.php b/aryo-activity-log.php index e5b7660..6b98b92 100644 --- a/aryo-activity-log.php +++ b/aryo-activity-log.php @@ -112,10 +112,12 @@ protected function __construct() { public function __clone() { _doing_it_wrong( __FUNCTION__, - sprintf( - /* translators: %s: Class name. */ - __( 'Cloning instances of the singleton "%s" class is forbidden.', 'aryo-activity-log' ), - get_class( $this ) + esc_html( + sprintf( + /* translators: %s: Class name. */ + __( 'Cloning instances of the singleton "%s" class is forbidden.', 'aryo-activity-log' ), + get_class( $this ) + ) ), '2.0.7' ); @@ -130,10 +132,12 @@ public function __clone() { public function __wakeup() { _doing_it_wrong( __FUNCTION__, - sprintf( - /* translators: %s: Class name. */ - __( 'Unserializing instances of the singleton "%s" class is forbidden.', 'aryo-activity-log' ), - get_class( $this ) + esc_html( + sprintf( + /* translators: %s: Class name. */ + __( 'Unserializing instances of the singleton "%s" class is forbidden.', 'aryo-activity-log' ), + get_class( $this ) + ) ), '2.0.7' ); diff --git a/classes/class-aal-activity-log-list-table.php b/classes/class-aal-activity-log-list-table.php index 86d94c8..b42a524 100644 --- a/classes/class-aal-activity-log-list-table.php +++ b/classes/class-aal-activity-log-list-table.php @@ -222,9 +222,9 @@ private function maybe_promotion_row( $object_type ) { printf( '
%s%s
', esc_attr( $object_type ), - wp_create_nonce( 'aal_promotion' ), - $promotion_html, - $dismiss_button + esc_attr( wp_create_nonce( 'aal_promotion' ) ), + $promotion_html, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped in get_promotion_html_by_object_type(). + $dismiss_button // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- label escaped with esc_html__(). ); } @@ -558,9 +558,21 @@ public function extra_tablenav_footer() { @@ -614,7 +626,7 @@ public function extra_tablenav( $which ) { ); echo ''; submit_button( __( 'Filter', 'aryo-activity-log' ), 'button', 'aal-filter', false, array( 'id' => 'activity-query-submit' ) ); @@ -631,9 +643,9 @@ public function extra_tablenav( $which ) { if ( ! empty( $output ) ) { echo ''; } @@ -655,9 +667,9 @@ public function extra_tablenav( $which ) { if ( ! empty( $output ) ) { echo ''; } @@ -668,19 +680,16 @@ public function extra_tablenav( $which ) { $_REQUEST['typeshow'] = ''; } - $output = array(); + echo ''; - printf( '', __( 'All Topics', 'aryo-activity-log' ) ); - echo implode( '', $output ); echo ''; } @@ -697,13 +706,16 @@ public function extra_tablenav( $which ) { if ( ! isset( $_REQUEST['showaction'] ) ) $_REQUEST['showaction'] = ''; - $output = array(); - foreach ( $actions as $action ) - $output[] = sprintf( '', $action->action, selected( $_REQUEST['showaction'], $action->action, false ), $this->get_action_label( $action->action ) ); - echo ''; } @@ -740,7 +752,7 @@ public function extra_tablenav( $which ) { foreach ( $filters as $filter ) { if ( ! empty( $_REQUEST[ $filter ] ) ) { - echo '' . __( 'Reset Filters', 'aryo-activity-log' ) . ''; + echo '' . esc_html__( 'Reset Filters', 'aryo-activity-log' ) . ''; break; } } @@ -881,8 +893,8 @@ public function search_box( $text, $input_id ) { $input_id = $input_id . '-search-input'; ?> get_list_table()->prepare_items(); ?>
-

+

diff --git a/classes/class-aal-maintenance.php b/classes/class-aal-maintenance.php index 372c2d7..71bb51c 100644 --- a/classes/class-aal-maintenance.php +++ b/classes/class-aal-maintenance.php @@ -242,7 +242,7 @@ public static function upgrade_notice() { public static function handle_manual_upgrade() { if ( ! current_user_can( 'manage_options' ) ) { - wp_die( __( 'You do not have sufficient permissions to access this page.', 'aryo-activity-log' ) ); + wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'aryo-activity-log' ) ); } check_admin_referer( 'aal_run_db_upgrade' ); diff --git a/classes/class-aal-notifications.php b/classes/class-aal-notifications.php index 893be4f..0e98bed 100644 --- a/classes/class-aal-notifications.php +++ b/classes/class-aal-notifications.php @@ -296,7 +296,7 @@ public function load_handlers() { */ public function register_handler( $classname ) { if ( ! class_exists( $classname ) ) { - trigger_error( __( 'The AAL notification handler you are trying to register does not exist.', 'aryo-activity-log' ) ); + trigger_error( esc_html__( 'The AAL notification handler you are trying to register does not exist.', 'aryo-activity-log' ) ); return false; } diff --git a/classes/class-aal-settings.php b/classes/class-aal-settings.php index 1e8bc7e..1b58e8d 100644 --- a/classes/class-aal-settings.php +++ b/classes/class-aal-settings.php @@ -276,7 +276,7 @@ private function menu_print_tabs() { foreach ( $sections as $section_key => $section_caption ) { $active = $current_section === $section_key ? 'nav-tab-active' : ''; $url = add_query_arg( 'aal_section', $section_key ); - echo '' . esc_html( $section_caption ) . ''; + echo '' . esc_html( $section_caption ) . ''; } } @@ -297,7 +297,7 @@ public function display_settings_page() {
-

+

@@ -316,7 +316,7 @@ public function display_settings_page() { public function admin_notices() { switch ( filter_input( INPUT_GET, 'message' ) ) { case 'data_erased': - printf( '

%s

', __( 'All activities have been successfully deleted.', 'aryo-activity-log' ) ); + printf( '

%s

', esc_html__( 'All activities have been successfully deleted.', 'aryo-activity-log' ) ); break; } } @@ -327,7 +327,7 @@ public function admin_footer() {