Пример #1
0
    def test_redact(self):

        d = DotDict()
        # these keys survive redaction
        d['a.b.c'] = 11
        d['sensitive.x'] = 2
        d['not_url'] = 'not a url'

        # these keys do not survive redaction
        d['url'] = 'http://very.embarassing.com'
        d['email'] = '*****@*****.**',
        d['user_id'] = '3333'
        d['exploitability'] = 'yep'
        d['json_dump.sensitive'] = 22
        d['upload_file_minidump_flash1.json_dump.sensitive'] = 33
        d['upload_file_minidump_flash2.json_dump.sensitive'] = 44
        d['upload_file_minidump_browser.json_dump.sensitive.exploitable'] = 55
        d['upload_file_minidump_browser.json_dump.sensitive.secret'] = 66
        d['memory_info'] = {'incriminating_memory': 'call the FBI'}

        ok_('json_dump' in d)

        config = DotDict()
        config.forbidden_keys = Redactor.required_config.forbidden_keys.default

        expected_surviving_keys = [
            'a',
            'sensitive',
            'not_url',
            'json_dump',
            'upload_file_minidump_flash1',
            'upload_file_minidump_flash2',
            'upload_file_minidump_browser'
        ]
        expected_surviving_keys.sort()

        redactor = Redactor(config)
        redactor(d)
        actual_surviving_keys = [x for x in d.keys()]
        actual_surviving_keys.sort()
        eq_(
            len(actual_surviving_keys),
            len(expected_surviving_keys)
        )
        eq_(
            actual_surviving_keys,
            expected_surviving_keys
        )
Пример #2
0
    def test_redact(self):
        d = DotDict()
        # these keys survive redaction
        d["a.b.c"] = 11
        d["sensitive.x"] = 2
        d["not_url"] = "not a url"

        # these keys do not survive redaction
        d["url"] = "http://very.embarassing.com"
        d["email"] = ("*****@*****.**", )
        d["user_id"] = "3333"
        d["exploitability"] = "yep"
        d["json_dump.sensitive"] = 22
        d["upload_file_minidump_flash1.json_dump.sensitive"] = 33
        d["upload_file_minidump_flash2.json_dump.sensitive"] = 44
        d["upload_file_minidump_browser.json_dump.sensitive.exploitable"] = 55
        d["upload_file_minidump_browser.json_dump.sensitive.secret"] = 66
        d["memory_info"] = {"incriminating_memory": "call the FBI"}

        assert "json_dump" in d

        config = DotDict()
        config.forbidden_keys = Redactor.required_config.forbidden_keys.default

        expected_surviving_keys = [
            "a",
            "sensitive",
            "not_url",
            "json_dump",
            "upload_file_minidump_flash1",
            "upload_file_minidump_flash2",
            "upload_file_minidump_browser",
        ]
        expected_surviving_keys.sort()

        redactor = Redactor(config)
        redactor(d)
        actual_surviving_keys = [x for x in d.keys()]
        actual_surviving_keys.sort()
        assert actual_surviving_keys == expected_surviving_keys