Plugin Directory

Changeset 3356898


Ignore:
Timestamp:
09/05/2025 08:53:25 PM (7 months ago)
Author:
peachpay
Message:

1.117.6

Location:
peachpay-for-woocommerce
Files:
868 added
3 edited

Legend:

Unmodified
Added
Removed
  • peachpay-for-woocommerce/trunk/core/modules/analytics/class-peachpay-analytics-database.php

    r3101897 r3356898  
    549549        }
    550550
    551         $order_by_param  = array_key_exists( 'order_by', (array) $query ) && $query['order_by'] ? 'ORDER BY ' . $query['order_by'] : '';
    552         $group_by_param  = array_key_exists( 'group_by', (array) $query ) && $query['group_by'] ? 'GROUP BY ' . $query['group_by'] : '';
     551        // Sanitize order_by parameter to prevent SQL injection
     552        $order_by_param = '';
     553        if ( array_key_exists( 'order_by', (array) $query ) && $query['order_by'] ) {
     554            $order_by_param = self::sanitize_order_by_clause( $query['order_by'] );
     555        }
     556
     557        // Sanitize group_by parameter to prevent SQL injection
     558        $group_by_param = '';
     559        if ( array_key_exists( 'group_by', (array) $query ) && $query['group_by'] ) {
     560            $group_by_param = self::sanitize_group_by_clause( $query['group_by'] );
     561        }
    553562        $sum_results     = array_key_exists( 'sum', (array) $query ) ? $query['sum'] : 0;
    554563        $count_results   = array_key_exists( 'count', (array) $query ) && ! $currency_convert && $query['count'];
     
    831840            'datasets' => $analytics_interval,
    832841        );
     842    }
     843
     844    /**
     845     * Sanitizes the ORDER BY clause to prevent SQL injection.
     846     *
     847     * This function validates and sanitizes the order_by parameter by only allowing
     848     * whitelisted column names and sorting directions.
     849     *
     850     * @param string $order_by The order by clause to sanitize.
     851     * @return string Sanitized ORDER BY clause or empty string if invalid.
     852     */
     853    private static function sanitize_order_by_clause( $order_by ) {
     854        // Remove any extra whitespace
     855        $order_by = trim( $order_by );
     856       
     857        if ( empty( $order_by ) ) {
     858            return '';
     859        }
     860
     861        // Define allowed columns for ORDER BY
     862        $allowed_columns = array( 'id', 'title', 'currency', 'value', 'tab', 'section' );
     863       
     864        // Define allowed sort directions
     865        $allowed_directions = array( 'ASC', 'DESC' );
     866
     867        // Parse the order by clause
     868        $parts = preg_split( '/\s+/', $order_by, 2 );
     869        $column = trim( $parts[0] );
     870        $direction = isset( $parts[1] ) ? strtoupper( trim( $parts[1] ) ) : 'ASC';
     871
     872        // Validate column name
     873        if ( ! in_array( $column, $allowed_columns, true ) ) {
     874            // Log security incident
     875            peachpay_notify_error( new Exception( "Blocked SQL injection attempt in order_by parameter: {$order_by}" ) );
     876            return '';
     877        }
     878
     879        // Validate sort direction
     880        if ( ! in_array( $direction, $allowed_directions, true ) ) {
     881            // Default to ASC if invalid direction
     882            $direction = 'ASC';
     883        }
     884
     885        return "ORDER BY {$column} {$direction}";
     886    }
     887
     888    /**
     889     * Sanitizes the GROUP BY clause to prevent SQL injection.
     890     *
     891     * This function validates and sanitizes the group_by parameter by only allowing
     892     * whitelisted column names.
     893     *
     894     * @param string $group_by The group by clause to sanitize.
     895     * @return string Sanitized GROUP BY clause or empty string if invalid.
     896     */
     897    private static function sanitize_group_by_clause( $group_by ) {
     898        // Remove any extra whitespace
     899        $group_by = trim( $group_by );
     900       
     901        if ( empty( $group_by ) ) {
     902            return '';
     903        }
     904
     905        // Define allowed columns for GROUP BY
     906        $allowed_columns = array( 'id', 'title', 'currency', 'value', 'tab', 'section' );
     907       
     908        // Parse multiple columns (comma-separated)
     909        $columns = array_map( 'trim', explode( ',', $group_by ) );
     910        $sanitized_columns = array();
     911
     912        foreach ( $columns as $column ) {
     913            // Validate each column name
     914            if ( in_array( $column, $allowed_columns, true ) ) {
     915                $sanitized_columns[] = $column;
     916            } else {
     917                // Log security incident for invalid column
     918                peachpay_notify_error( new Exception( "Blocked SQL injection attempt in group_by parameter: {$column}" ) );
     919            }
     920        }
     921
     922        // Return empty string if no valid columns found
     923        if ( empty( $sanitized_columns ) ) {
     924            return '';
     925        }
     926
     927        return 'GROUP BY ' . implode( ', ', $sanitized_columns );
    833928    }
    834929
  • peachpay-for-woocommerce/trunk/peachpay.php

    r3351480 r3356898  
    44 * Plugin URI: https://woocommerce.com/products/peachpay
    55 * Description: Connect and manage all your payment methods, offer shoppers a beautiful Express Checkout, and reduce cart abandonment.
    6  * Version: 1.117.5
     6 * Version: 1.117.6
    77 * Text Domain: peachpay-for-woocommerce
    88 * Domain Path: /languages
  • peachpay-for-woocommerce/trunk/readme.txt

    r3351480 r3356898  
    44Requires at least: 5.8
    55Tested up to: 6.8.1
    6 Stable tag: 1.117.5
     6Stable tag: 1.117.6
    77Requires PHP: 7.0
    88License: GPLv2 or later
     
    262262
    263263== Changelog ==
     264
     265### 1.117.6 (2025-09-05)
     266
     267#### Bug Fixes
     268- Bug Fixes
    264269
    265270### 1.117.5 (2025-08-20)
Note: See TracChangeset for help on using the changeset viewer.