Skip to content

Commit

Permalink
updated named functions and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davidperezgar committed Aug 29, 2024
1 parent 7d583ea commit 6f574ea
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
6 changes: 6 additions & 0 deletions phpcs-rulesets/plugin-review.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,14 @@
<element key="create_function" value="null"/>
<element key="eval" value="null"/>
<element key="str_rot13" value="null"/>
<element key="set_time_limit" value="null"/>
<element key="ini_set" value="null"/>
<element key="ini_alter" value="null"/>
<element key="dl" value="null"/>
</property>
</properties>
<type>error</type>
<severity>7</severity>
</rule>

<!-- Check for use of deprecated WordPress classes, functions and function parameters. -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@
$the_author_email = ob_get_clean();

$var_post_not_sanitized = $_POST['not_sanitized'];

set_time_limit( 20 );
ini_set( 'max_execution_time', 20 );
ini_alter( 'max_execution_time', 20 );
dl( 'plugin-check.so' );
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function test_run_with_errors() {

$this->assertNotEmpty( $errors );
$this->assertArrayHasKey( 'load.php', $errors );
$this->assertEquals( 5, $check_result->get_error_count() );
$this->assertEquals( 9, $check_result->get_error_count() );

// Check for Generic.PHP.DisallowShortOpenTag.Found error on Line no 6 and column no at 1.
$this->assertArrayHasKey( 6, $errors['load.php'] );
Expand All @@ -41,6 +41,30 @@ public function test_run_with_errors() {
$this->assertArrayHasKey( 27, $errors['load.php'][15] );
$this->assertArrayHasKey( 'code', $errors['load.php'][15][27][0] );
$this->assertEquals( 'WordPress.Security.ValidatedSanitizedInput.InputNotValidated', $errors['load.php'][15][27][0]['code'] );

// Check for WordPress.Security.Generic.PHP.ForbiddenFunctions.Found error on Line no 17 and column no at 1.
$this->assertArrayHasKey( 17, $errors['load.php'] );
$this->assertArrayHasKey( 1, $errors['load.php'][17] );
$this->assertArrayHasKey( 'code', $errors['load.php'][17][1][0] );
$this->assertEquals( 'Generic.PHP.ForbiddenFunctions.Found', $errors['load.php'][17][1][0]['code'] );

// Check for WordPress.Security.Generic.PHP.ForbiddenFunctions.Found error on Line no 18 and column no at 1.
$this->assertArrayHasKey( 18, $errors['load.php'] );
$this->assertArrayHasKey( 1, $errors['load.php'][18] );
$this->assertArrayHasKey( 'code', $errors['load.php'][18][1][0] );
$this->assertEquals( 'Generic.PHP.ForbiddenFunctions.Found', $errors['load.php'][18][1][0]['code'] );

// Check for WordPress.Security.Generic.PHP.ForbiddenFunctions.Found error on Line no 19 and column no at 1.
$this->assertArrayHasKey( 19, $errors['load.php'] );
$this->assertArrayHasKey( 1, $errors['load.php'][19] );
$this->assertArrayHasKey( 'code', $errors['load.php'][19][1][0] );
$this->assertEquals( 'Generic.PHP.ForbiddenFunctions.Found', $errors['load.php'][19][1][0]['code'] );

// Check for WordPress.Security.Generic.PHP.ForbiddenFunctions.Found error on Line no 20 and column no at 1.
$this->assertArrayHasKey( 20, $errors['load.php'] );
$this->assertArrayHasKey( 1, $errors['load.php'][20] );
$this->assertArrayHasKey( 'code', $errors['load.php'][20][1][0] );
$this->assertEquals( 'Generic.PHP.ForbiddenFunctions.Found', $errors['load.php'][20][1][0]['code'] );
}

public function test_run_without_errors() {
Expand Down

0 comments on commit 6f574ea

Please sign in to comment.