Changeset 2986360
- Timestamp:
- 10/30/2023 06:26:04 PM (2 years ago)
- Location:
- datafeedr-comparison-sets
- Files:
-
- 10 edited
- 1 copied
-
tags/0.9.68 (copied) (copied from datafeedr-comparison-sets/trunk)
-
tags/0.9.68/classes/class-dfrcs.php (modified) (1 diff)
-
tags/0.9.68/datafeedr-comparison-sets.php (modified) (2 diffs)
-
tags/0.9.68/includes/actions.php (modified) (8 diffs)
-
tags/0.9.68/includes/functions.php (modified) (1 diff)
-
tags/0.9.68/readme.txt (modified) (2 diffs)
-
trunk/classes/class-dfrcs.php (modified) (1 diff)
-
trunk/datafeedr-comparison-sets.php (modified) (2 diffs)
-
trunk/includes/actions.php (modified) (8 diffs)
-
trunk/includes/functions.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
datafeedr-comparison-sets/tags/0.9.68/classes/class-dfrcs.php
r2901871 r2986360 320 320 private function set_encoded_source() { 321 321 $source = $this->source->original; 322 $signature = dfrcs_hash_hmac( serialize( $source ) ); 323 $source['signature'] = $signature; 322 324 $source = serialize( $source ); 323 325 $source = base64_encode( $source ); -
datafeedr-comparison-sets/tags/0.9.68/datafeedr-comparison-sets.php
r2981217 r2986360 11 11 Requires at least: 3.8 12 12 Tested up to: 6.3.3-alpha 13 Version: 0.9.6 713 Version: 0.9.68 14 14 15 15 WC requires at least: 3.0 … … 43 43 * Define constants. 44 44 */ 45 define( 'DFRCS_VERSION', '0.9.6 7' );45 define( 'DFRCS_VERSION', '0.9.68' ); 46 46 define( 'DFRCS_DB_VERSION', '0.9.0' ); 47 47 define( 'DFRCS_URL', plugin_dir_url( __FILE__ ) ); -
datafeedr-comparison-sets/tags/0.9.68/includes/actions.php
r2981217 r2986360 1237 1237 $request = $_REQUEST; 1238 1238 1239 $request_source = $request['source'];1240 $request_source = base64_decode( $request_source );1239 $request_source = $request['source']; 1240 $request_source = base64_decode( $request_source ); 1241 1241 $request_source = unserialize( $request_source, [ 'allowed_classes' => false, 'max_depth' => 1 ] ); 1242 1242 … … 1244 1244 if ( ! is_array( $request_source ) ) { 1245 1245 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' ); 1246 1254 } 1247 1255 … … 1274 1282 check_ajax_referer( 'dfrcs_ajax_nonce', 'dfrcs_security' ); 1275 1283 1284 if ( ! dfrcs_can_manage_compset() ) { 1285 die( 'Permission denied' ); 1286 } 1287 1276 1288 $request = $_REQUEST; 1277 1289 1278 if ( ! isset( $request['hash'] ) ||empty( $request['hash'] ) ) {1290 if ( empty( $request['hash'] ) ) { 1279 1291 die(); 1280 1292 } … … 1290 1302 if ( ! is_array( $source ) ) { 1291 1303 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' ); 1292 1312 } 1293 1313 … … 1339 1359 check_ajax_referer( 'dfrcs_ajax_nonce', 'dfrcs_security' ); 1340 1360 1361 if ( ! dfrcs_can_manage_compset() ) { 1362 die( 'Permission denied' ); 1363 } 1364 1341 1365 global $wpdb; 1342 1366 … … 1415 1439 check_ajax_referer( 'dfrcs_ajax_nonce', 'dfrcs_security' ); 1416 1440 1441 if ( ! dfrcs_can_manage_compset() ) { 1442 die( 'Permission denied' ); 1443 } 1444 1417 1445 global $wpdb; 1418 1446 … … 1493 1521 check_ajax_referer( 'dfrcs_ajax_nonce', 'dfrcs_security' ); 1494 1522 1523 if ( ! dfrcs_can_manage_compset() ) { 1524 die( 'Permission denied' ); 1525 } 1526 1495 1527 global $wpdb; 1496 1528 … … 1620 1652 check_ajax_referer( 'dfrcs_ajax_nonce', 'dfrcs_security' ); 1621 1653 1654 if ( ! dfrcs_can_manage_compset() ) { 1655 die( 'Permission denied' ); 1656 } 1657 1622 1658 if ( ! isset( $_REQUEST['hash'] ) ) { 1623 echo 'no hash'; 1624 die; 1659 die( 'Missing hash' ); 1625 1660 } 1626 1661 -
datafeedr-comparison-sets/tags/0.9.68/includes/functions.php
r2981217 r2986360 1414 1414 return boolval( preg_match( '/^[a-f0-9]{32}$/', $md5 ) ); 1415 1415 } 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 */ 1428 function 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 */ 1454 function 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 9 9 Requires at least: 3.8 10 10 Tested up to: 6.3.3-alpha 11 Stable tag: 0.9.6 711 Stable tag: 0.9.68 12 12 13 13 Automatically create price comparison sets for your WooCommerce products or by using a shortcode. … … 205 205 206 206 == Changelog == 207 208 = 0.9.68 - 2023/10/30 = 209 * Added `signed` encoded source values. 207 210 208 211 = 0.9.67 - 2023/10/19 = -
datafeedr-comparison-sets/trunk/classes/class-dfrcs.php
r2901871 r2986360 320 320 private function set_encoded_source() { 321 321 $source = $this->source->original; 322 $signature = dfrcs_hash_hmac( serialize( $source ) ); 323 $source['signature'] = $signature; 322 324 $source = serialize( $source ); 323 325 $source = base64_encode( $source ); -
datafeedr-comparison-sets/trunk/datafeedr-comparison-sets.php
r2981217 r2986360 11 11 Requires at least: 3.8 12 12 Tested up to: 6.3.3-alpha 13 Version: 0.9.6 713 Version: 0.9.68 14 14 15 15 WC requires at least: 3.0 … … 43 43 * Define constants. 44 44 */ 45 define( 'DFRCS_VERSION', '0.9.6 7' );45 define( 'DFRCS_VERSION', '0.9.68' ); 46 46 define( 'DFRCS_DB_VERSION', '0.9.0' ); 47 47 define( 'DFRCS_URL', plugin_dir_url( __FILE__ ) ); -
datafeedr-comparison-sets/trunk/includes/actions.php
r2981217 r2986360 1237 1237 $request = $_REQUEST; 1238 1238 1239 $request_source = $request['source'];1240 $request_source = base64_decode( $request_source );1239 $request_source = $request['source']; 1240 $request_source = base64_decode( $request_source ); 1241 1241 $request_source = unserialize( $request_source, [ 'allowed_classes' => false, 'max_depth' => 1 ] ); 1242 1242 … … 1244 1244 if ( ! is_array( $request_source ) ) { 1245 1245 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' ); 1246 1254 } 1247 1255 … … 1274 1282 check_ajax_referer( 'dfrcs_ajax_nonce', 'dfrcs_security' ); 1275 1283 1284 if ( ! dfrcs_can_manage_compset() ) { 1285 die( 'Permission denied' ); 1286 } 1287 1276 1288 $request = $_REQUEST; 1277 1289 1278 if ( ! isset( $request['hash'] ) ||empty( $request['hash'] ) ) {1290 if ( empty( $request['hash'] ) ) { 1279 1291 die(); 1280 1292 } … … 1290 1302 if ( ! is_array( $source ) ) { 1291 1303 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' ); 1292 1312 } 1293 1313 … … 1339 1359 check_ajax_referer( 'dfrcs_ajax_nonce', 'dfrcs_security' ); 1340 1360 1361 if ( ! dfrcs_can_manage_compset() ) { 1362 die( 'Permission denied' ); 1363 } 1364 1341 1365 global $wpdb; 1342 1366 … … 1415 1439 check_ajax_referer( 'dfrcs_ajax_nonce', 'dfrcs_security' ); 1416 1440 1441 if ( ! dfrcs_can_manage_compset() ) { 1442 die( 'Permission denied' ); 1443 } 1444 1417 1445 global $wpdb; 1418 1446 … … 1493 1521 check_ajax_referer( 'dfrcs_ajax_nonce', 'dfrcs_security' ); 1494 1522 1523 if ( ! dfrcs_can_manage_compset() ) { 1524 die( 'Permission denied' ); 1525 } 1526 1495 1527 global $wpdb; 1496 1528 … … 1620 1652 check_ajax_referer( 'dfrcs_ajax_nonce', 'dfrcs_security' ); 1621 1653 1654 if ( ! dfrcs_can_manage_compset() ) { 1655 die( 'Permission denied' ); 1656 } 1657 1622 1658 if ( ! isset( $_REQUEST['hash'] ) ) { 1623 echo 'no hash'; 1624 die; 1659 die( 'Missing hash' ); 1625 1660 } 1626 1661 -
datafeedr-comparison-sets/trunk/includes/functions.php
r2981217 r2986360 1414 1414 return boolval( preg_match( '/^[a-f0-9]{32}$/', $md5 ) ); 1415 1415 } 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 */ 1428 function 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 */ 1454 function 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 9 9 Requires at least: 3.8 10 10 Tested up to: 6.3.3-alpha 11 Stable tag: 0.9.6 711 Stable tag: 0.9.68 12 12 13 13 Automatically create price comparison sets for your WooCommerce products or by using a shortcode. … … 205 205 206 206 == Changelog == 207 208 = 0.9.68 - 2023/10/30 = 209 * Added `signed` encoded source values. 207 210 208 211 = 0.9.67 - 2023/10/19 =
Note: See TracChangeset
for help on using the changeset viewer.