Repository navigation
Conversation
This file contains hidden or 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
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.
Problem
redact_header()only matched five exact header names (authorization,cookie,proxy-authorization,set-cookie,x-api-key). Any other credential header passed with-Hwas written verbatim into therequestfield of the output, which is meant to be shareable evidence.Before, with
-H "X-Auth-Token: s3cr3t" -H "Cookie: c=1":After:
Change
SENSITIVE_HEADER_PATTERNmatches credential-bearing name segments:auth,authorization,bearer,cookie,key,passwd,password,secret,session,token, plusapikey/accesskey. Segment boundaries keep ordinary headers such asX-Request-Id,X-Forwarded-For, andX-Keyboard-Layoutuntouched.is_sensitive_header()is the single predicate, used by bothredact_header()and the existing cross-origin redirect stripping insend_post(). A header worth hiding is also worth dropping when the scan follows a redirect to another host.SENSITIVE_HEADERSis kept as the exact-match base set.The pattern is name-based only. A credential carried in a header whose name has none of those markers (for example
X-Custom: Bearer ...) is still not detected; values are not inspected.Tests
Adds
tests/test_redaction.py, stdlibunittest, no new dependencies. It works withpython -m unittest discover -s testsand pytest.Coverage: credential headers detected, ordinary headers untouched,
redact_headerreplaces only the value, andrequest_dump()output contains no secret value for custom token headers.