Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion raven/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ def process(self, data, **kwargs):
if resp:
data = resp

if 'stacktrace' in data:
self.filter_stacktrace(data['stacktrace'])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a test that highlight why this is needed ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you asking for updating the tests/processors/tests.py for case when an event that has 'stacktrace' in its data? I have just updated the processor test to include the two additional 'pw' and 'cred' field. As for the test case for 'AUTO_LOG_STACKS', I will need to spend a bit more time in figuring how to write a test for that (turn on auto_log_stacks and build a raven.events.Message).

This can be reproduce when "auto_log_stacks" option is set to True and logging a Message event.


if 'exception' in data:
if 'values' in data['exception']:
for value in data['exception'].get('values', []):
Expand Down Expand Up @@ -67,7 +70,8 @@ class SanitizePasswordsProcessor(Processor):
"""
MASK = '*' * 8
FIELDS = frozenset([
'password', 'secret', 'passwd', 'authorization', 'api_key', 'apikey'
'password', 'secret', 'passwd', 'authorization', 'api_key', 'apikey',
'pw', 'cred'
])
VALUES_RE = re.compile(r'^(?:\d[ -]*?){13,16}$')

Expand Down
8 changes: 8 additions & 0 deletions tests/processors/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
'a_password_here': 'hello',
'api_key': 'secret_key',
'apiKey': 'secret_key',
'pw': 'hello',
'cred': 'hello',
}


Expand All @@ -25,6 +27,8 @@ def _will_throw_type_error(foo, **kwargs):
a_password_here = "Don't look at me!" # NOQA F841
api_key = "I'm hideous!" # NOQA F841
apiKey = "4567000012345678" # NOQA F841
pw = "this is my pw" # NOQA F841
cred = "my credential" # NOQA F841

# TypeError: unsupported operand type(s) for /: 'str' and 'str'
raise exception_class()
Expand Down Expand Up @@ -83,6 +87,10 @@ def _check_vars_sanitized(self, vars, proc):
self.assertEquals(vars['api_key'], proc.MASK)
self.assertTrue('apiKey' in vars)
self.assertEquals(vars['apiKey'], proc.MASK)
self.assertTrue('pw' in vars)
self.assertEquals(vars['pw'], proc.MASK)
self.assertTrue('cred' in vars)
self.assertEquals(vars['cred'], proc.MASK)

def test_stacktrace(self, *args, **kwargs):
"""
Expand Down