-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from woocommerce/23-11/add-theme-self-tests
Added Theme self tests
- Loading branch information
Showing
88 changed files
with
4,703 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: QIT Self-Tests - Malware | ||
|
||
on: | ||
# Every day at 11am and 11pm UTC (6am and 6pm ET) | ||
schedule: | ||
- cron: '0 11 * * *' | ||
- cron: '0 23 * * *' | ||
# Manually | ||
workflow_dispatch: | ||
# On push to trunk | ||
push: | ||
branches: | ||
- trunk | ||
|
||
jobs: | ||
malware_tests: | ||
uses: ./.github/workflows/self-test-template.yml | ||
with: | ||
test_type: malware | ||
secrets: | ||
QIT_USER: ${{ secrets.QIT_USER }} | ||
QIT_ACCESS_TOKEN: ${{ secrets.QIT_ACCESS_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
return [ | ||
'php' => '8.2', | ||
'wp' => 'stable', | ||
'woo' => 'stable', | ||
]; |
13 changes: 13 additions & 0 deletions
13
_tests/activation/childtheme/wporg-theme-storefront/functions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
add_action( 'wp', static function () { | ||
if ( is_cart() ) { | ||
call_to_undefined_function(); | ||
} | ||
|
||
trigger_error( 'Warning on all requests - Child theme', E_USER_WARNING ); | ||
} ); | ||
|
||
add_action( 'init', static function() { | ||
trigger_error( 'Notice on all requests - Child theme' ); | ||
} ); |
7 changes: 7 additions & 0 deletions
7
_tests/activation/childtheme/wporg-theme-storefront/style.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
Theme Name: Storefront | ||
Theme URI: https://woocommerce.com/products/storefront/ | ||
Description: Storefront Theme. | ||
Template: twentytwentyfour | ||
Version: 1.0.0 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
return [ | ||
'php' => '8.2', | ||
'wp' => 'stable', | ||
'woo' => 'stable', | ||
]; |
13 changes: 13 additions & 0 deletions
13
_tests/activation/parenttheme/wporg-theme-storefront/functions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
add_action( 'wp', static function () { | ||
if ( is_cart() ) { | ||
call_to_undefined_function(); | ||
} | ||
|
||
trigger_error( 'Warning on all requests - Parent Theme', E_USER_WARNING ); | ||
} ); | ||
|
||
add_action( 'init', static function() { | ||
trigger_error( 'Notice on all requests - Parent Theme' ); | ||
} ); |
9 changes: 9 additions & 0 deletions
9
_tests/activation/parenttheme/wporg-theme-storefront/index.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
/** | ||
* The main template file. | ||
* | ||
* This is the most generic template file in a WordPress theme | ||
* and one of the two required files for a theme (the other being style.css). | ||
* It is used to display a page when nothing more specific matches a query. | ||
*/ | ||
|
6 changes: 6 additions & 0 deletions
6
_tests/activation/parenttheme/wporg-theme-storefront/style.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
Theme Name: Storefront | ||
Theme URI: https://woocommerce.com/products/storefront/ | ||
Description: Storefront Theme. | ||
Version: 1.0.0 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
return [ | ||
'php' => '8.2', | ||
'wp' => 'stable', | ||
'woo' => 'stable', | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
Theme Name: Storefront | ||
Theme URI: https://woocommerce.com/products/storefront/ | ||
Description: Storefront Theme. | ||
Template: twentytwentyfour | ||
Version: 1.0.0 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
return [ | ||
'php' => '8.2', | ||
'wp' => 'stable', | ||
'woo' => 'stable', | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
/** | ||
* The main template file. | ||
* | ||
* This is the most generic template file in a WordPress theme | ||
* and one of the two required files for a theme (the other being style.css). | ||
* It is used to display a page when nothing more specific matches a query. | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
Theme Name: Storefront | ||
Theme URI: https://woocommerce.com/products/storefront/ | ||
Description: Storefront Theme. | ||
Version: 1.0.0 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?php | ||
return []; |
7 changes: 7 additions & 0 deletions
7
_tests/malware/no_op/woocommerce-product-feeds/woocommerce-product-feeds.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
/* | ||
* Plugin name: Malware - No-op. | ||
*/ | ||
|
||
// No-op plugin. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?php | ||
return []; |
19 changes: 19 additions & 0 deletions
19
_tests/malware/violations/woocommerce-product-feeds/woocommerce-product-feeds.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
/* | ||
* Plugin name: Malware Violations | ||
* Description: This plugin contains multiple violations that should be flagged by the malware scanner | ||
*/ | ||
|
||
function dangerous_method( $handle ) { | ||
fpassthru( $handle ); | ||
} | ||
|
||
$dodgy_php = "SetHandler application/x-httpd-php"; | ||
$dodgy_string = ".bash_history"; | ||
|
||
// Check password | ||
if ( md5($_POST['password']) === 'd41d8cd98f00b204e9800998ecf8427e' ) { | ||
echo "Gotchya!"; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
return [ | ||
'params' => [ | ||
'--min_php_version' => '7.2', | ||
], | ||
]; |
86 changes: 86 additions & 0 deletions
86
_tests/phpcompatibility/childtheme/wporg-theme-storefront/front-page.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
// Requires PHP 7.0. | ||
$anonymousClass = new class {}; | ||
|
||
// Requires PHP 7.1. | ||
function voidReturnType(): void {} | ||
|
||
// Requires PHP 7.2. | ||
$object = new class { public const A = 'a'; }; | ||
$objectType = $object::A ?? 'default'; // Null coalescing operator with class constant | ||
|
||
// Requires PHP 7.3 (should be flagged since this plugin supports PHP 7.2). | ||
$result = my_function(1, 2, 3,); // Trailing comma in function call | ||
|
||
// Requires PHP 7.4 (should be flagged since this plugin supports PHP 7.2). | ||
$arrowFunction = fn($x) => $x + 1; | ||
|
||
// Requries PHP 8.0 (should not be flagged since this plugin does not support PHP 8.0). | ||
str_contains('hello world', 'world'); | ||
|
||
// Requires PHP 8.1 (should not be flagged since this plugin does not support PHP 8.1). | ||
class Bar { | ||
readonly string $foo; | ||
} | ||
|
||
// Requires PHP 8.2 (should not be flagged since this plugin does not support PHP 8.2). | ||
readonly class Foo { | ||
|
||
} | ||
|
||
// Deprecated in PHP 7.2 | ||
// The create_function() function is deprecated as of PHP 7.2. | ||
$newfunc = create_function('$a', 'return $a * 2;'); | ||
|
||
// Deprecated in PHP 7.2 | ||
// The __autoload function is deprecated in favor of spl_autoload_register. | ||
function __autoload($class) { | ||
include 'classes/' . $class . '.class.php'; | ||
} | ||
|
||
// Deprecated in PHP 7.3 | ||
// Deprecated flags for filter_var with FILTER_VALIDATE_URL. | ||
filter_var('http://example.com', FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED); | ||
|
||
// Deprecated in PHP 7.3 | ||
// Using implode() with the parameters in a non-canonical order is deprecated. | ||
implode($pieces, ''); | ||
|
||
// Deprecated in PHP 7.4 | ||
// Using curly braces for array and string offset access is deprecated. | ||
$array = [1, 2, 3]; | ||
$element = $array{0}; | ||
|
||
// Deprecated in PHP 7.4 | ||
// This function is deprecated. | ||
$magic_quotes = get_magic_quotes_gpc(); | ||
|
||
// PHP 8.0 Deprecations | ||
// Deprecated: Required parameters after optional parameters | ||
function exampleFunction($a = [], $b) {} | ||
|
||
// Deprecated: ReflectionParameter methods | ||
function deprecatedReflectionMethods(ReflectionParameter $param) { | ||
$param->getClass(); | ||
} | ||
|
||
// PHP 8.1 Deprecations | ||
// Deprecated: Passing null to non-nullable internal function parameters | ||
strlen(null); | ||
|
||
// Deprecated: Serializable interface | ||
class DeprecatedSerializable implements Serializable { | ||
public function serialize() {} | ||
public function unserialize($serialized) {} | ||
} | ||
|
||
// PHP 8.2 Deprecations | ||
// Deprecated: Dynamic Properties | ||
class ExampleClass {} | ||
$example = new ExampleClass; | ||
$example->dynamicProperty = 'Deprecated'; | ||
|
||
// Deprecated: utf8_encode and utf8_decode functions | ||
utf8_encode('Deprecated'); | ||
|
7 changes: 7 additions & 0 deletions
7
_tests/phpcompatibility/childtheme/wporg-theme-storefront/style.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
Theme Name: Storefront | ||
Theme URI: https://woocommerce.com/products/storefront/ | ||
Description: Storefront Theme. | ||
Template: twentytwentyfour | ||
Version: 1.0.0 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
return [ | ||
'params' => [ | ||
'--min_php_version' => '7.2', | ||
], | ||
]; |
9 changes: 9 additions & 0 deletions
9
_tests/phpcompatibility/parenttheme/wporg-theme-storefront/index.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
/** | ||
* The main template file. | ||
* | ||
* This is the most generic template file in a WordPress theme | ||
* and one of the two required files for a theme (the other being style.css). | ||
* It is used to display a page when nothing more specific matches a query. | ||
*/ | ||
|
Oops, something went wrong.