Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated named functions and tests #594

Merged
merged 3 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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