How to use the bugsnag.utils.FilterDict function in bugsnag

To help you get started, we’ve selected a few bugsnag examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bugsnag / bugsnag-python / tests / test_utils.py View on Github external
def test_filter_dict(self):
        data = FilterDict({"metadata": {"another_password": "My password"}})
        encoder = SanitizingJSONEncoder(keyword_filters=["password"])
        sane_data = encoder.filter_string_values(data)
        self.assertEqual(sane_data,
                         {"metadata": {"another_password": "[FILTERED]"}})
github bugsnag / bugsnag-python / tests / test_utils.py View on Github external
def test_filter_dict_with_inner_dict(self):
        """
        Test that nested dict uniqueness checks work and are not recycled
        when a reference to a nested dict goes out of scope
        """
        data = {
            'level1-key1': {
                'level2-key1': FilterDict({
                    'level3-key1': {'level4-key1': 'level4-value1'},
                    'level3-key4': {'level4-key3': 'level4-value3'},
                }),
                'level2-key2': FilterDict({
                    'level3-key2': 'level3-value1',
                    'level3-key3': {'level4-key2': 'level4-value2'},
                    'level3-key5': {'level4-key4': 'level4-value4'},
                }),
            }
        }
        encoder = SanitizingJSONEncoder(keyword_filters=['password'])
        sane_data = json.loads(encoder.encode(data))
        self.assertEqual(sane_data, {
                            'level1-key1': {
                                'level2-key1': {
                                    'level3-key1': {
github bugsnag / bugsnag-python / tests / test_utils.py View on Github external
def test_encode_filters(self):
        data = FilterDict({"credit_card": "123213213123", "password": "456",
                           "cake": True})
        encoder = SanitizingJSONEncoder(keyword_filters=["credit_card",
                                                         "password"])
        sane_data = json.loads(encoder.encode(data))
        self.assertEqual(sane_data, {"credit_card": "[FILTERED]",
                                     "password": "[FILTERED]",
                                     "cake": True})
github bugsnag / bugsnag-python / tests / test_utils.py View on Github external
def test_sanitize_list(self):
        data = FilterDict({"list": ["carrots", "apples", "peas"],
                           "passwords": ["abc", "def"]})
        encoder = SanitizingJSONEncoder(keyword_filters=["credit_card",
                                                         "passwords"])
        sane_data = json.loads(encoder.encode(data))
        self.assertEqual(sane_data, {"list": ["carrots", "apples", "peas"],
                                     "passwords": "[FILTERED]"})
github bugsnag / bugsnag-python / tests / test_utils.py View on Github external
def test_filter_strings_with_inner_dict(self):
        """
        Test that nested dict uniqueness checks work and are not recycled
        when a reference to a nested dict goes out of scope
        """
        data = FilterDict({
            'level1-key1': {
                'level2-key1': {
                    'level3-key1': {'level4-key1': 'level4-value1'},
                    'token': 'mypassword',
                },
                'level2-key2': {
                    'level3-key3': {'level4-key2': 'level4-value2'},
                    'level3-key4': {'level4-key3': 'level4-value3'},
                    'level3-key5': {'password': 'super-secret'},
                    'level3-key6': {'level4-key4': 'level4-value4'},
                    'level3-key7': {'level4-key4': 'level4-value4'},
                    'level3-key8': {'level4-key4': 'level4-value4'},
                    'level3-key9': {'level4-key4': 'level4-value4'},
                    'level3-key0': {'level4-key4': 'level4-value4'},
                },
            }
github bugsnag / bugsnag-python / tests / test_utils.py View on Github external
def test_sanitize_nested_object_filters(self):
        data = FilterDict({"metadata": {"another_password": "My password"}})
        encoder = SanitizingJSONEncoder(keyword_filters=["password"])
        sane_data = json.loads(encoder.encode(data))
        self.assertEqual(sane_data,
                         {"metadata": {"another_password": "[FILTERED]"}})
github bugsnag / bugsnag-python / bugsnag / sessiontracker.py View on Github external
bugsnag.logger.debug("Not delivering due to an invalid api_key")
            return

        if not self.config.should_notify:
            bugsnag.logger.debug("Not delivering due to release_stages")
            return

        notifier_version = package_version('bugsnag') or 'unknown'

        payload = {
            'notifier': {
                'name': Notification.NOTIFIER_NAME,
                'url': Notification.NOTIFIER_URL,
                'version': notifier_version
            },
            'device': FilterDict({
                'hostname': self.config.get('hostname'),
                'runtimeVersions': self.config.get('runtime_versions')
            }),
            'app': {
                'releaseStage': self.config.get('release_stage'),
                'version': self.config.get('app_version')
            },
            'sessionCounts': sessions
        }

        try:
            filters = self.config.params_filters
            encoder = SanitizingJSONEncoder(separators=(',', ':'),
                                            keyword_filters=filters)
            encoded_payload = encoder.encode(payload)
            self.config.delivery.deliver_sessions(self.config, encoded_payload)