Exemplo n.º 1
0
def test_trim_function_name():
    assert trim_function_name('+[foo:(bar)]', 'objc') == '+[foo:(bar)]'
    assert trim_function_name('[foo:(bar)]', 'objc') == '[foo:(bar)]'
    assert trim_function_name('-[foo:(bar)]', 'objc') == '-[foo:(bar)]'
    assert trim_function_name('(anonymous namespace)::foo(int)',
                              'native') == '(anonymous namespace)::foo'
    assert trim_function_name('foo::bar::foo(int)',
                              'native') == 'foo::bar::foo'
Exemplo n.º 2
0
 def _push_frame(frame):
     self._frames.append({
         'function':
         trim_function_name(frame.get('function'), '<unknown>'),
         'path':
         frame.get('abs_path') or frame.get('filename'),
         'module':
         frame.get('module'),
         'family':
         get_grouping_family_for_platform(
             frame.get('platform') or self.event.get('platform')),
     })
Exemplo n.º 3
0
def get_crash_location(exception, platform=None):
    default = None
    for frame in reversed(
            get_path(exception, 'stacktrace', 'frames', filter=True) or ()):
        fn = frame.get('filename') or frame.get('abs_path')
        if fn:
            func = frame.get('function')
            if func is not None:
                from sentry.grouping.strategies.utils import trim_function_name
                func = trim_function_name(func,
                                          frame.get('platform') or platform)
            if frame.get('in_app'):
                return fn, func
            if default is None:
                default = fn, func
    return default
Exemplo n.º 4
0
    def matches_frame(self, frame_data, platform):
        # Path matches are always case insensitive
        if self.key in ('path', 'package'):
            if self.key == 'package':
                value = frame_data.get('package') or ''
            else:
                value = frame_data.get('abs_path') or frame_data.get(
                    'filename') or ''
            if glob_match(value,
                          self.pattern,
                          ignorecase=True,
                          doublestar=True,
                          path_normalize=True):
                return True
            if not value.startswith('/') and glob_match('/' + value,
                                                        self.pattern,
                                                        ignorecase=True,
                                                        doublestar=True,
                                                        path_normalize=True):
                return True
            return False

        # families need custom handling as well
        if self.key == 'family':
            flags = self.pattern.split(',')
            if 'all' in flags:
                return True
            family = get_grouping_family_for_platform(
                frame_data.get('platform') or platform)
            return family in flags

        # all other matches are case sensitive
        if self.key == 'function':
            from sentry.grouping.strategies.utils import trim_function_name
            value = trim_function_name(
                frame_data.get('function') or '<unknown>',
                frame_data.get('platform') or platform)
        elif self.key == 'module':
            value = frame_data.get('module') or '<unknown>'
        else:
            # should not happen :)
            value = '<unknown>'
        return glob_match(value, self.pattern)
Exemplo n.º 5
0
def test_isolate_native_function_v1(input, output):
    assert isolate_native_function_v1(input) == output
    assert trim_function_name(input, 'native') == output