plugin-check
plugin-check copied to clipboard
Create Nonce_Verification_Check
Description
Checks that nonce verification functions are used within form processing. This is a security check that ensures that core nonce functions are being used to verify the request to the server before processing. This will use the existing WordPress.Security.NonceVerification sniff in the WordPress Coding Standards.
Acceptance Criteria
- Class
Nonce_Verification_Checkshould be created and exists atincludes/Checker/Checks - Class
Nonce_Verification_Checkshould extend theAbstract_PHP_CodeSniffer_Checkabstract class - Class should implement the public
get_args()and return an associative array of the required PHPCS arguments'sniffs' => 'WordPress.Security.NonceVerification''standard' => 'WordPress'
- Add a sample code in the
tests/testdata/plugins/test-plugin-with-errors\test-plugin-with-errors.phpfile, which will come under theWordPress.Security.NonceVerificationerror.
Tests Coverage
@felixarntz I have updated AC for this epic. It is ready for review now. Thanks!
Looks like XML file has this ruled enabled already.
<!-- Nonces. These are triggered on any GET/POST access items. -->
<rule ref="WordPress.Security.NonceVerification">
<!-- This is triggered on all GET/POST access, it can't be an error. -->
<type>warning</type>
</rule>
When I try to add separate check for this rule WordPress.Security.NonceVerification is displaying duplicate messages for same errors.
Are we planning to create separate Check for this and remove the rule from XML file? Can someone please elaborate?
There are already WordPress.Security.NonceVerification.Missing errors being reported as part of the plugin_review_phpcs / Plugin_Review_PHPCS_Check check. No need to create a separate duplicate check for this.
So this is already WAI.