Plugin Directory

Changeset 1070808

Timestamp:
01/19/2015 06:01:40 AM (10 years ago)
Author:
tollmanz
Message:

Sync with Github.

Location:
https-mixed-content-detector
Files:
13 added
8 edited

Legend:

Unmodified
Added
Removed
  • https-mixed-content-detector/trunk/beacon.php

    r1059828 r1070808  
    7272            'show_in_admin_bar'   => false,
    7373            'menu_position'       => 25,
    74             'menu_icon'           => null,
     74            'menu_icon'           => ,
    7575            'can_export'          => false,
    7676            'delete_with_user'    => false,
     
    115115    public function manage_edit_csp_report_columns( $columns ) {
    116116        unset( $columns['title'] );
    117 
    118         $columns['blocked-uri']        = __( 'Blocked URI', 'zdt-mdc' );
    119         $columns['document-uri']       = __( 'Document URI', 'zdt-mdc' );
    120         $columns['referrer']           = __( 'Referrer', 'zdt-mdc' );
    121         $columns['violated-directive'] = __( 'Violated Directive', 'zdt-mdc' );
    122         $columns['original-policy']    = __( 'Original Policy', 'zdt-mdc' );
     117        unset( $columns['date'] );
     118
     119        $columns['blocked-uri']        = __( 'Blocked URI', 'zdt-mcd' );
     120        $columns['document-uri']       = __( 'Document URI', 'zdt-mcd' );
     121        $columns['referrer']           = __( 'Referrer', 'zdt-mcd' );
     122        $columns['violated-directive'] = __( 'Violated Directive', 'zdt-mcd' );
     123        $columns['report-date']        = __( 'Date', 'zdt-mcd' );
     124        $columns['location']           = __( 'Location', 'zdt-mcd' );
     125        $columns['resolve-status']     = __( 'Resolved', 'zdt-mcd' );
     126        $columns['secure-status']      = __( 'Secure URI', 'zdt-mcd' );
    123127
    124128        return $columns;
     
    137141        switch ( $column ) {
    138142            case 'blocked-uri' :
    139                 echo esc_url( get_the_title( $post_id ) );
     143                echo esc_url( get_ ) );
    140144                break;
    141145
     
    154158                break;
    155159
    156             case 'original-policy' :
    157                 $original_policy = get_post_meta( $post_id , 'original-policy' , true );
    158                 echo ( ! empty( $original_policy ) ) ? esc_html( wp_strip_all_tags( $original_policy ) ) : __( 'N/A', 'zdt-mcd' );
     160            case 'report-date' :
     161                echo human_time_diff( get_the_date( 'U', get_the_ID() ) );
     162                break;
     163
     164            case 'location':
     165                $location_id = get_post_meta( get_the_ID(), 'location', true );
     166                $collector = mcd_get_mixed_content_detector()->violation_location_collector;
     167                $location = $collector->get_item( $location_id );
     168
     169                if ( method_exists( $location, 'get_location_name' ) ) {
     170                    echo esc_html( $location->get_location_name() );
     171                } else if ( 'unknown' === $location_id ) {
     172                    echo __( 'Unknown', 'zdt-mcd' );
     173                } else {
     174                    echo __( 'N/A', 'zdt-mcd' );
     175                }
     176
     177                break;
     178
     179            case 'resolve-status':
     180                echo ( 1 === (int) get_post_meta( get_the_ID(), 'resolved', true ) ) ? __( 'Yes', 'zdt-mcd' ) : __( 'No', 'zdt-mcd' );
     181                break;
     182
     183            case 'secure-status':
     184                $status = (int) get_post_meta( get_the_ID(), 'valid-https-uri', true );
     185
     186                if ( 1 === $status ) {
     187                    $message = __( 'Yes', 'zdt-mcd' );
     188                } elseif ( 0 === $status ) {
     189                    $message = __( 'No', 'zdt-mcd' );
     190                } else {
     191                    $message = __( 'Unknown', 'zdt-mcd' );
     192                }
     193
     194                echo $message;
    159195                break;
    160196        }
     
    171207     */
    172208    public function handle_report_uri() {
    173         // If you can turn on the plugin, the beacon should work for you
    174         if ( ! current_user_can( 'activate_plugins' ) ) {
    175             return;
    176         }
    177 
    178209        // Check to make sure the a beacon request has been made
    179210        if ( ! isset( $_GET['mcd'] ) || 'report' !== $_GET['mcd'] ) {
    180211            return;
     212
     213
     214
     215
     216
     217
     218
     219
     220
     221
     222
     223
     224
     225
     226
     227
     228
     229
     230
     231
    181232        }
    182233
     
    229280        }
    230281
     282
     283
     284
    231285        // Check if the domain supports HTTPS
    232286        if ( isset( $clean_data['blocked-uri'] ) ) {
  • https-mixed-content-detector/trunk/config.php

    r1059828 r1070808  
    2424    define( 'MCD_MONITOR_FRONT_END', true );
    2525}
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
  • https-mixed-content-detector/trunk/helpers.php

    r1059828 r1070808  
    88 *
    99 * @param  int         $num    The number of violations to query.
     10
    1011 * @return WP_Query            The WP_Query containing the violations
    1112 */
    12 function mcd_get_violation_wp_query( $num = 999 ) {
     13function mcd_get_violation_wp_query( $num = 999 ) {
    1314    // Determine number of violations to display
    1415    $num = ( ! empty( $num ) ) ? intval( $num ) : 999; // Use intval to allow -1 if desired
    1516
    16     // Query for all violations
    17     $violations = new WP_Query( array(
    18         'post_type' => 'csp-report',
     17    $args = array(
     18        'post_type'      => 'csp-report',
    1919        'posts_per_page' => $num,
    20         'no_found_rows' => true,
    21     ) );
    22 
    23     return $violations;
     20        'no_found_rows'  => true,
     21    );
     22
     23    // If a specific ID is queried, add it to the query
     24    if ( 0 !== $id ) {
     25        $args['p']              = absint( $id );
     26        $args['posts_per_page'] = 1;
     27    }
     28
     29    return new WP_Query( $args );
    2430}
    2531endif;
     
    4652 *
    4753 * @param  int      $num    The number of violations to get.
     54
    4855 * @return array            The data for the violations.
    4956 */
    50 function mcd_get_violation_data( $num = 999 ) {
     57function mcd_get_violation_data( $num = 999 ) {
    5158    // Set a data collector
    5259    $data = array();
    5360
    5461    // Query for the violations
    55     $violation_wp_query = mcd_get_violation_wp_query( $num );
     62    $violation_wp_query = mcd_get_violation_wp_query( $num );
    5663
    5764    // Package up the important data
     
    6976            $original_policy = ( ! empty( $original_policy ) ) ? $original_policy : __( 'N/A', 'zdt-mcd' );
    7077
     78
     79
     80
    7181            $valid_https_uri = get_post_meta( get_the_ID(), 'valid-https-uri', true );
    7282            $valid_https_uri = ( '0' === $valid_https_uri || '1' === $valid_https_uri ) ? intval( $valid_https_uri ) :  -1;
     
    7484            $data[ get_the_ID() ] = array(
    7585                'id'                 => get_the_ID(),
    76                 'blocked-uri'        => get_the_title(),
     86                'blocked-uri'        => get_),
    7787                'document-uri'       => get_post_meta( get_the_ID(), 'document-uri', true ),
    7888                'referrer'           => $referrer,
    7989                'violated-directive' => $v_directive,
    8090                'original-policy'    => $original_policy,
     91
    8192                'resolved'           => absint( get_post_meta( get_the_ID(), 'resolved', true ) ),
    8293                'valid-https-uri'    => $valid_https_uri,
     
    245256}
    246257endif;
     258
     259
     260
     261
     262
     263
     264
     265
     266
     267
     268
     269
     270
     271
     272
     273
     274
     275
     276
     277
     278
     279
     280
     281
     282
     283
     284
     285
     286
     287
     288
     289
     290
     291
     292
     293
     294
     295
     296
     297
     298
     299
     300
     301
     302
     303
     304
     305
     306
     307
     308
     309
     310
     311
     312
     313
     314
     315
     316
     317
     318
     319
     320
     321
     322
     323
  • https-mixed-content-detector/trunk/https-mixed-content-detector.php

    r1059828 r1070808  
    44 * Plugin URI:     https://github.com/tollmanz/wordpress-https-mixed-content-detector
    55 * Description:    A tool for proactively detecting mixed content issues in TLS enabled WordPress websites.
    6  * Version:        1.1.0
     6 * Version:        1..0
    77 * Author:         Zack Tollman
    88 * Author URI:     https://www.tollmanz.com
     
    2525     * @var   string    The semantically versioned plugin version number.
    2626     */
    27     var $version = '1.1.0';
     27    var $version = '1..0';
    2828
    2929    /**
     
    5353     */
    5454    var $url_base = '';
     55
     56
     57
     58
     59
     60
     61
     62
     63
    5564
    5665    /**
     
    97106        include $this->root_dir . '/policy.php';
    98107
     108
    99109        if ( defined('WP_CLI') && WP_CLI ) {
    100110            include $this->root_dir . '/wp-cli.php';
    101111        }
     112
     113
     114
     115
     116
     117
     118
     119
     120
     121
     122
     123
     124
     125
     126
     127
     128
     129
     130
     131
     132
     133
     134
     135
     136
     137
     138
     139
     140
     141
     142
     143
     144
     145
     146
     147
     148
     149
     150
     151
     152
     153
     154
     155
     156
     157
     158
     159
     160
     161
     162
     163
     164
     165
     166
    102167    }
    103168}
  • https-mixed-content-detector/trunk/policy.php

    r1059828 r1070808  
    5454     */
    5555    public function add_cps_header() {
    56         if ( ! is_user_logged_in() ) {
    57             return;
     56        /**
     57         * The CSP header is added should be added if we are in sample mode or if not in sample mode *and* logged in.
     58         * Sample mode will set set a header for every request; however, the beacon will only accept
     59         * MCD_SAMPLE_FREQUENCY percent of requests.
     60         */
     61        if ( false === MCD_SAMPLE_MODE ) {
     62            if ( ! is_user_logged_in() ) {
     63                return;
     64            }
    5865        }
    5966
  • https-mixed-content-detector/trunk/readme.txt

    r1059828 r1070808  
    44Requires at least: 4.0.1
    55Tested up to: trunk
    6 Stable tag: 1.1.0
     6Stable tag: 1..0
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3535
    36361. Content Security Policy reports are collected in the Content Security Policy Reports list table.
     37
    3738
    3839== Changelog ==
     40
     41
     42
     43
     44
    3945
    4046= 1.1.0 =
     
    5460== Upgrade Notice ==
    5561
     62
     63
     64
    5665= 1.1.0 =
    5766Adds HTTPS domain checking, WP CLI commands and more specific CSP directives
  • https-mixed-content-detector/trunk/wp-cli.php

    r1059828 r1070808  
    4242                            $value = $unresolved;
    4343                        } else {
    44                             $value = __( '-', 'zdt-mdc' );
     44                            $value = __( '-', 'zdt-m' );
    4545                        }
    4646                    }
     
    5959            // Set up the Headers and Footers
    6060            $header_footers = array(
    61                 __( 'ID', 'zdt-mdc' ),
    62                 __( 'Blocked URI', 'zdt-mdc' ),
    63                 __( 'Document URI', 'zdt-mdc' ),
    64                 __( 'Referrer', 'zdt-mdc' ),
    65                 __( 'Violated Directive', 'zdt-mdc' ),
    66                 __( 'R', 'zdt-mdc' ),
    67                 __( 'S', 'zdt-mdc' ),
     61                __( 'ID', 'zdt-mcd' ),
     62                __( 'Blocked URI', 'zdt-mcd' ),
     63                __( 'Document URI', 'zdt-mcd' ),
     64                __( 'Referrer', 'zdt-mcd' ),
     65                __( 'Directive', 'zdt-mcd' ),
     66                __( 'Location', 'zdt-mcd' ),
     67                __( 'R', 'zdt-mcd' ),
     68                __( 'S', 'zdt-mcd' ),
    6869            );
    6970
     
    7778            WP_CLI::line( "\n  R = Resolved, S = Secure URI Available\n" );
    7879        } else {
    79             WP_CLI::warning( __( 'There are no CSP violations logged.', 'zdt-mdc' ) );
     80            WP_CLI::warning( __( 'There are no CSP violations logged.', 'zdt-m' ) );
    8081        }
    8182    }
     
    254255        WP_CLI::success( $message );
    255256    }
     257
     258
     259
     260
     261
     262
     263
     264
     265
     266
     267
     268
     269
     270
     271
     272
     273
     274
     275
     276
     277
     278
     279
     280
     281
     282
     283
     284
     285
     286
     287
     288
     289
     290
     291
     292
     293
     294
     295
     296
     297
     298
     299
     300
     301
     302
     303
     304
     305
     306
     307
     308
     309
     310
     311
     312
     313
     314
     315
     316
     317
     318
     319
     320
     321
     322
     323
     324
     325
     326
     327
     328
     329
     330
     331
     332
     333
     334
     335
     336
     337
     338
     339
     340
     341
     342
     343
     344
     345
    256346}
    257347endif;
Note: See TracChangeset for help on using the changeset viewer.