Making WordPress.org

Ticket #5357: red-flag-many-plugins-fast.diff

File red-flag-many-plugins-fast.diff, 2.9 KB (added by Ipstenu, 4 years ago)
  • trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-review-tools.php

     
    208208                                }
    209209                        }
    210210
    211                         // User account was registered less than 2 weeks ago (but longer than 3 days) (user is still fairly new).
    212                         $two_weeks_ago  = time() - ( 2 * WEEK_IN_SECONDS );
    213                         $three_days_ago = time() - ( 3 * DAY_IN_SECONDS );
    214                         if ( strtotime( $author->user_registered ) > $two_weeks_ago && strtotime( $author->user_registered ) < $three_days_ago ) {
     211                        // There has been an uptick in users with names ending in numbers AND being very new, submitting
     212                        // a lot of plugins after being banned.
     213                        $two_weeks_ago = time() - ( 2 * WEEK_IN_SECONDS );
     214                        $four_days_ago = time() - ( 4 * DAY_IN_SECONDS );
     215                        if ( is_numeric( substr( $author->user_login, - 1, 1 ) ) && strtotime( $author->user_registered ) > $four_days_ago ) {
     216                                // Username ends in numbers and is less than 4 days old.
     217                                array_push( self::$flagged['high'], 'account registered less than 4 days ago and username ends in numbers' );
     218                        } elseif ( is_numeric( substr( $author->user_login, - 1, 1 ) ) ) {
     219                                // Username just ends in numbers.
     220                                array_push( self::$flagged['med'], 'username ends in numbers' );
     221                        } elseif ( strtotime( $author->user_registered ) > $two_weeks_ago && strtotime( $author->user_registered ) < $four_days_ago ) {
     222                                // User account was registered less than 2 weeks ago (but longer than 4 days).
    215223                                array_push( self::$flagged['low'], 'account registered less than 2 weeks ago' );
     224                                // If they have 4+ plugins in 2 weeks, it MAY be an issue.
     225                                if ( 4 <= count( $author_plugins ) ) {
     226                                        array_push( self::$flagged['med'], 'high number of submitted plugins in a short timeframe' );
     227                                }
     228                        } elseif ( strtotime( $author->user_registered ) > $four_days_ago ) {
     229                                // User account was registered less than 3 days ago.
     230                                array_push( self::$flagged['med'], 'account registered less than 4 days ago' );
     231                                // If they have 2+ plugins in 4 days, it's a problem.
     232                                if ( 2 <= count( $author_plugins ) ) {
     233                                        array_push( self::$flagged['high'], 'high number of submitted plugins in a short timeframe' );
     234                                }
    216235                        }
    217                         if ( strtotime( $author->user_registered ) > $three_days_ago ) {
    218                                 array_push( self::$flagged['low'], 'account registered less than 3 days ago' );
    219                         }
    220236
    221                         // Username ends in numbers.
    222                         if ( is_numeric( substr( $author->user_login, - 1, 1 ) ) ) {
    223                                 array_push( self::$flagged['low'], 'username ends in numbers' );
    224                         }
    225 
    226237                        // User has no URL.
    227238                        if ( empty( $author->user_url ) ) {
    228239                                array_push( self::$flagged['low'], 'account has no URL' );