Making WordPress.org

Changeset 14239


Ignore:
Timestamp:
12/05/2024 03:15:47 AM (7 months ago)
Author:
dd32
Message:

Plugin Directory: Plugin Check: Include low-severity issues in the output of plugin-check on plugin submission.

Fixes #7840.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload-handler.php

    r14223 r14239  
    686686        $command    = WPCLI . ' --url=https://wordpress.org/plugins ' .
    687687                      'plugin check ' .
    688                       '--error-severity=7 --warning-severity=6 --categories=plugin_repo --format=json ' .
     688                      '--error-severity=7 --warning-severity=6 --include-low-severity-errors ' .
     689                      '--categories=plugin_repo --format=json ' .
    689690                      '--slug=' . escapeshellarg( $this->plugin_slug ) . ' ' .
    690691                      escapeshellarg( $this->plugin_root );
     
    758759         * [{.....}]
    759760         */
    760         $verdict  = true;
    761         $results  = [];
    762         $output   = explode( "\n", $output );
     761        $verdict         = true;
     762        $results         = [];
     763        $results_by_type = [];
     764        $output          = explode( "\n", $output );
    763765        foreach ( array_chunk( $output, 3 ) as $file_result ) {
    764766            if ( ! str_starts_with( $file_result[0], 'FILE:' ) ) {
     
    777779
    778780                $results[] = $record;
     781
     782                $results_by_type[ $record['type'] ] ??= [];
     783                $results_by_type[ $record['type'] ][] = $record;
    779784
    780785                // Record submission stats.
     
    798803            $html .= '<ul class="pc-result" style="list-style: disc">';
    799804            // Display errors, and then warnings.
    800             foreach ( [ wp_list_filter( $results, [ 'type' => 'ERROR' ] ), wp_list_filter( $results, [ 'type' => 'ERROR' ], 'NOT' ) ] as $result_set ) {
     805            foreach ( [ 'ERROR', 'ERRORS_LOW_SEVERITY', 'WARNING', 'WARNING_LOW_SEVERITY' ] as $result_type ) {
     806                $result_set = $results_by_type[ $result_type ] ?? [];
     807                if ( empty( $result_set ) ) {
     808                    continue;
     809                }
     810
     811                // ERROR or WARNING
     812                $result_label = str_replace(
     813                    [
     814                        'S_LOW_SEVERITY', // S included because of the pluralisation.
     815                        '_LOW_SEVERITY'
     816                    ],
     817                    '',
     818                    $result_type
     819                );
     820
     821                $maybe_false_positive  = '';
     822                if ( str_ends_with( $result_type, 'LOW_SEVERITY' ) ) {
     823                    $result_label .= '*';
     824                    $maybe_false_positive = __( 'This may be a false-positive, and will be manually checked by a reviewer.', 'wporg-plugins' );
     825                }
     826
    801827                foreach ( $result_set as $result ) {
    802828                    $html .= sprintf(
    803                         '<li>%s <a href="%s">%s</a>: %s</li>',
     829                        '<li>%s <a href="%s" title="%s">%s</a>: %s</li>',
    804830                        esc_html( $result['file'] ),
    805831                        esc_url( $result['docs'] ?? '' ),
    806                         esc_html( $result['type'] . ' ' . $result['code'] ),
     832                        esc_attr( $maybe_false_positive ),
     833                        esc_html( "{$result_label}: {$result['code']}" ),
    807834                        esc_html( $result['message'] )
    808835                    );
     
    810837            }
    811838            $html .= '</ul>';
    812         }
    813         $html .= __( 'Note: While the automated plugin scan is based on the Plugin Review Guidelines, it is not a complete review. A successful result from the scan does not guarantee that the plugin will be approved, only that it is sufficient to be reviewed. All submitted plugins are checked manually to ensure they meet security and guideline standards before approval.', 'wporg-plugins' );
     839
     840            $html .= '<p>' . __( 'The above may contain false-positives. If you believe an error or warning is incorrect or a false-positive, please do not work around it. A reviewer will manually confirm this during the review process.', 'wporg-plugins' ) . '</p>';
     841        }
     842        $html .= '<p>' . __( 'Note: While the automated plugin scan is based on the Plugin Review Guidelines, it is not a complete review. A successful result from the scan does not guarantee that the plugin will be approved, only that it is sufficient to be reviewed. All submitted plugins are checked manually to ensure they meet security and guideline standards before approval.', 'wporg-plugins' ) . '</p>';
    814843
    815844        // If the upload is blocked; log it to slack.
     
    859888            $zip_name   = reset( $_FILES )['name'];
    860889            $output     = implode( "\n", $output );
    861             $text       = ":rotating_light: Error: {$return_code} for {$zip_name}: {$this->plugin['Name']} ({$this->plugin_slug}) took {$total_time}s\n```{$stderr}\n===\n{$output}```";
     890            $debug      = '';
     891            if ( $output || $stderr ) {
     892                $debug = trim( "{$output}\n===\n{$stderr}", "\n=" );
     893                $debug = "\n```{$debug}```";
     894            }
     895            $text       = ":rotating_light: Error: {$return_code} for {$zip_name}: {$this->plugin['Name']} ({$this->plugin_slug}) took {$total_time}s{$debug}";
    862896            notify_slack( PLUGIN_CHECK_LOGS_SLACK_CHANNEL, $text, wp_get_current_user(), true );
    863897        }
Note: See TracChangeset for help on using the changeset viewer.