Plugin Directory

Changeset 2986360


Ignore:
Timestamp:
10/30/2023 06:26:04 PM (2 years ago)
Author:
datafeedr.com
Message:

Update to version 0.9.68 from GitHub

Location:
datafeedr-comparison-sets
Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • datafeedr-comparison-sets/tags/0.9.68/classes/class-dfrcs.php

    r2901871 r2986360  
    320320    private function set_encoded_source() {
    321321        $source               = $this->source->original;
     322        $signature            = dfrcs_hash_hmac( serialize( $source ) );
     323        $source['signature']  = $signature;
    322324        $source               = serialize( $source );
    323325        $source               = base64_encode( $source );
  • datafeedr-comparison-sets/tags/0.9.68/datafeedr-comparison-sets.php

    r2981217 r2986360  
    1111Requires at least: 3.8
    1212Tested up to: 6.3.3-alpha
    13 Version: 0.9.67
     13Version: 0.9.68
    1414
    1515WC requires at least: 3.0
     
    4343 * Define constants.
    4444 */
    45 define( 'DFRCS_VERSION', '0.9.67' );
     45define( 'DFRCS_VERSION', '0.9.68' );
    4646define( 'DFRCS_DB_VERSION', '0.9.0' );
    4747define( 'DFRCS_URL', plugin_dir_url( __FILE__ ) );
  • datafeedr-comparison-sets/tags/0.9.68/includes/actions.php

    r2981217 r2986360  
    12371237    $request = $_REQUEST;
    12381238
    1239     $request_source  = $request['source'];
    1240     $request_source  = base64_decode( $request_source );
     1239    $request_source = $request['source'];
     1240    $request_source = base64_decode( $request_source );
    12411241    $request_source = unserialize( $request_source, [ 'allowed_classes' => false, 'max_depth' => 1 ] );
    12421242
     
    12441244    if ( ! is_array( $request_source ) ) {
    12451245        die();
     1246    }
     1247
     1248    $received_signature = $request_source['signature'];
     1249    unset( $request_source['signature'] );
     1250    $check_signature = dfrcs_hash_hmac( serialize( $request_source ) );
     1251
     1252    if ( ! hash_equals( $check_signature, $received_signature ) ) {
     1253        die( 'Invalid signature' );
    12461254    }
    12471255
     
    12741282    check_ajax_referer( 'dfrcs_ajax_nonce', 'dfrcs_security' );
    12751283
     1284    if ( ! dfrcs_can_manage_compset() ) {
     1285        die( 'Permission denied' );
     1286    }
     1287
    12761288    $request = $_REQUEST;
    12771289
    1278     if ( ! isset( $request['hash'] ) || empty( $request['hash'] ) ) {
     1290    if ( empty( $request['hash'] ) ) {
    12791291        die();
    12801292    }
     
    12901302    if ( ! is_array( $source ) ) {
    12911303        die();
     1304    }
     1305
     1306    $received_signature = $source['signature'];
     1307    unset( $source['signature'] );
     1308    $check_signature = dfrcs_hash_hmac( serialize( $source ) );
     1309
     1310    if ( ! hash_equals( $check_signature, $received_signature ) ) {
     1311        die( 'Invalid signature' );
    12921312    }
    12931313
     
    13391359    check_ajax_referer( 'dfrcs_ajax_nonce', 'dfrcs_security' );
    13401360
     1361    if ( ! dfrcs_can_manage_compset() ) {
     1362        die( 'Permission denied' );
     1363    }
     1364
    13411365    global $wpdb;
    13421366
     
    14151439    check_ajax_referer( 'dfrcs_ajax_nonce', 'dfrcs_security' );
    14161440
     1441    if ( ! dfrcs_can_manage_compset() ) {
     1442        die( 'Permission denied' );
     1443    }
     1444
    14171445    global $wpdb;
    14181446
     
    14931521    check_ajax_referer( 'dfrcs_ajax_nonce', 'dfrcs_security' );
    14941522
     1523    if ( ! dfrcs_can_manage_compset() ) {
     1524        die( 'Permission denied' );
     1525    }
     1526
    14951527    global $wpdb;
    14961528
     
    16201652    check_ajax_referer( 'dfrcs_ajax_nonce', 'dfrcs_security' );
    16211653
     1654    if ( ! dfrcs_can_manage_compset() ) {
     1655        die( 'Permission denied' );
     1656    }
     1657
    16221658    if ( ! isset( $_REQUEST['hash'] ) ) {
    1623         echo 'no hash';
    1624         die;
     1659        die( 'Missing hash' );
    16251660    }
    16261661
  • datafeedr-comparison-sets/tags/0.9.68/includes/functions.php

    r2981217 r2986360  
    14141414    return boolval( preg_match( '/^[a-f0-9]{32}$/', $md5 ) );
    14151415}
     1416
     1417/**
     1418 * Returns the Comparison Sets Hash value to use in signed requests.
     1419 *
     1420 * This function will only return a valid MD5 hash. If the value returned
     1421 * from the database does not exist OR is an invalid MD5 hash, this
     1422 * function will create and save a new MD5 hash and return the new hash.
     1423 *
     1424 * @since 0.9.68
     1425 *
     1426 * @return string
     1427 */
     1428function dfrcs_get_hash(): string {
     1429
     1430    $option = 'dfrcs_hash';
     1431    $hash   = get_option( $option, false );
     1432
     1433    if ( dfrcs_is_valid_md5( $hash ) ) {
     1434        return $hash;
     1435    }
     1436
     1437    $password = wp_generate_password( 64, true, true );
     1438    $hash     = wp_hash( $password );
     1439
     1440    update_option( $option, $hash, false );
     1441
     1442    return $hash;
     1443}
     1444
     1445/**
     1446 * Return a "signature" for the $data.
     1447 *
     1448 * @since 0.9.68
     1449 *
     1450 * @param string $data
     1451 *
     1452 * @return bool|string
     1453 */
     1454function dfrcs_hash_hmac( string $data ): bool|string {
     1455    $algo = 'sha256';
     1456    $key  = dfrcs_get_hash();
     1457
     1458    return hash_hmac( $algo, $data, $key );
     1459}
  • datafeedr-comparison-sets/tags/0.9.68/readme.txt

    r2981217 r2986360  
    99Requires at least: 3.8
    1010Tested up to: 6.3.3-alpha
    11 Stable tag: 0.9.67
     11Stable tag: 0.9.68
    1212
    1313Automatically create price comparison sets for your WooCommerce products or by using a shortcode.
     
    205205
    206206== Changelog ==
     207
     208= 0.9.68 - 2023/10/30 =
     209* Added `signed` encoded source values.
    207210
    208211= 0.9.67 - 2023/10/19 =
  • datafeedr-comparison-sets/trunk/classes/class-dfrcs.php

    r2901871 r2986360  
    320320    private function set_encoded_source() {
    321321        $source               = $this->source->original;
     322        $signature            = dfrcs_hash_hmac( serialize( $source ) );
     323        $source['signature']  = $signature;
    322324        $source               = serialize( $source );
    323325        $source               = base64_encode( $source );
  • datafeedr-comparison-sets/trunk/datafeedr-comparison-sets.php

    r2981217 r2986360  
    1111Requires at least: 3.8
    1212Tested up to: 6.3.3-alpha
    13 Version: 0.9.67
     13Version: 0.9.68
    1414
    1515WC requires at least: 3.0
     
    4343 * Define constants.
    4444 */
    45 define( 'DFRCS_VERSION', '0.9.67' );
     45define( 'DFRCS_VERSION', '0.9.68' );
    4646define( 'DFRCS_DB_VERSION', '0.9.0' );
    4747define( 'DFRCS_URL', plugin_dir_url( __FILE__ ) );
  • datafeedr-comparison-sets/trunk/includes/actions.php

    r2981217 r2986360  
    12371237    $request = $_REQUEST;
    12381238
    1239     $request_source  = $request['source'];
    1240     $request_source  = base64_decode( $request_source );
     1239    $request_source = $request['source'];
     1240    $request_source = base64_decode( $request_source );
    12411241    $request_source = unserialize( $request_source, [ 'allowed_classes' => false, 'max_depth' => 1 ] );
    12421242
     
    12441244    if ( ! is_array( $request_source ) ) {
    12451245        die();
     1246    }
     1247
     1248    $received_signature = $request_source['signature'];
     1249    unset( $request_source['signature'] );
     1250    $check_signature = dfrcs_hash_hmac( serialize( $request_source ) );
     1251
     1252    if ( ! hash_equals( $check_signature, $received_signature ) ) {
     1253        die( 'Invalid signature' );
    12461254    }
    12471255
     
    12741282    check_ajax_referer( 'dfrcs_ajax_nonce', 'dfrcs_security' );
    12751283
     1284    if ( ! dfrcs_can_manage_compset() ) {
     1285        die( 'Permission denied' );
     1286    }
     1287
    12761288    $request = $_REQUEST;
    12771289
    1278     if ( ! isset( $request['hash'] ) || empty( $request['hash'] ) ) {
     1290    if ( empty( $request['hash'] ) ) {
    12791291        die();
    12801292    }
     
    12901302    if ( ! is_array( $source ) ) {
    12911303        die();
     1304    }
     1305
     1306    $received_signature = $source['signature'];
     1307    unset( $source['signature'] );
     1308    $check_signature = dfrcs_hash_hmac( serialize( $source ) );
     1309
     1310    if ( ! hash_equals( $check_signature, $received_signature ) ) {
     1311        die( 'Invalid signature' );
    12921312    }
    12931313
     
    13391359    check_ajax_referer( 'dfrcs_ajax_nonce', 'dfrcs_security' );
    13401360
     1361    if ( ! dfrcs_can_manage_compset() ) {
     1362        die( 'Permission denied' );
     1363    }
     1364
    13411365    global $wpdb;
    13421366
     
    14151439    check_ajax_referer( 'dfrcs_ajax_nonce', 'dfrcs_security' );
    14161440
     1441    if ( ! dfrcs_can_manage_compset() ) {
     1442        die( 'Permission denied' );
     1443    }
     1444
    14171445    global $wpdb;
    14181446
     
    14931521    check_ajax_referer( 'dfrcs_ajax_nonce', 'dfrcs_security' );
    14941522
     1523    if ( ! dfrcs_can_manage_compset() ) {
     1524        die( 'Permission denied' );
     1525    }
     1526
    14951527    global $wpdb;
    14961528
     
    16201652    check_ajax_referer( 'dfrcs_ajax_nonce', 'dfrcs_security' );
    16211653
     1654    if ( ! dfrcs_can_manage_compset() ) {
     1655        die( 'Permission denied' );
     1656    }
     1657
    16221658    if ( ! isset( $_REQUEST['hash'] ) ) {
    1623         echo 'no hash';
    1624         die;
     1659        die( 'Missing hash' );
    16251660    }
    16261661
  • datafeedr-comparison-sets/trunk/includes/functions.php

    r2981217 r2986360  
    14141414    return boolval( preg_match( '/^[a-f0-9]{32}$/', $md5 ) );
    14151415}
     1416
     1417/**
     1418 * Returns the Comparison Sets Hash value to use in signed requests.
     1419 *
     1420 * This function will only return a valid MD5 hash. If the value returned
     1421 * from the database does not exist OR is an invalid MD5 hash, this
     1422 * function will create and save a new MD5 hash and return the new hash.
     1423 *
     1424 * @since 0.9.68
     1425 *
     1426 * @return string
     1427 */
     1428function dfrcs_get_hash(): string {
     1429
     1430    $option = 'dfrcs_hash';
     1431    $hash   = get_option( $option, false );
     1432
     1433    if ( dfrcs_is_valid_md5( $hash ) ) {
     1434        return $hash;
     1435    }
     1436
     1437    $password = wp_generate_password( 64, true, true );
     1438    $hash     = wp_hash( $password );
     1439
     1440    update_option( $option, $hash, false );
     1441
     1442    return $hash;
     1443}
     1444
     1445/**
     1446 * Return a "signature" for the $data.
     1447 *
     1448 * @since 0.9.68
     1449 *
     1450 * @param string $data
     1451 *
     1452 * @return bool|string
     1453 */
     1454function dfrcs_hash_hmac( string $data ): bool|string {
     1455    $algo = 'sha256';
     1456    $key  = dfrcs_get_hash();
     1457
     1458    return hash_hmac( $algo, $data, $key );
     1459}
  • datafeedr-comparison-sets/trunk/readme.txt

    r2981217 r2986360  
    99Requires at least: 3.8
    1010Tested up to: 6.3.3-alpha
    11 Stable tag: 0.9.67
     11Stable tag: 0.9.68
    1212
    1313Automatically create price comparison sets for your WooCommerce products or by using a shortcode.
     
    205205
    206206== Changelog ==
     207
     208= 0.9.68 - 2023/10/30 =
     209* Added `signed` encoded source values.
    207210
    208211= 0.9.67 - 2023/10/19 =
Note: See TracChangeset for help on using the changeset viewer.