Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(wsgi): ensure HTTPS: on environ value does not get parsed as a he…
…ader (#6290) Fixes #6284 We have a check in the wsgi helper `get_request_header` which will try to extract any `environ` values starting with `HTTP` into headers, but `from_wsgi_header` will require that the input starts with `HTTP_`. This means if `environ` has `["HTTPS"] = "on"` then we would try to convert it, get `None` back and end up with a header key of `None` with the value `"on"`. This updates the caller of `from_wsgi_header` to check for `HTTP_` prefix, and test whether the resulting name is `None` or not. The Django integration also uses `from_wsgi_header`, but it's usage was already safe/checking the result for `None`, but we added an explicit test anyways. I also added additional type hinting to wsgi and Django to try and help catch this issue at development time. ## Checklist - [x] Change(s) are motivated and described in the PR description. - [x] Testing strategy is described if automated tests are not included in the PR. - [x] Risk is outlined (performance impact, potential for breakage, maintainability, etc). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed. If no release note is required, add label `changelog/no-changelog`. - [x] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)). - [x] Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [ ] Title is accurate. - [ ] No unnecessary changes are introduced. - [ ] Description motivates each change. - [ ] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes unless absolutely necessary. - [ ] Testing strategy adequately addresses listed risk(s). - [ ] Change is maintainable (easy to change, telemetry, documentation). - [ ] Release note makes sense to a user of the library. - [ ] Reviewer has explicitly acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment. - [ ] Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
- Loading branch information