Пример #1
0
def test_scrub_data_in_processing(field):
    project_config = ProjectConfig(
        None,
        config={
            "datascrubbingSettings": {
                "excludeFields": [],
                "scrubData": True,
                "scrubIpAddresses": False,
                "sensitiveFields": ["a"],
                "scrubDefaults": False,
            },
            "piiConfig": {},
        },
    )

    new_field = u"new_{}".format(field)

    old_event = {"extra": {field: "do not remove"}}
    event = {"extra": {field: "do not remove", new_field: "do remove"}}

    new_event = scrub_data(project_config, event, in_processing=True, old_event=old_event)

    assert new_event == {
        u"_meta": {
            u"extra": {new_field: {u"": {u"len": 9, u"rem": [[u"strip-fields", u"s", 0, 10]]}}}
        },
        u"extra": {field: u"do not remove", new_field: u"[Filtered]"},
    }
Пример #2
0
def process_event(data, meta, project_config):
    from sentry.event_manager import EventManager
    from sentry.tasks.store import should_process
    from sentry.web.api import _scrub_event_data
    from sentry.relay.config import ProjectConfig

    project_config = ProjectConfig(None, **project_config)

    event_manager = EventManager(
        data,
        client_ip=meta.get("REMOTE_ADDR"),
        user_agent=meta.get("HTTP_USER_AGENT"),
        auth=None,
        key=None,
        content_encoding=meta.get("HTTP_CONTENT_ENCODING"),
    )
    event_manager.normalize()

    event = event_manager.get_data()
    group_hash = None

    datascrubbing_settings = project_config.config.get(
        "datascrubbingSettings") or {}
    event = _scrub_event_data(event, datascrubbing_settings)

    if not should_process(event):
        group_hash = event_manager._get_event_instance(
            project_id=1).get_hashes()
    return {"event": dict(event), "group_hash": group_hash}
Пример #3
0
 def _get_project_config(self, filter_opt=None):
     """
     Constructs a test project_config with the provided legacy_browsers filter setting
     :param filter_opt: the value for 'filters:legacy-browsers' project options (may be None)
     :return: a ProjectConfig object with the filter option set and the project taken from
     the TestCase
     """
     ret_val = ProjectConfig(self.project, config={})
     config = ret_val.config
     filter_settings = {}
     config['filter_settings'] = filter_settings
     if filter_opt is not None:
         key = get_filter_key(_legacy_browsers_filter)
         filter_settings[key] = _filter_option_to_config_setting(
             _legacy_browsers_filter, filter_opt)
     return ret_val
Пример #4
0
def test_scrub_data(field):
    project_config = ProjectConfig(
        None,
        config={
            "datascrubbingSettings": {
                "excludeFields": [],
                "scrubData": True,
                "scrubIpAddresses": False,
                "sensitiveFields": ["a"],
                "scrubDefaults": False,
            },
            "piiConfig": {
                "applications": {
                    "debug_meta.images.*.code_file": ["@userpath:replace"],
                    "debug_meta.images.*.debug_file": ["@userpath:replace"],
                }
            },
        },
    )

    event = {
        "extra": {
            field: "pls remove"
        },
        "debug_meta": {
            "images": [{
                "type": "symbolic",
                "debug_file": "/Users/foo/bar",
                "code_file": "/Users/foo/bar"
            }]
        },
    }

    new_event = scrub_data(project_config, event)

    assert new_event == ({
        u"_meta": {
            u"debug_meta": {
                u"images": {
                    u"0": {
                        u"code_file": {
                            u"": {
                                u"len": 10,
                                u"rem": [[u"@userpath:replace", u"s", 7, 13]]
                            }
                        },
                        u"debug_file": {
                            u"": {
                                u"len": 10,
                                u"rem": [[u"@userpath:replace", u"s", 7, 13]]
                            }
                        },
                    }
                }
            },
            u"extra": {
                field: {
                    u"": {
                        u"len": 10,
                        u"rem": [[u"strip-fields", u"s", 0, 10]]
                    }
                }
            },
        },
        u"debug_meta": {
            u"images": [{
                u"code_file": u"/Users/[user]/bar",
                u"debug_file": u"/Users/[user]/bar",
                u"type": u"symbolic",
            }]
        },
        u"extra": {
            field: u"[Filtered]"
        },
    })
 def apply_filter(self, data):
     project_config = ProjectConfig(self.project)
     return _browser_extensions_filter(project_config, data)
Пример #6
0
 def apply_filter(self, data):
     project_config = ProjectConfig(self.project)
     return _localhost_filter(project_config, data)
 def apply_filter(self, data):
     project = Project()
     project_config = ProjectConfig(project)
     return _web_crawlers_filter(project_config, data)