Sync: Provide explanation on missing nonce verifications - #37402
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped. |
anomiex
left a comment
There was a problem hiding this comment.
I left some copy edits and suggestions inline. Feel free to disagree, maybe I want to be a little too explicit in the reasoning. 😅
| public function is_gutenberg_meta_box_update() { | ||
| // phpcs:disable WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended | ||
| private function is_gutenberg_meta_box_update() { | ||
| // phpcs:disable WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended -- We are using $_POST['action'] to detect if this is a Gutenberg meta box update. |
There was a problem hiding this comment.
I'd say more like this
| // phpcs:disable WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended -- We are using $_POST['action'] to detect if this is a Gutenberg meta box update. | |
| // phpcs:disable WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended -- Nonce checking, if necessary, is the responsibility of the caller. We can't know here what the caller is going to do with the return value. |
And possibly also put a note in the function's doc block about the caller being responsible for checking a nonce if necessary.
There was a problem hiding this comment.
hmm if this becomes a private method we can be more explicit here I think and mention that we are only using it to detect if this is a Gutenberg meta box update and set a flag before sending the corresponding action to wpcom?
There was a problem hiding this comment.
I updated it based on the above, however feel free to suggest and commit any alternative explanation you feel is better :)
Co-authored-by: Brad Jorsch <anomiex@users.noreply.github.com>
Co-authored-by: Brad Jorsch <anomiex@users.noreply.github.com>
Co-authored-by: Brad Jorsch <anomiex@users.noreply.github.com>
Co-authored-by: Brad Jorsch <anomiex@users.noreply.github.com>
Co-authored-by: Brad Jorsch <anomiex@users.noreply.github.com>
anomiex
left a comment
There was a problem hiding this comment.
LGTM. Haven't tested it though.
We are adding explanations inside the Sync package when nonce verification is missing.
Proposed changes:
phpcs:ignore WordPress.Security.NonceVerification.Missingignore rules for missing nonce verification with an explanation on why it's ok to skip it.Other information:
Jetpack product discussion
p9dueE-8ca-p2
Does this pull request change what data or activity we track or use?
No
Testing instructions: