WordPress / WordPress/plugin-check-action
Add to settings custom nonce function
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 129
- Forks
- 17
- PR merge metrics
- No merged PRs in 30d
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the plugin-check-action path that invokes PHPCS and the handling of the customNonceVerificationFunctions setting. Trace how functions such as is_valid_nonce() are identified, then define the setting and warning behavior needed so valid custom nonce checks no longer produce WordPress.Security.NonceVerification.Missing warnings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, typescript, wordpress
- Domain
- security, tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100