Plugin Directory

Changeset 2309135


Ignore:
Timestamp:
05/20/2020 09:03:04 PM (6 years ago)
Author:
layotte
Message:

Tagging 2.1.6

Location:
ithemes-sync
Files:
16 edited
1 copied

Legend:

Unmodified
Added
Removed
  • ithemes-sync/tags/2.1.6/functions.php

    r2263241 r2309135  
    10311031    }
    10321032
     1033    /**
     1034     * Checks if sodium library and methods we use are available
     1035     * Also checks if sodium is fast enough on this system
     1036     * If available: include the compatiability layer, core utilities, and Base64 UrlSafe classes
     1037     *
     1038     * @return bool
     1039     */
     1040    public static function is_sodium_available() {
     1041        $requiredFiles = array(
     1042            'wp-includes/sodium_compat/autoload.php',
     1043        );
     1044
     1045        foreach ( $requiredFiles as $file ) {
     1046            if ( file_exists( ABSPATH . $file ) ) {
     1047                require_once( ABSPATH . $file );
     1048            } else {
     1049                return false;
     1050            }
     1051        }
     1052
     1053        // Verify the functions we need are callable
     1054        if ( ! is_callable( 'sodium_base642bin' ) || ! is_callable( 'sodium_crypto_sign_verify_detached' ) ) {
     1055            return false;
     1056        }
     1057
     1058        // Check for a edge-case affecting PHP Maths abilities
     1059        // Sodium_Compat isn't compatible with PHP 7.2.0~7.2.2 due to a bug in the PHP Opcache extension, bail early as it'll fail.
     1060        if (
     1061            ! extension_loaded( 'sodium' ) &&
     1062            in_array( PHP_VERSION_ID, [ 70200, 70201, 70202 ], true ) &&
     1063            extension_loaded( 'opcache' )
     1064        ) {
     1065            return false;
     1066        }
     1067
     1068        // Verify runtime speed of Sodium_Compat is acceptable.
     1069        if ( ! extension_loaded( 'sodium' ) && ! ParagonIE_Sodium_Compat::polyfill_is_fast() ) {
     1070
     1071            // Allow for an old version of Sodium_Compat being loaded before the bundled WordPress one.
     1072            if ( method_exists( 'ParagonIE_Sodium_Compat', 'runtime_speed_test' ) ) {
     1073                // Run `ParagonIE_Sodium_Compat::runtime_speed_test()` in optimized integer mode, as that's what is used for signing verifications.
     1074                $old_fastMult                      = ParagonIE_Sodium_Compat::$fastMult;
     1075                ParagonIE_Sodium_Compat::$fastMult = true;
     1076                $sodium_compat_is_fast             = ParagonIE_Sodium_Compat::runtime_speed_test( 100, 10 );
     1077                ParagonIE_Sodium_Compat::$fastMult = $old_fastMult;
     1078
     1079                return $sodium_compat_is_fast;
     1080            }
     1081
     1082        }
     1083
     1084        return true;
     1085    }
    10331086}
  • ithemes-sync/tags/2.1.6/history.txt

    r2275244 r2309135  
    2352352.1.5 - 2020-04-03 - Josh Oakes
    236236    Bug Fix: Limit the total number of unsent notices that can be queued
     2372.1.6 - 2020-05-20 - Josh Oakes
     238    Bug Fix: Fixed an issue where a user couldn't be unsynced if already removed from the dashboard
  • ithemes-sync/tags/2.1.6/init.php

    r2275244 r2309135  
    55Description: Manage updates to your WordPress sites easily in one place.
    66Author: iThemes
    7 Version: 2.1.5
     7Version: 2.1.6
    88Author URI: http://ithemes.com/
    99Domain Path: /lang/
  • ithemes-sync/tags/2.1.6/lang/ithemes-sync.pot

    r2275244 r2309135  
    55"Project-Id-Version: iThemes Sync 2.1.5\n"
    66"Report-Msgid-Bugs-To: http://ithemes.com/support/\n"
    7 "POT-Creation-Date: 2020-04-03 16:05:35+00:00\n"
     7"POT-Creation-Date: 2020-05-20 20:44:47+00:00\n"
    88"PO-Revision-Date: 2020-MO-DA HO:MI+ZONE\n"
    99"MIME-Version: 1.0\n"
     
    351351msgstr ""
    352352
    353 #: server.php:192
     353#: server.php:195
    354354msgid "An unrecognized server response format was received from the iThemes Sync server."
    355355msgstr ""
  • ithemes-sync/tags/2.1.6/readme.txt

    r2275244 r2309135  
    8888== Changelog ==
    8989
     90= 2.1.6 =
     91* Bug Fix: Fixed an issue where a user couldn't be unsynced if already removed from the dashboard
     92
    9093= 2.1.5 =
    9194* Bug Fix: Limit the total number of unsent notices that can be queued
  • ithemes-sync/tags/2.1.6/request-handler.php

    r2263241 r2309135  
    6262        $request   = $_POST['request'];
    6363
     64        if ( !empty( $_POST['signature'] ) ) {
     65
     66            // Append success and failures to response
     67            $sodium_available = Ithemes_Sync_Functions::is_sodium_available();
     68
     69            if ( $sodium_available && ! $this->verify_request_signature( $request, $_POST['signature'] ) ) {
     70                // Sodium is available and verification failed
     71                do_action( 'ithemes-sync-add-log', 'signature-verification', array( 'available' => true, 'verified' => false ) );
     72
     73                // $this->send_response( new WP_Error( 'request-signature-invalid', 'The request signature could not be verified' ) );
     74            } elseif ( $sodium_available ) {
     75                // Sodium available and signature was verified
     76                do_action( 'ithemes-sync-add-log', 'signature-verification', array( 'available' => true, 'verified' => true ) );
     77            } else {
     78                // Sodium is not available
     79                do_action( 'ithemes-sync-add-log', 'signature-verification', array( 'available' => false, 'verified' => false ) );
     80            }
     81        }
     82
    6483        if ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
    6584            $request = stripslashes( $request );
     
    462481    }
    463482
     483    /**
     484     * Determine if signature supplied in the request can be verified using the public key
     485     *
     486     * @param $request
     487     * @param $signature
     488     *
     489     * @return bool
     490     */
     491    private function verify_request_signature( $request, $signature ) {
     492
     493        // Verify the functions we need are callable
     494        if ( ! is_callable( 'sodium_base642bin' ) || ! is_callable( 'sodium_crypto_sign_verify_detached' ) ) {
     495            return false;
     496        }
     497
     498        try {
     499
     500            $public_key = sodium_base642bin( file_get_contents( $GLOBALS['ithemes_sync_path'] . '/public.key' ), 5 );
     501            $signature = sodium_base642bin( $signature, 5 );
     502
     503        } catch ( Exception $e ) {
     504            return false;
     505        }
     506
     507        return sodium_crypto_sign_verify_detached( $signature, $request, $public_key );
     508    }
     509
    464510}
    465511
  • ithemes-sync/tags/2.1.6/server.php

    r2244568 r2309135  
    111111   
    112112    public static function request( $action, $query = array(), $data = array() ) {
     113
     114        $secure_url = apply_filters( 'sync_api_request_url', self::$secure_server_url );
     115
    113116        if ( isset( $data['auth_token'] ) ) {
    114117            $data['iterations'] = self::$password_iterations;
     
    153156           
    154157            if ( is_wp_error( $response ) ) {
    155                 $response = wp_remote_post( self::$secure_server_url . $request, $remote_post_args );
     158                $response = wp_remote_post( $secure_url . $request, $remote_post_args );
    156159            } else {
    157160                $options['use_ca_patch'] = true;
     
    159162        }
    160163        else {
    161             $response = wp_remote_post( self::$secure_server_url . $request, $remote_post_args );
     164            $response = wp_remote_post( $secure_url . $request, $remote_post_args );
    162165           
    163166            if ( is_wp_error( $response ) ) {
     
    171174       
    172175        if ( is_wp_error( $response ) ) {
    173             $response = wp_remote_post( self::$insecure_server_url . $request . '&insecure=1', $remote_post_args );
     176            $response = wp_remote_post( $secure_url . $request . '&insecure=1', $remote_post_args );
    174177           
    175178            $options['use_ssl'] = false;
     
    202205   
    203206    private static function do_patched_post( $request, $remote_post_args ) {
     207        $secure_url = apply_filters( 'sync_api_request_url', self::$secure_server_url );
     208
    204209        self::enable_ssl_ca_patch();
    205         $response = wp_remote_post( self::$secure_server_url . $request . '&ca_patch=1', $remote_post_args );
     210        $response = wp_remote_post( $secure_url . $request . '&ca_patch=1', $remote_post_args );
    206211        self::disable_ssl_ca_patch();
    207212       
     
    225230   
    226231    public static function add_ca_patch_to_curl_opts( $handle ) {
     232        $secure_url = apply_filters( 'sync_api_request_url', self::$secure_server_url );
    227233        $url = curl_getinfo( $handle, CURLINFO_EFFECTIVE_URL );
    228234       
    229         if ( ! preg_match( '/^' . preg_quote( self::$secure_server_url, '/' ) . '/', $url ) ) {
     235        if ( ! preg_match( '/^' . preg_quote( $secure_url, '/' ) . '/', $url ) ) {
    230236            return;
    231237        }
  • ithemes-sync/tags/2.1.6/settings-page.php

    r1881423 r2309135  
    156156       
    157157        $result = Ithemes_Sync_Server::deauthenticate( $data['user'], $user_details['username'], $user_details['key'] );
    158        
    159         if ( is_wp_error( $result ) && ( 'authentication' != $result->get_error_code() ) ) {
     158
     159        if ( is_wp_error( $result ) && ( 'authentication' != $result->get_error_code() ) && 'This site has not been authenticated by this user.' != $result->get_error_message() ) {
    160160            $heading = __( 'The user could not be unsynced.', 'it-l10n-ithemes-sync' );
    161161            $message = $result->get_error_message();
     
    337337            </form>
    338338        </div>
     339        <?php  do_action('sync_dev_render'); ?>
    339340    </div>
    340341<?php
  • ithemes-sync/trunk/functions.php

    r2263241 r2309135  
    10311031    }
    10321032
     1033    /**
     1034     * Checks if sodium library and methods we use are available
     1035     * Also checks if sodium is fast enough on this system
     1036     * If available: include the compatiability layer, core utilities, and Base64 UrlSafe classes
     1037     *
     1038     * @return bool
     1039     */
     1040    public static function is_sodium_available() {
     1041        $requiredFiles = array(
     1042            'wp-includes/sodium_compat/autoload.php',
     1043        );
     1044
     1045        foreach ( $requiredFiles as $file ) {
     1046            if ( file_exists( ABSPATH . $file ) ) {
     1047                require_once( ABSPATH . $file );
     1048            } else {
     1049                return false;
     1050            }
     1051        }
     1052
     1053        // Verify the functions we need are callable
     1054        if ( ! is_callable( 'sodium_base642bin' ) || ! is_callable( 'sodium_crypto_sign_verify_detached' ) ) {
     1055            return false;
     1056        }
     1057
     1058        // Check for a edge-case affecting PHP Maths abilities
     1059        // Sodium_Compat isn't compatible with PHP 7.2.0~7.2.2 due to a bug in the PHP Opcache extension, bail early as it'll fail.
     1060        if (
     1061            ! extension_loaded( 'sodium' ) &&
     1062            in_array( PHP_VERSION_ID, [ 70200, 70201, 70202 ], true ) &&
     1063            extension_loaded( 'opcache' )
     1064        ) {
     1065            return false;
     1066        }
     1067
     1068        // Verify runtime speed of Sodium_Compat is acceptable.
     1069        if ( ! extension_loaded( 'sodium' ) && ! ParagonIE_Sodium_Compat::polyfill_is_fast() ) {
     1070
     1071            // Allow for an old version of Sodium_Compat being loaded before the bundled WordPress one.
     1072            if ( method_exists( 'ParagonIE_Sodium_Compat', 'runtime_speed_test' ) ) {
     1073                // Run `ParagonIE_Sodium_Compat::runtime_speed_test()` in optimized integer mode, as that's what is used for signing verifications.
     1074                $old_fastMult                      = ParagonIE_Sodium_Compat::$fastMult;
     1075                ParagonIE_Sodium_Compat::$fastMult = true;
     1076                $sodium_compat_is_fast             = ParagonIE_Sodium_Compat::runtime_speed_test( 100, 10 );
     1077                ParagonIE_Sodium_Compat::$fastMult = $old_fastMult;
     1078
     1079                return $sodium_compat_is_fast;
     1080            }
     1081
     1082        }
     1083
     1084        return true;
     1085    }
    10331086}
  • ithemes-sync/trunk/history.txt

    r2275244 r2309135  
    2352352.1.5 - 2020-04-03 - Josh Oakes
    236236    Bug Fix: Limit the total number of unsent notices that can be queued
     2372.1.6 - 2020-05-20 - Josh Oakes
     238    Bug Fix: Fixed an issue where a user couldn't be unsynced if already removed from the dashboard
  • ithemes-sync/trunk/init.php

    r2275244 r2309135  
    55Description: Manage updates to your WordPress sites easily in one place.
    66Author: iThemes
    7 Version: 2.1.5
     7Version: 2.1.6
    88Author URI: http://ithemes.com/
    99Domain Path: /lang/
  • ithemes-sync/trunk/lang/ithemes-sync.pot

    r2275244 r2309135  
    55"Project-Id-Version: iThemes Sync 2.1.5\n"
    66"Report-Msgid-Bugs-To: http://ithemes.com/support/\n"
    7 "POT-Creation-Date: 2020-04-03 16:05:35+00:00\n"
     7"POT-Creation-Date: 2020-05-20 20:44:47+00:00\n"
    88"PO-Revision-Date: 2020-MO-DA HO:MI+ZONE\n"
    99"MIME-Version: 1.0\n"
     
    351351msgstr ""
    352352
    353 #: server.php:192
     353#: server.php:195
    354354msgid "An unrecognized server response format was received from the iThemes Sync server."
    355355msgstr ""
  • ithemes-sync/trunk/readme.txt

    r2275244 r2309135  
    8888== Changelog ==
    8989
     90= 2.1.6 =
     91* Bug Fix: Fixed an issue where a user couldn't be unsynced if already removed from the dashboard
     92
    9093= 2.1.5 =
    9194* Bug Fix: Limit the total number of unsent notices that can be queued
  • ithemes-sync/trunk/request-handler.php

    r2263241 r2309135  
    6262        $request   = $_POST['request'];
    6363
     64        if ( !empty( $_POST['signature'] ) ) {
     65
     66            // Append success and failures to response
     67            $sodium_available = Ithemes_Sync_Functions::is_sodium_available();
     68
     69            if ( $sodium_available && ! $this->verify_request_signature( $request, $_POST['signature'] ) ) {
     70                // Sodium is available and verification failed
     71                do_action( 'ithemes-sync-add-log', 'signature-verification', array( 'available' => true, 'verified' => false ) );
     72
     73                // $this->send_response( new WP_Error( 'request-signature-invalid', 'The request signature could not be verified' ) );
     74            } elseif ( $sodium_available ) {
     75                // Sodium available and signature was verified
     76                do_action( 'ithemes-sync-add-log', 'signature-verification', array( 'available' => true, 'verified' => true ) );
     77            } else {
     78                // Sodium is not available
     79                do_action( 'ithemes-sync-add-log', 'signature-verification', array( 'available' => false, 'verified' => false ) );
     80            }
     81        }
     82
    6483        if ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
    6584            $request = stripslashes( $request );
     
    462481    }
    463482
     483    /**
     484     * Determine if signature supplied in the request can be verified using the public key
     485     *
     486     * @param $request
     487     * @param $signature
     488     *
     489     * @return bool
     490     */
     491    private function verify_request_signature( $request, $signature ) {
     492
     493        // Verify the functions we need are callable
     494        if ( ! is_callable( 'sodium_base642bin' ) || ! is_callable( 'sodium_crypto_sign_verify_detached' ) ) {
     495            return false;
     496        }
     497
     498        try {
     499
     500            $public_key = sodium_base642bin( file_get_contents( $GLOBALS['ithemes_sync_path'] . '/public.key' ), 5 );
     501            $signature = sodium_base642bin( $signature, 5 );
     502
     503        } catch ( Exception $e ) {
     504            return false;
     505        }
     506
     507        return sodium_crypto_sign_verify_detached( $signature, $request, $public_key );
     508    }
     509
    464510}
    465511
  • ithemes-sync/trunk/server.php

    r2244568 r2309135  
    111111   
    112112    public static function request( $action, $query = array(), $data = array() ) {
     113
     114        $secure_url = apply_filters( 'sync_api_request_url', self::$secure_server_url );
     115
    113116        if ( isset( $data['auth_token'] ) ) {
    114117            $data['iterations'] = self::$password_iterations;
     
    153156           
    154157            if ( is_wp_error( $response ) ) {
    155                 $response = wp_remote_post( self::$secure_server_url . $request, $remote_post_args );
     158                $response = wp_remote_post( $secure_url . $request, $remote_post_args );
    156159            } else {
    157160                $options['use_ca_patch'] = true;
     
    159162        }
    160163        else {
    161             $response = wp_remote_post( self::$secure_server_url . $request, $remote_post_args );
     164            $response = wp_remote_post( $secure_url . $request, $remote_post_args );
    162165           
    163166            if ( is_wp_error( $response ) ) {
     
    171174       
    172175        if ( is_wp_error( $response ) ) {
    173             $response = wp_remote_post( self::$insecure_server_url . $request . '&insecure=1', $remote_post_args );
     176            $response = wp_remote_post( $secure_url . $request . '&insecure=1', $remote_post_args );
    174177           
    175178            $options['use_ssl'] = false;
     
    202205   
    203206    private static function do_patched_post( $request, $remote_post_args ) {
     207        $secure_url = apply_filters( 'sync_api_request_url', self::$secure_server_url );
     208
    204209        self::enable_ssl_ca_patch();
    205         $response = wp_remote_post( self::$secure_server_url . $request . '&ca_patch=1', $remote_post_args );
     210        $response = wp_remote_post( $secure_url . $request . '&ca_patch=1', $remote_post_args );
    206211        self::disable_ssl_ca_patch();
    207212       
     
    225230   
    226231    public static function add_ca_patch_to_curl_opts( $handle ) {
     232        $secure_url = apply_filters( 'sync_api_request_url', self::$secure_server_url );
    227233        $url = curl_getinfo( $handle, CURLINFO_EFFECTIVE_URL );
    228234       
    229         if ( ! preg_match( '/^' . preg_quote( self::$secure_server_url, '/' ) . '/', $url ) ) {
     235        if ( ! preg_match( '/^' . preg_quote( $secure_url, '/' ) . '/', $url ) ) {
    230236            return;
    231237        }
  • ithemes-sync/trunk/settings-page.php

    r1881423 r2309135  
    156156       
    157157        $result = Ithemes_Sync_Server::deauthenticate( $data['user'], $user_details['username'], $user_details['key'] );
    158        
    159         if ( is_wp_error( $result ) && ( 'authentication' != $result->get_error_code() ) ) {
     158
     159        if ( is_wp_error( $result ) && ( 'authentication' != $result->get_error_code() ) && 'This site has not been authenticated by this user.' != $result->get_error_message() ) {
    160160            $heading = __( 'The user could not be unsynced.', 'it-l10n-ithemes-sync' );
    161161            $message = $result->get_error_message();
     
    337337            </form>
    338338        </div>
     339        <?php  do_action('sync_dev_render'); ?>
    339340    </div>
    340341<?php
Note: See TracChangeset for help on using the changeset viewer.