WordPress.org

Plugin Directory

Changeset 379097


Ignore:
Timestamp:
04/30/11 07:29:04 (3 years ago)
Author:
ldebrouwer
Message:

Added another way to check for image files to reduce the number of false positives

Location:
wp-plugin-security-check/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wp-plugin-security-check/trunk/readme.txt

    r378556 r379097  
    55Requires at least: 3.1 
    66Tested up to: 3.1.1 
    7 Stable tag: 0.2 
     7Stable tag: 0.3 
    88 
    99WP Plugin Security Check checks if your WordPress plugins are 'safe'. 
     
    3131== Changelog == 
    3232 
     33= 0.3 = 
     34* Added another way to check for image files to reduce the number of false positives. 
     35 
    3336= 0.2 = 
    3437* Included checks for variable execution and the PHP function eval. 
  • wp-plugin-security-check/trunk/wp-plugin-security-check.php

    r378556 r379097  
    44 * Plugin URI: http://www.lucdebrouwer.nl/wordpress-plugin-wp-plugin-security-check/ 
    55 * Description: WP Plugin Security Check checks if your WordPress plugins are 'safe'. 
    6  * Version: 0.2 
     6 * Version: 0.3 
    77 * Author: Luc De Brouwer 
    88 * Author URI: http://www.lucdebrouwer.nl/ 
     
    2525} 
    2626 
     27function LDB_wp_plugin_security_check_get_ext( $name ) { 
     28    $parts = explode( '.', $name ); 
     29    return strtolower( $parts[( count( $parts )-1 )] ); 
     30} 
     31 
    2732function LDB_wp_plugin_security_check_variable_execution( $content ) { 
    2833    $regexp = '/\$([a-zA-Z0-9-_]+)\(/'; 
     
    4752    $realfile = WP_PLUGIN_DIR . '/' . $file; 
    4853    if( file_exists( $realfile ) ){ 
     54        $image = false; 
    4955        // Check if finfo_file() is supported; 
    50         $image = false; 
    5156        if( function_exists( 'finfo_file' ) && function_exists( 'finfo_open' ) ){ 
    5257            $mime_type = explode( '/', finfo_file( finfo_open( FILEINFO_MIME_TYPE ), $realfile ) ); 
     
    5964                $image = true; 
    6065            } 
     66        } else if ( LDB_wp_plugin_security_check_get_ext( $realfile ) == 'png' || LDB_wp_plugin_security_check_get_ext( $realfile ) == 'jpg' || LDB_wp_plugin_security_check_get_ext( $realfile ) == 'jpeg' || LDB_wp_plugin_security_check_get_ext( $realfile ) == 'gif'){ 
     67            $image = true; 
    6168        } 
    6269        // Don't scan images for now. 
     
    220227                    <li>Variable execution. Although this is somewhat common it's also a trick often used to prevent easy detection of malicious code as pointed out in this <a href="http://ottopress.com/2011/scanning-for-malicious-code-is-pointless/" target="_blank">excellent post</a> by Samuel Wood.</li> 
    221228                </ul> 
     229<?php 
     230    if ( !function_exists( 'finfo_file' ) && !function_exists( 'mime_content_type' ) ) { 
     231?> 
     232                <p><strong>Notice :</strong> Your hosting currently doesn't support the PHP functions <a href="http://php.net/manual/en/function.finfo-file.php" target="_blank">finfo_file</a> or <a href="http://php.net/manual/en/function.mime-content-type.php" target="_blank">mime_content_type</a> which means that image files have been excluded from testing based on their extension. This isn't fullproof but limits the number of false positives for variable execution.</p> 
     233<?php 
     234    } 
     235?> 
    222236            </div> 
    223237        </div> 
Note: See TracChangeset for help on using the changeset viewer.