-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
cherrypy: fix handling of raw application/x-www-form-urlencoded traffic #54901
Merged
dwoz
merged 14 commits into
saltstack:master
from
nicholasmhughes:fix_cherrypy_urlencoded_rawbody2
Aug 6, 2020
Merged
cherrypy: fix handling of raw application/x-www-form-urlencoded traffic #54901
dwoz
merged 14 commits into
saltstack:master
from
nicholasmhughes:fix_cherrypy_urlencoded_rawbody2
Aug 6, 2020
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dwoz
requested changes
Oct 7, 2019
@dwoz added test and all tests passing |
@dwoz @sagetherage assuming these tests pass (I'm going to bed), can this PR get some love? I think we're coming up on 11 months from the original PR date and I keep having to track to new formats and tests. |
dwoz
approved these changes
Aug 6, 2020
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
handle the preservation of raw application/x-www-form-urlencoded traffic in cherrypy
What issues does this PR fix or reference?
N/A
Previous Behavior
cherrypy natively parsed the incoming x-www-form-urlencoded traffic into a dictionary, which was then put into the
post
key when the event fired. theraw_body
was manually set to an empty string, because cherrypy will leaveraw_body
asNone
when parsing x-www-form-urlencoded traffic. therefore, thebody
key of the event was always an empty string in the case of x-www-form-urlencoded traffic, where that key would normally contain the raw request when processing other types of traffic.I consider this "broken" because it doesn't provide a way to handle the raw data at all when parsing x-www-form-urlencoded traffic. This functionality is required when attempting to validate Slack webhooks since the raw x-www-form-urlencoded string is hashed for a signature and cannot be deserialized because it will destroy the order of the parameters and provide no mechanism to validate the traffic.
New Behavior
instead of using the native cherrypy parsing, which throws away the raw request when creating the
params
dictionary, we read the raw data into a string (which ends up in thebody
key in the event) and then perform manual parsing of the tokens into a dictionary using parse_qsl to set the contents of thepost
key in the event. since thepost
key output functionality isn't changed and thebody
key was always empty and therefore wasn't relied on, this is a low impact change.Tests written?
Yes
Commits signed with GPG?
Yes