Skip to content

Commit

Permalink
fix(store) Don't explode on garbage ignore patterns (#13483)
Browse files Browse the repository at this point in the history
Users make mistakes on their ignore patterns, we shouldn't fail to store
events just because they are bad at filter patterns.

Fixes SENTRY-9H7
  • Loading branch information
markstory authored Jun 3, 2019
1 parent 5ad8658 commit e0fbb21
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/sentry/utils/data_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,12 @@ def is_valid_error_message(project, message):
message = force_text(message).lower()

for error in filtered_errors:
if fnmatch.fnmatch(message, error.lower()):
return False
try:
if fnmatch.fnmatch(message, error.lower()):
return False
except Exception:
# fnmatch raises a string when the pattern is bad.
# Patterns come from end users and can be full of mistakes.
pass

return True
6 changes: 6 additions & 0 deletions tests/sentry/utils/http/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,12 @@ def test_garbage_data(self):
assert self.is_valid_error_message(None, ['ImportError*'])
assert self.is_valid_error_message({}, ['ImportError*'])

def test_bad_characters_in_pattern(self):
patterns = [
u"*google_tag_manager['GTM-3TL3'].macro(...)*",
]
assert self.is_valid_error_message('it bad', patterns)


class OriginFromRequestTestCase(TestCase):
def test_nothing(self):
Expand Down

0 comments on commit e0fbb21

Please sign in to comment.