Skip to content

Commit

Permalink
Adds checks for trigger_error and set_error_handler
Browse files Browse the repository at this point in the history
Added checks per issue Automattic#272:
> trigger_error() doesn't make much sense, as there is no access to the
log file this will produce...and if you intentionally throw a fatal
error, that's doubly bad.
> set_error_handler() is not supported.

Test cases also added
  • Loading branch information
devonliu committed May 21, 2015
1 parent 5d44ef3 commit abfe8fc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/checks/test-VIPRestrictedCommandsCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ public function testDebugging() {
array( 'slug' => 'wp_debug_backtrace_summary', 'level' => 'Blocker', 'description' => "Unfiltered filesystem information output", 'file' => 'VIPRestrictedCommandsCheck7.inc', 'lines' => ++$line ),
array( 'slug' => 'debug_backtrace', 'level' => 'Blocker', 'description' => "Unfiltered filesystem information output", 'file' => 'VIPRestrictedCommandsCheck7.inc', 'lines' => ++$line ),
array( 'slug' => 'debug_print_backtrace', 'level' => 'Blocker', 'description' => "Unfiltered filesystem information output", 'file' => 'VIPRestrictedCommandsCheck7.inc', 'lines' => ++$line ),
array( 'slug' => 'trigger_error', 'level' => 'Blocker', 'description' => "Triggered error message not accessible", 'file' => 'VIPRestrictedCommandsCheck7.inc', 'lines' => ++$line ),
array( 'slug' => 'set_error_handler', 'level' => 'Blocker', 'description' => "User-defined error handler not supported", 'file' => 'VIPRestrictedCommandsCheck7.inc', 'lines' => ++$line ),
);
$actual_errors = $this->checkFile( 'VIPRestrictedCommandsCheck7.inc' );
$this->assertEqualErrors( $expected_errors, $actual_errors );
Expand Down
2 changes: 2 additions & 0 deletions vip-scanner/checks/VIPRestrictedCommandsCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ class VIPRestrictedCommandsCheck extends CodeCheck
"wp_debug_backtrace_summary" => array( "level" => "Blocker", "note" => "Unfiltered filesystem information output" ),
"debug_backtrace" => array( "level" => "Blocker", "note" => "Unfiltered filesystem information output" ),
"debug_print_backtrace" => array( "level" => "Blocker", "note" => "Unfiltered filesystem information output" ),
"trigger_error" => array( "level" => "Blocker", "note" => "Triggered error message not accessible" ),
"set_error_handler" => array( "level" => "Blocker", "note" => "User-defined error handler not supported" ),


// other
Expand Down

0 comments on commit abfe8fc

Please sign in to comment.