Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require unlashing of input superglobals #395

Merged
merged 1 commit into from
Jun 1, 2015
Merged

Require unlashing of input superglobals #395

merged 1 commit into from
Jun 1, 2015

Conversation

JDGrimes
Copy link
Contributor

This updates the validated/sanitized input sniff to also check for
slashing. This could have been made into another sniff instead,
however, it would have required lots of duplicated logic and this sniff
would need to be updated to accommodate the use of wp_unslash()
anyway.

Currently only wp_unslash() is recognized as an unlashing function,
but this can be changed in the future if needed.

The sniff currently requires that wp_unslash() be used before the
data is passed through a sanitizing function. Sanitizing first and then
wrapping that in wp_unslash() is not accepted.

The error for missing the use of wp_unslash() is independent of the
missing sanitizing function error, so an error will be given for
missing use of an unslashing function whether or not a sanitizing
function is used, and vice versa.

Unslashing is not required when sanitization is provided via casting,
or when certain sanitization functions are used which implicitly or
explicitly perform an unslash or for which unslashing isn’t necessary.
absint() implicitly unslashes, and sanitize_key() will remove
slashes explicitly. And unslashing isn’t necessary when testing a value
with is_array(). This list can be expanded in the future, and is
configurable via the customUnslashingSanitizingFunctions property.

See #172

This updates the validated/sanitized input sniff to also check for
slashing. This could have been made into another sniff instead,
however, it would have required lots of duplicated logic and this sniff
would need to be updated to accommodate the use of `wp_unslash()`
anyway.

Currently only `wp_unslash()` is recognized as an unlashing function,
but this can be changed in the future if needed.

The sniff currently requires that `wp_unslash()` be used *before* the
data is passed through a sanitizing function. Sanitizing first and then
wrapping that in `wp_unslash()` is not accepted.

The error for missing the use of `wp_unslash()` is independent of the
missing sanitizing function error, so an error will be given for
missing use of an unslashing function whether or not a sanitizing
function is used, and vice versa.

Unslashing is not required when sanitization is provided via casting,
or when certain sanitization functions are used which implicitly or
explicitly perform an unslash or for which unslashing isn’t necessary.
`absint()` implicitly unslashes, and `sanitize_key()` will remove
slashes explicitly. And unslashing isn’t necessary when testing a value
with `is_array()`. This list can be expanded in the future, and is
configurable via the `customUnslashingSanitizingFunctions` property.

See #172
@JDGrimes JDGrimes added this to the 0.5.0 milestone May 30, 2015
@GaryJones
Copy link
Member

I don't see any $_POST or $_GET values being assigned with explicitly slashes values / values that would become slashed, and checked in tests? Not necessarily to unit test the functionality of wp_unslash() but to integration test with different data for our existing tests.

@JDGrimes
Copy link
Contributor Author

@GaryJones I'm not sure I follow. There are some places where wp_unslash() is not used, to test that the error is given, if that's what you mean.

@GaryJones
Copy link
Member

Nevermind - think I'm confusing myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants