{"action":"created","comment":{"url":"https://api.github.com/repos/requests/toolbelt/pulls/comments/223984069","pull_request_review_id":163241167,"id":223984069,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMzk4NDA2OQ==","diff_hunk":"@@ -3,19 +3,116 @@\n \n from requests import compat\n \n-\n-__all__ = ('dump_response', 'dump_all')\n+__all__ = ('dump_response', 'dump_all', 'Sanitizer', 'HeaderSanitizer')\n \n HTTP_VERSIONS = {\n     9: b'0.9',\n     10: b'1.0',\n     11: b'1.1',\n }\n \n+#: List of sensitive headers copied from\n+#: https://github.com/google/har-sanitizer\n+SENSITIVE_HEADERS = {\n+    \"state\",\n+    \"shdf\",\n+    \"usg\",\n+    \"password\",\n+    \"email\",\n+    \"code\",\n+    \"code_verifier\",\n+    \"client_secret\",\n+    \"client_id\",\n+    \"token\",\n+    \"access_token\",\n+    \"authenticity_token\",\n+    \"id_token\",\n+    \"appid\",\n+    \"challenge\",\n+    \"facetid\",\n+    \"assertion\",\n+    \"fcparams\",\n+    \"serverdata\",\n+    \"authorization\",\n+    \"auth\",\n+    \"x-client-data\",\n+    \"samlrequest\",\n+    \"samlresponse\"\n+}\n+\n _PrefixSettings = collections.namedtuple('PrefixSettings',\n                                          ['request', 'response'])\n \n \n+class Sanitizer(object):\n+    \"\"\"Performs no sanitation\"\"\"\n+\n+    def request_header(self, name, value):\n+        \"\"\"Sanitize a request header\n+\n+        :param name: The header name\n+        :type name: `compat.basestring`","path":"requests_toolbelt/utils/dump.py","position":54,"original_position":54,"commit_id":"4cf2eabedcfbab6b5f93dd708e7af6427a286e78","original_commit_id":"4cf2eabedcfbab6b5f93dd708e7af6427a286e78","user":{"login":"mortenlj","id":746078,"node_id":"MDQ6VXNlcjc0NjA3OA==","avatar_url":"https://avatars0.githubusercontent.com/u/746078?v=4","gravatar_id":"","url":"https://api.github.com/users/mortenlj","html_url":"https://github.com/mortenlj","followers_url":"https://api.github.com/users/mortenlj/followers","following_url":"https://api.github.com/users/mortenlj/following{/other_user}","gists_url":"https://api.github.com/users/mortenlj/gists{/gist_id}","starred_url":"https://api.github.com/users/mortenlj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mortenlj/subscriptions","organizations_url":"https://api.github.com/users/mortenlj/orgs","repos_url":"https://api.github.com/users/mortenlj/repos","events_url":"https://api.github.com/users/mortenlj/events{/privacy}","received_events_url":"https://api.github.com/users/mortenlj/received_events","type":"User","site_admin":false},"body":"So `requests.compat.basestring` is probably the most correct thing to use then?","created_at":"2018-10-10T08:38:46Z","updated_at":"2018-10-10T08:38:47Z","html_url":"https://github.com/requests/toolbelt/pull/227#discussion_r223984069","pull_request_url":"https://api.github.com/repos/requests/toolbelt/pulls/227","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/requests/toolbelt/pulls/comments/223984069"},"html":{"href":"https://github.com/requests/toolbelt/pull/227#discussion_r223984069"},"pull_request":{"href":"https://api.github.com/repos/requests/toolbelt/pulls/227"}},"in_reply_to_id":223069891},"pull_request":{"url":"https://api.github.com/repos/requests/toolbelt/pulls/227","id":220612192,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIwNjEyMTky","html_url":"https://github.com/requests/toolbelt/pull/227","diff_url":"https://github.com/requests/toolbelt/pull/227.diff","patch_url":"https://github.com/requests/toolbelt/pull/227.patch","issue_url":"https://api.github.com/repos/requests/toolbelt/issues/227","number":227,"state":"open","locked":false,"title":"Allow users to manipulate data before dumping","user":{"login":"mortenlj","id":746078,"node_id":"MDQ6VXNlcjc0NjA3OA==","avatar_url":"https://avatars0.githubusercontent.com/u/746078?v=4","gravatar_id":"","url":"https://api.github.com/users/mortenlj","html_url":"https://github.com/mortenlj","followers_url":"https://api.github.com/users/mortenlj/followers","following_url":"https://api.github.com/users/mortenlj/following{/other_user}","gists_url":"https://api.github.com/users/mortenlj/gists{/gist_id}","starred_url":"https://api.github.com/users/mortenlj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mortenlj/subscriptions","organizations_url":"https://api.github.com/users/mortenlj/orgs","repos_url":"https://api.github.com/users/mortenlj/repos","events_url":"https://api.github.com/users/mortenlj/events{/privacy}","received_events_url":"https://api.github.com/users/mortenlj/received_events","type":"User","site_admin":false},"body":"Dumping the request/response is useful for debugging, but that means\r\nthe data usually will end up in logfiles or other places. Since many\r\nrequests or responses will contain sensitive data (authentication\r\ntokens, username, cookies etc), it is sometimes necessary to redact some\r\nof that information before dumping it. This implementation provides a\r\nway to supply your own sanitizer, or use the provided sanitizer which\r\nwill redact information in a number of known sensitive headers.\r\n\r\nCloses #226","created_at":"2018-10-05T07:41:46Z","updated_at":"2018-10-10T08:38:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"981b48e939736027371a943c058241f50f5bdda5","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/requests/toolbelt/pulls/227/commits","review_comments_url":"https://api.github.com/repos/requests/toolbelt/pulls/227/comments","review_comment_url":"https://api.github.com/repos/requests/toolbelt/pulls/comments{/number}","comments_url":"https://api.github.com/repos/requests/toolbelt/issues/227/comments","statuses_url":"https://api.github.com/repos/requests/toolbelt/statuses/4cf2eabedcfbab6b5f93dd708e7af6427a286e78","head":{"label":"mortenlj:feature/redact-sensitive-headers","ref":"feature/redact-sensitive-headers","sha":"4cf2eabedcfbab6b5f93dd708e7af6427a286e78","user":{"login":"mortenlj","id":746078,"node_id":"MDQ6VXNlcjc0NjA3OA==","avatar_url":"https://avatars0.githubusercontent.com/u/746078?v=4","gravatar_id":"","url":"https://api.github.com/users/mortenlj","html_url":"https://github.com/mortenlj","followers_url":"https://api.github.com/users/mortenlj/followers","following_url":"https://api.github.com/users/mortenlj/following{/other_user}","gists_url":"https://api.github.com/users/mortenlj/gists{/gist_id}","starred_url":"https://api.github.com/users/mortenlj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mortenlj/subscriptions","organizations_url":"https://api.github.com/users/mortenlj/orgs","repos_url":"https://api.github.com/users/mortenlj/repos","events_url":"https://api.github.com/users/mortenlj/events{/privacy}","received_events_url":"https://api.github.com/users/mortenlj/received_events","type":"User","site_admin":false},"repo":{"id":151407649,"node_id":"MDEwOlJlcG9zaXRvcnkxNTE0MDc2NDk=","name":"toolbelt","full_name":"mortenlj/toolbelt","private":false,"owner":{"login":"mortenlj","id":746078,"node_id":"MDQ6VXNlcjc0NjA3OA==","avatar_url":"https://avatars0.githubusercontent.com/u/746078?v=4","gravatar_id":"","url":"https://api.github.com/users/mortenlj","html_url":"https://github.com/mortenlj","followers_url":"https://api.github.com/users/mortenlj/followers","following_url":"https://api.github.com/users/mortenlj/following{/other_user}","gists_url":"https://api.github.com/users/mortenlj/gists{/gist_id}","starred_url":"https://api.github.com/users/mortenlj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mortenlj/subscriptions","organizations_url":"https://api.github.com/users/mortenlj/orgs","repos_url":"https://api.github.com/users/mortenlj/repos","events_url":"https://api.github.com/users/mortenlj/events{/privacy}","received_events_url":"https://api.github.com/users/mortenlj/received_events","type":"User","site_admin":false},"html_url":"https://github.com/mortenlj/toolbelt","description":"A toolbelt of useful classes and functions to be used with python-requests","fork":true,"url":"https://api.github.com/repos/mortenlj/toolbelt","forks_url":"https://api.github.com/repos/mortenlj/toolbelt/forks","keys_url":"https://api.github.com/repos/mortenlj/toolbelt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mortenlj/toolbelt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mortenlj/toolbelt/teams","hooks_url":"https://api.github.com/repos/mortenlj/toolbelt/hooks","issue_events_url":"https://api.github.com/repos/mortenlj/toolbelt/issues/events{/number}","events_url":"https://api.github.com/repos/mortenlj/toolbelt/events","assignees_url":"https://api.github.com/repos/mortenlj/toolbelt/assignees{/user}","branches_url":"https://api.github.com/repos/mortenlj/toolbelt/branches{/branch}","tags_url":"https://api.github.com/repos/mortenlj/toolbelt/tags","blobs_url":"https://api.github.com/repos/mortenlj/toolbelt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mortenlj/toolbelt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mortenlj/toolbelt/git/refs{/sha}","trees_url":"https://api.github.com/repos/mortenlj/toolbelt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mortenlj/toolbelt/statuses/{sha}","languages_url":"https://api.github.com/repos/mortenlj/toolbelt/languages","stargazers_url":"https://api.github.com/repos/mortenlj/toolbelt/stargazers","contributors_url":"https://api.github.com/repos/mortenlj/toolbelt/contributors","subscribers_url":"https://api.github.com/repos/mortenlj/toolbelt/subscribers","subscription_url":"https://api.github.com/repos/mortenlj/toolbelt/subscription","commits_url":"https://api.github.com/repos/mortenlj/toolbelt/commits{/sha}","git_commits_url":"https://api.github.com/repos/mortenlj/toolbelt/git/commits{/sha}","comments_url":"https://api.github.com/repos/mortenlj/toolbelt/comments{/number}","issue_comment_url":"https://api.github.com/repos/mortenlj/toolbelt/issues/comments{/number}","contents_url":"https://api.github.com/repos/mortenlj/toolbelt/contents/{+path}","compare_url":"https://api.github.com/repos/mortenlj/toolbelt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mortenlj/toolbelt/merges","archive_url":"https://api.github.com/repos/mortenlj/toolbelt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mortenlj/toolbelt/downloads","issues_url":"https://api.github.com/repos/mortenlj/toolbelt/issues{/number}","pulls_url":"https://api.github.com/repos/mortenlj/toolbelt/pulls{/number}","milestones_url":"https://api.github.com/repos/mortenlj/toolbelt/milestones{/number}","notifications_url":"https://api.github.com/repos/mortenlj/toolbelt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mortenlj/toolbelt/labels{/name}","releases_url":"https://api.github.com/repos/mortenlj/toolbelt/releases{/id}","deployments_url":"https://api.github.com/repos/mortenlj/toolbelt/deployments","created_at":"2018-10-03T12:17:49Z","updated_at":"2018-10-03T12:17:51Z","pushed_at":"2018-10-05T07:39:43Z","git_url":"git://github.com/mortenlj/toolbelt.git","ssh_url":"git@github.com:mortenlj/toolbelt.git","clone_url":"https://github.com/mortenlj/toolbelt.git","svn_url":"https://github.com/mortenlj/toolbelt","homepage":"https://toolbelt.readthedocs.org","size":647,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"NOASSERTION","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"requests:master","ref":"master","sha":"0fe365e2934621ba0d7db546d4fd3e4f25354b4c","user":{"login":"requests","id":2805331,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4MDUzMzE=","avatar_url":"https://avatars1.githubusercontent.com/u/2805331?v=4","gravatar_id":"","url":"https://api.github.com/users/requests","html_url":"https://github.com/requests","followers_url":"https://api.github.com/users/requests/followers","following_url":"https://api.github.com/users/requests/following{/other_user}","gists_url":"https://api.github.com/users/requests/gists{/gist_id}","starred_url":"https://api.github.com/users/requests/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/requests/subscriptions","organizations_url":"https://api.github.com/users/requests/orgs","repos_url":"https://api.github.com/users/requests/repos","events_url":"https://api.github.com/users/requests/events{/privacy}","received_events_url":"https://api.github.com/users/requests/received_events","type":"Organization","site_admin":false},"repo":{"id":15515181,"node_id":"MDEwOlJlcG9zaXRvcnkxNTUxNTE4MQ==","name":"toolbelt","full_name":"requests/toolbelt","private":false,"owner":{"login":"requests","id":2805331,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4MDUzMzE=","avatar_url":"https://avatars1.githubusercontent.com/u/2805331?v=4","gravatar_id":"","url":"https://api.github.com/users/requests","html_url":"https://github.com/requests","followers_url":"https://api.github.com/users/requests/followers","following_url":"https://api.github.com/users/requests/following{/other_user}","gists_url":"https://api.github.com/users/requests/gists{/gist_id}","starred_url":"https://api.github.com/users/requests/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/requests/subscriptions","organizations_url":"https://api.github.com/users/requests/orgs","repos_url":"https://api.github.com/users/requests/repos","events_url":"https://api.github.com/users/requests/events{/privacy}","received_events_url":"https://api.github.com/users/requests/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/requests/toolbelt","description":"A toolbelt of useful classes and functions to be used with python-requests","fork":false,"url":"https://api.github.com/repos/requests/toolbelt","forks_url":"https://api.github.com/repos/requests/toolbelt/forks","keys_url":"https://api.github.com/repos/requests/toolbelt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/requests/toolbelt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/requests/toolbelt/teams","hooks_url":"https://api.github.com/repos/requests/toolbelt/hooks","issue_events_url":"https://api.github.com/repos/requests/toolbelt/issues/events{/number}","events_url":"https://api.github.com/repos/requests/toolbelt/events","assignees_url":"https://api.github.com/repos/requests/toolbelt/assignees{/user}","branches_url":"https://api.github.com/repos/requests/toolbelt/branches{/branch}","tags_url":"https://api.github.com/repos/requests/toolbelt/tags","blobs_url":"https://api.github.com/repos/requests/toolbelt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/requests/toolbelt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/requests/toolbelt/git/refs{/sha}","trees_url":"https://api.github.com/repos/requests/toolbelt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/requests/toolbelt/statuses/{sha}","languages_url":"https://api.github.com/repos/requests/toolbelt/languages","stargazers_url":"https://api.github.com/repos/requests/toolbelt/stargazers","contributors_url":"https://api.github.com/repos/requests/toolbelt/contributors","subscribers_url":"https://api.github.com/repos/requests/toolbelt/subscribers","subscription_url":"https://api.github.com/repos/requests/toolbelt/subscription","commits_url":"https://api.github.com/repos/requests/toolbelt/commits{/sha}","git_commits_url":"https://api.github.com/repos/requests/toolbelt/git/commits{/sha}","comments_url":"https://api.github.com/repos/requests/toolbelt/comments{/number}","issue_comment_url":"https://api.github.com/repos/requests/toolbelt/issues/comments{/number}","contents_url":"https://api.github.com/repos/requests/toolbelt/contents/{+path}","compare_url":"https://api.github.com/repos/requests/toolbelt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/requests/toolbelt/merges","archive_url":"https://api.github.com/repos/requests/toolbelt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/requests/toolbelt/downloads","issues_url":"https://api.github.com/repos/requests/toolbelt/issues{/number}","pulls_url":"https://api.github.com/repos/requests/toolbelt/pulls{/number}","milestones_url":"https://api.github.com/repos/requests/toolbelt/milestones{/number}","notifications_url":"https://api.github.com/repos/requests/toolbelt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/requests/toolbelt/labels{/name}","releases_url":"https://api.github.com/repos/requests/toolbelt/releases{/id}","deployments_url":"https://api.github.com/repos/requests/toolbelt/deployments","created_at":"2013-12-29T21:19:08Z","updated_at":"2018-10-10T03:07:28Z","pushed_at":"2018-10-09T19:58:06Z","git_url":"git://github.com/requests/toolbelt.git","ssh_url":"git@github.com:requests/toolbelt.git","clone_url":"https://github.com/requests/toolbelt.git","svn_url":"https://github.com/requests/toolbelt","homepage":"https://toolbelt.readthedocs.org","size":645,"stargazers_count":489,"watchers_count":489,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":98,"mirror_url":null,"archived":false,"open_issues_count":38,"license":{"key":"other","name":"NOASSERTION","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":98,"open_issues":38,"watchers":489,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/requests/toolbelt/pulls/227"},"html":{"href":"https://github.com/requests/toolbelt/pull/227"},"issue":{"href":"https://api.github.com/repos/requests/toolbelt/issues/227"},"comments":{"href":"https://api.github.com/repos/requests/toolbelt/issues/227/comments"},"review_comments":{"href":"https://api.github.com/repos/requests/toolbelt/pulls/227/comments"},"review_comment":{"href":"https://api.github.com/repos/requests/toolbelt/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/requests/toolbelt/pulls/227/commits"},"statuses":{"href":"https://api.github.com/repos/requests/toolbelt/statuses/4cf2eabedcfbab6b5f93dd708e7af6427a286e78"}},"author_association":"NONE"}}
{"actor":{"display_login":"mortenlj"}}