Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.

Commit d2176d8

Browse files
committed
Merge pull request #610 from tgwizard/sanitize-access-tokens
Sanitize access_token values
2 parents 12bb737 + 79c903c commit d2176d8

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ include/
2323
lib/
2424
.idea
2525
.eggs
26+
venv

raven/processors.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class SanitizePasswordsProcessor(Processor):
8080
'api_key',
8181
'apikey',
8282
'sentry_dsn',
83+
'access_token',
8384
])
8485
VALUES_RE = re.compile(r'^(?:\d[ -]*?){13,16}$')
8586

tests/processors/tests.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
'a_password_here': 'hello',
1616
'api_key': 'secret_key',
1717
'apiKey': 'secret_key',
18+
'access_token': 'oauth2 access token',
1819
}
1920

2021

@@ -25,6 +26,7 @@ def _will_throw_type_error(foo, **kwargs):
2526
a_password_here = "Don't look at me!" # NOQA F841
2627
api_key = "I'm hideous!" # NOQA F841
2728
apiKey = "4567000012345678" # NOQA F841
29+
access_token = "secret stuff!" # NOQA F841
2830

2931
# TypeError: unsupported operand type(s) for /: 'str' and 'str'
3032
raise exception_class()
@@ -89,6 +91,8 @@ def _check_vars_sanitized(self, vars, proc):
8991
self.assertEquals(vars['api_key'], proc.MASK)
9092
self.assertTrue('apiKey' in vars)
9193
self.assertEquals(vars['apiKey'], proc.MASK)
94+
self.assertTrue('access_token' in vars)
95+
self.assertEquals(vars['access_token'], proc.MASK)
9296

9397
def test_stacktrace(self, *args, **kwargs):
9498
"""
@@ -191,7 +195,8 @@ def test_cookie_as_string_with_partials(self):
191195
def test_cookie_header(self):
192196
data = get_http_data()
193197
data['request']['headers']['Cookie'] = 'foo=bar;password=hello'\
194-
';the_secret=hello;a_password_here=hello;api_key=secret_key'
198+
';the_secret=hello;a_password_here=hello;api_key=secret_key'\
199+
';access_token=at'
195200

196201
proc = SanitizePasswordsProcessor(Mock())
197202
result = proc.process(data)
@@ -201,7 +206,8 @@ def test_cookie_header(self):
201206
self.assertEquals(
202207
http['headers']['Cookie'],
203208
'foo=bar;password=%(m)s'
204-
';the_secret=%(m)s;a_password_here=%(m)s;api_key=%(m)s' % dict(m=proc.MASK))
209+
';the_secret=%(m)s;a_password_here=%(m)s;api_key=%(m)s'
210+
';access_token=%(m)s' % dict(m=proc.MASK))
205211

206212
def test_sanitize_credit_card(self):
207213
proc = SanitizePasswordsProcessor(Mock())

0 commit comments

Comments
 (0)