|
| 1 | +<?xml version="1.0"?> |
| 2 | +<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WPPluginCheck" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd"> |
| 3 | + |
| 4 | + <!-- For more information: https://make.wordpress.org/plugins/handbook/review/ --> |
| 5 | + <description>Standards any plugin to be published on wordpress.org should comply with.</description> |
| 6 | + |
| 7 | + <!-- All SQL queries should be prepared as close to the time of querying the database as possible. --> |
| 8 | + <rule ref="WordPress.DB.PreparedSQL"/> |
| 9 | + <rule ref="WordPress.DB.PreparedSQL.InterpolatedNotPrepared"> |
| 10 | + <!-- Ideally this wouldn't trigger on "safe" items, but it's triggered on any variable in the SQL. --> |
| 11 | + <type>warning</type> |
| 12 | + </rule> |
| 13 | + |
| 14 | + <!-- Verify that placeholders in prepared queries are used correctly. --> |
| 15 | + <rule ref="WordPress.DB.PreparedSQLPlaceholders"/> |
| 16 | + |
| 17 | + <!-- Nonces. These are triggered on any GET/POST access items. --> |
| 18 | + <rule ref="WordPress.Security.NonceVerification"> |
| 19 | + <!-- This is triggered on all GET/POST access, it can't be an error. --> |
| 20 | + <type>warning</type> |
| 21 | + </rule> |
| 22 | + |
| 23 | + <!-- Sanitized Input rules --> |
| 24 | + <rule ref="WordPress.Security.ValidatedSanitizedInput"> |
| 25 | + <type>warning</type> |
| 26 | + </rule> |
| 27 | + |
| 28 | + <!-- Prohibit the use of the backtick operator. --> |
| 29 | + <rule ref="Generic.PHP.BacktickOperator"> |
| 30 | + <severity>7</severity> |
| 31 | + </rule> |
| 32 | + |
| 33 | + <!-- Prohibit the use of HEREDOC or NOWDOC. --> |
| 34 | + <rule ref="Squiz.PHP.Heredoc"> |
| 35 | + <severity>7</severity> |
| 36 | + </rule> |
| 37 | + |
| 38 | + <!-- Prohibit the use of the `goto` PHP language construct. --> |
| 39 | + <rule ref="Generic.PHP.DiscourageGoto.Found"> |
| 40 | + <type>error</type> |
| 41 | + <severity>7</severity> |
| 42 | + <message>The "goto" language construct should not be used.</message> |
| 43 | + </rule> |
| 44 | + |
| 45 | + <!-- Check for error logs in plugin --> |
| 46 | + <rule ref="WordPress.PHP.DevelopmentFunctions"> |
| 47 | + <type>warning</type> |
| 48 | + </rule> |
| 49 | + |
| 50 | + <!-- No PHP short open tags allowed. --> |
| 51 | + <rule ref="Generic.PHP.DisallowShortOpenTag"/> |
| 52 | + <rule ref="Generic.PHP.DisallowShortOpenTag.Found"> |
| 53 | + <severity>7</severity> |
| 54 | + </rule> |
| 55 | + <rule ref="Generic.PHP.DisallowShortOpenTag.EchoFound"> |
| 56 | + <severity>7</severity> |
| 57 | + </rule> |
| 58 | + |
| 59 | + <!-- Alternative PHP open tags not allowed. --> |
| 60 | + <rule ref="Generic.PHP.DisallowAlternativePHPTags"> |
| 61 | + <severity>7</severity> |
| 62 | + </rule> |
| 63 | + |
| 64 | + <!-- Prevent path disclosure when using add_theme_page(). --> |
| 65 | + <rule ref="WordPress.Security.PluginMenuSlug"> |
| 66 | + <severity>6</severity> |
| 67 | + </rule> |
| 68 | + |
| 69 | + <!-- While most plugins shouldn't query the database directly, if they do, it should be done correctly. --> |
| 70 | + <!-- Don't use the PHP database functions and classes, use the WP abstraction layer instead. --> |
| 71 | + <rule ref="WordPress.DB.RestrictedClasses"> |
| 72 | + <severity>7</severity> |
| 73 | + </rule> |
| 74 | + |
| 75 | + <rule ref="WordPress.DB.RestrictedFunctions"> |
| 76 | + <severity>7</severity> |
| 77 | + </rule> |
| 78 | + |
| 79 | + <!-- Check for code WP does better --> |
| 80 | + <rule ref="WordPress.WP.AlternativeFunctions"> |
| 81 | + <type>error</type> |
| 82 | + <exclude name="WordPress.WP.AlternativeFunctions.json_encode_json_encode"/> |
| 83 | + <exclude name="WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents"/> |
| 84 | + <exclude name="WordPress.WP.AlternativeFunctions.file_system_operations_file_put_contents"/> |
| 85 | + </rule> |
| 86 | + |
| 87 | + <rule ref="Generic.PHP.ForbiddenFunctions"> |
| 88 | + <properties> |
| 89 | + <property name="forbiddenFunctions" type="array"> |
| 90 | + <element key="move_uploaded_file" value="null"/> |
| 91 | + <element key="passthru" value="null"/> |
| 92 | + <element key="proc_open" value="null"/> |
| 93 | + <element key="create_function" value="null"/> |
| 94 | + <element key="eval" value="null"/> |
| 95 | + <element key="str_rot13" value="null"/> |
| 96 | + </property> |
| 97 | + </properties> |
| 98 | + <type>error</type> |
| 99 | + <severity>7</severity> |
| 100 | + </rule> |
| 101 | + |
| 102 | + <rule ref="Squiz.PHP.DiscouragedFunctions"> |
| 103 | + <properties> |
| 104 | + <property name="forbiddenFunctions" type="array"> |
| 105 | + <element key="set_time_limit" value="null"/> |
| 106 | + <element key="ini_set" value="null"/> |
| 107 | + <element key="ini_alter" value="null"/> |
| 108 | + <element key="dl" value="null"/> |
| 109 | + </property> |
| 110 | + </properties> |
| 111 | + </rule> |
| 112 | + |
| 113 | + <!-- Check for use of deprecated WordPress classes, functions and function parameters. --> |
| 114 | + <rule ref="WordPress.WP.DeprecatedClasses"/> |
| 115 | + <rule ref="WordPress.WP.DeprecatedFunctions"/> |
| 116 | + <rule ref="WordPress.WP.DeprecatedParameters"/> |
| 117 | + <rule ref="WordPress.DateTime.RestrictedFunctions"/> |
| 118 | + |
| 119 | + <!-- Check for deprecated WordPress constants. --> |
| 120 | + <rule ref="WordPress.WP.DiscouragedConstants"> |
| 121 | + <type>error</type> |
| 122 | + <severity>7</severity> |
| 123 | + </rule> |
| 124 | + |
| 125 | + <!-- Check for discouraged WordPress functions. --> |
| 126 | + <rule ref="WordPress.WP.DiscouragedFunctions"> |
| 127 | + <severity>6</severity> |
| 128 | + </rule> |
| 129 | + |
| 130 | + <!-- Check for usage of deprecated parameter values in WP functions and provide alternative based on the parameter passed. --> |
| 131 | + <rule ref="WordPress.WP.DeprecatedParameterValues"> |
| 132 | + <severity>7</severity> |
| 133 | + </rule> |
| 134 | + |
| 135 | + <!-- No ByteOrderMark allowed - important to prevent issues with content being sent before headers. --> |
| 136 | + <rule ref="Generic.Files.ByteOrderMark"> |
| 137 | + <severity>7</severity> |
| 138 | + </rule> |
| 139 | + |
| 140 | + <!-- Check for missing required function parameters. --> |
| 141 | + <rule ref="PluginCheck.CodeAnalysis.RequiredFunctionParameters"> |
| 142 | + <severity>7</severity> |
| 143 | + </rule> |
| 144 | + |
| 145 | + <!-- Check for discouraged load_plugin_textdomain() call. --> |
| 146 | + <rule ref="PluginCheck.CodeAnalysis.DiscouragedFunctions.load_plugin_textdomainFound"> |
| 147 | + <type>error</type> |
| 148 | + <severity>7</severity> |
| 149 | + </rule> |
| 150 | + |
| 151 | +</ruleset> |
0 commit comments