-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Labels
Description
Hi there,
In my WP plugin, I just added a custom function that checks the nonce:
/**
* Validate nonce
*
* @param string $nonce_action Action for nonce
* @param string $nonce_field Field name in $_POST or $_GET
* @return bool True if nonce is valid
*/
protected function is_valid_nonce( string $nonce_action, string $nonce_field ): bool {
return isset( $_POST[ $nonce_field ] ) && is_string( $_POST[ $nonce_field ] ) && wp_verify_nonce( sanitize_key( $_POST[ $nonce_field ] ), $nonce_action ) > 0;
}
}
With PHPCS, i just declared a property customNonceVerificationFunctions
, and it is correctly handled.
But with plugin-check-action, I don't know how tho handle this custom function, since in functions using is_valid_nonce()
, it triggers WordPress.Security.NonceVerification.Missing warning.
I can obviously avoid the warnings using ignore-codes
, but it doesn't seem to me a sustainable solution.