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
{{ message }}
Repository navigation
Forbid pseudo-header fields not defined in RFC 7540 #193
For anyone who picks this up, here are my thoughts about how you might want to approach this:
The easiest place to fit this in to the code is the current header validation pipeline. This lives in h2/utilities.py, and is currently composed of a pipeline of generators as shown in validate_headers in that file. In particular, a small extension to _reject_pseudo_header_fields is probably the right place to start looking to do the change.
For filtering things out, consider using an approach similar to the CONNECTION_HEADERS approach in that same file: a set() of whitelisted values.
We'll need to write tests for this. A sensible approach might be to use Hypothesis to generate those tests, but that may also be tricky for you, so if you don't want to bite that off right now just write some standard examples-based tests and put them in test_invalid_headers.TestFilter. I can go back and extend them later.
You don't need to do any backporting, I'll handle that.
If you have any further questions, please do ask them.
@Lukasa Could you take a look at my solution? I'm happy to evolve it into something better using the Hypothesis package, and I don't understand what you mean by backporting, but would be happy to know and help out more 😄
@LuRsT That change looks perfect. One small note: I'm about to merge a PR (#198) that changes our internal headers representation to be bytestrings. That'll necessitate a small update in your code: you'll need to use bytestrings in that set.
Otherwise, that looks great: with some tests I'd be happy to merge it. =)
Awesome @Lukasa, I'll learn about hypothesis this evening so I can use it for the tests. I'll also update my code to use bytestrings.
One thing that I wasn't sure is the _ALLOWED_PSEUDO_HEADER_FIELDS, I don't know if I captured all the pseudo-header fields from the spec, I was expecting to find a list of them but I couldn't :/
Activity
Lukasa commentedon Apr 13, 2016
For anyone who picks this up, here are my thoughts about how you might want to approach this:
h2/utilities.py, and is currently composed of a pipeline of generators as shown invalidate_headersin that file. In particular, a small extension to_reject_pseudo_header_fieldsis probably the right place to start looking to do the change.CONNECTION_HEADERSapproach in that same file: aset()of whitelisted values.test_invalid_headers.TestFilter. I can go back and extend them later.If you have any further questions, please do ask them.
LuRsT commentedon Apr 13, 2016
@Lukasa Could you take a look at my solution? I'm happy to evolve it into something better using the
Hypothesispackage, and I don't understand what you mean by backporting, but would be happy to know and help out more 😄Lukasa commentedon Apr 14, 2016
@LuRsT That change looks perfect. One small note: I'm about to merge a PR (#198) that changes our internal headers representation to be bytestrings. That'll necessitate a small update in your code: you'll need to use bytestrings in that set.
Otherwise, that looks great: with some tests I'd be happy to merge it. =)
LuRsT commentedon Apr 14, 2016
Awesome @Lukasa, I'll learn about
hypothesisthis evening so I can use it for the tests. I'll also update my code to use bytestrings.One thing that I wasn't sure is the
_ALLOWED_PSEUDO_HEADER_FIELDS, I don't know if I captured all the pseudo-header fields from the spec, I was expecting to find a list of them but I couldn't :/Lukasa commentedon Apr 14, 2016
Yeah, there is no single list, but sections 8.1.2.3 and 8.1.2.4 cover the full set. You got them. =)
Disallow custom pseudo-headers
Disallow custom pseudo-headers
Disallow custom pseudo-headers