You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using filter_input with INPUT_GET or INPUT_POST or INPUT_COOKIE, it's like accessing the $_GET/$_POST superglobals.
Therefore a nonce validation is required.
Minimal Code Snippet
The issue happens when running this command:
./bin/phpcs --config-set installed_paths ../wpcs
... over a file containing this code:
// should report an error$foo = filter_input( INPUT_POST, 'email', FILTER_SANITIZE_EMAIL );
update_option( 'abc', $foo, false );
// correctly reports an error:$foo = $_POST['email'];
update_option( 'def', $foo, false );
Just saw that this was requested by @GaryJones when this rule was added initially: #325 (comment)
While back then someone said that filter_input was discouraged, using filter_input is actually the safer method, compared to (some) WP sanitizing functions, since the INPUT_ is out of scope of userland (e.g. $_POST['foo'] might have been modified somewhere/by any plugin already, while INPUT_POST, 'foo' is guaranteed to be unmodified) and some sanitizers are more secure than what WP can provide (e.g. for host names)
@johnstonphilip Please don't spam issues with "+1"'s which don't contribute anything useful to the discussion. You can use the emoji response on the first post for that.
Bug Description
When using filter_input with INPUT_GET or INPUT_POST or INPUT_COOKIE, it's like accessing the $_GET/$_POST superglobals.
Therefore a nonce validation is required.
Minimal Code Snippet
The issue happens when running this command:
... over a file containing this code:
Error Code
WordPress.Security.NonceVerification.Missing
Environment
Tested Against
develop
branch?develop
branch of WPCS.The text was updated successfully, but these errors were encountered: