Esempio n. 1
0
    def test_RawCrash_binary_blob(self):
        def mocked_get(**params):
            if "uuid" in params and params["uuid"] == "abc":
                return "\xe0"
            raise NotImplementedError

        RawCrash.implementation().get.side_effect = mocked_get

        url = reverse("api:model_wrapper", args=("RawCrash", ))
        response = self.client.get(url, {"crash_id": "abc", "format": "raw"})
        # because we don't have permission
        assert response.status_code == 403

        response = self.client.get(url, {
            "crash_id": "abc",
            "format": "wrong"
        })  # note
        # invalid format
        assert response.status_code == 400
        assert response["Content-Type"] == "application/json; charset=UTF-8"

        user = self._login()
        self._add_permission(user, "view_pii")
        response = self.client.get(url, {"crash_id": "abc", "format": "raw"})
        # still don't have the right permission
        assert response.status_code == 403

        self._add_permission(user, "view_rawdump")
        response = self.client.get(url, {"crash_id": "abc", "format": "raw"})
        # finally!
        assert response.status_code == 200
        assert response[
            "Content-Disposition"] == 'attachment; filename="abc.dmp"'
        assert response["Content-Type"] == "application/octet-stream"
Esempio n. 2
0
    def test_RawCrash_binary_blob(self):
        def mocked_get(**params):
            if 'uuid' in params and params['uuid'] == 'abc':
                return '\xe0'
            raise NotImplementedError

        RawCrash.implementation().get.side_effect = mocked_get

        url = reverse('api:model_wrapper', args=('RawCrash', ))
        response = self.client.get(url, {'crash_id': 'abc', 'format': 'raw'})
        # because we don't have permission
        eq_(response.status_code, 403)

        response = self.client.get(
            url,
            {
                'crash_id': 'abc',
                'format': 'wrong'  # note
            })
        # invalid format
        eq_(response.status_code, 400)
        eq_(response['Content-Type'], 'application/json; charset=UTF-8')

        user = self._login()
        self._add_permission(user, 'view_pii')
        response = self.client.get(url, {'crash_id': 'abc', 'format': 'raw'})
        # still don't have the right permission
        eq_(response.status_code, 403)

        self._add_permission(user, 'view_rawdump')
        response = self.client.get(url, {'crash_id': 'abc', 'format': 'raw'})
        # finally!
        eq_(response.status_code, 200)
        eq_(response['Content-Disposition'], 'attachment; filename="abc.dmp"')
        eq_(response['Content-Type'], 'application/octet-stream')
Esempio n. 3
0
    def test_RawCrash(self):
        def mocked_get(**params):
            if "uuid" in params and params["uuid"] == "abc123":
                return {
                    "InstallTime": "1366691881",
                    "AdapterVendorID": "0x8086",
                    "Theme": "classic/1.0",
                    "Version": "23.0a1",
                    "id": "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}",
                    "Vendor": "Mozilla",
                    "EMCheckCompatibility": "true",
                    "URL": "http://system.gaiamobile.org:8080/",
                    "version": "23.0a1",
                    "AdapterDeviceID": "0x  46",
                    "ReleaseChannel": "nightly",
                    "submitted_timestamp": "2013-04-29T16:42:28.961187+00:00",
                    "buildid": "20130422105838",
                    "Notes": "AdapterVendorID: 0x8086, AdapterDeviceID: ...",
                    "CrashTime": "1366703112",
                    "FramePoisonBase": "7ffffffff0dea000",
                    "FramePoisonSize": "4096",
                    "StartupTime": "1366702830",
                    "Add-ons": "activities%40gaiamobile.org:0.1,%40gaiam...",
                    "BuildID": "20130422105838",
                    "SecondsSinceLastCrash": "23484",
                    "ProductName": "WaterWolf",
                    "ProductID": "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}",
                    "AsyncShutdownTimeout": 12345,
                    "BIOS_Manufacturer": "abc123",
                    "Comments":
                    "I visited http://example.com and [email protected]",
                    "upload_file_minidump_browser": "a crash",
                    "upload_file_minidump_flash1": "a crash",
                    "upload_file_minidump_flash2": "a crash",
                    "upload_file_minidump_plugin": "a crash",
                }
            raise NotImplementedError

        RawCrash.implementation().get.side_effect = mocked_get

        url = reverse("api:model_wrapper", args=("RawCrash", ))
        response = self.client.get(url)
        assert response.status_code == 400
        assert response["Content-Type"] == "application/json; charset=UTF-8"
        dump = json.loads(response.content)
        assert dump["errors"]["crash_id"]

        response = self.client.get(url, {"crash_id": "abc123"})
        assert response.status_code == 200
        dump = json.loads(response.content)
        assert "id" in dump
        assert "URL" not in dump
        assert "AsyncShutdownTimeout" in dump
        assert "BIOS_Manufacturer" in dump
        assert "upload_file_minidump_browser" in dump
        assert "upload_file_minidump_flash1" in dump
        assert "upload_file_minidump_flash2" in dump
        assert "upload_file_minidump_plugin" in dump
Esempio n. 4
0
    def test_RawCrash_binary_blob(self):

        def mocked_get(**params):
            if 'uuid' in params and params['uuid'] == 'abc':
                return '\xe0'
            raise NotImplementedError

        RawCrash.implementation().get.side_effect = mocked_get

        url = reverse('api:model_wrapper', args=('RawCrash',))
        response = self.client.get(url, {
            'crash_id': 'abc',
            'format': 'raw'
        })
        # because we don't have permission
        eq_(response.status_code, 403)

        response = self.client.get(url, {
            'crash_id': 'abc',
            'format': 'wrong'  # note
        })
        # invalid format
        eq_(response.status_code, 400)
        eq_(response['Content-Type'], 'application/json; charset=UTF-8')

        user = self._login()
        self._add_permission(user, 'view_pii')
        response = self.client.get(url, {
            'crash_id': 'abc',
            'format': 'raw'
        })
        # still don't have the right permission
        eq_(response.status_code, 403)

        self._add_permission(user, 'view_rawdump')
        response = self.client.get(url, {
            'crash_id': 'abc',
            'format': 'raw'
        })
        # finally!
        eq_(response.status_code, 200)
        eq_(response['Content-Disposition'], 'attachment; filename="abc.dmp"')
        eq_(response['Content-Type'], 'application/octet-stream')
Esempio n. 5
0
    def test_RawCrash(self):
        def mocked_get(**params):
            if 'uuid' in params and params['uuid'] == 'abc123':
                return {
                    "InstallTime": "1366691881",
                    "AdapterVendorID": "0x8086",
                    "Theme": "classic/1.0",
                    "Version": "23.0a1",
                    "id": "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}",
                    "Vendor": "Mozilla",
                    "EMCheckCompatibility": "true",
                    "Throttleable": "0",
                    "URL": "http://system.gaiamobile.org:8080/",
                    "version": "23.0a1",
                    "AdapterDeviceID": "0x  46",
                    "ReleaseChannel": "nightly",
                    "submitted_timestamp": "2013-04-29T16:42:28.961187+00:00",
                    "buildid": "20130422105838",
                    "timestamp": 1367253748.9612169,
                    "Notes": "AdapterVendorID: 0x8086, AdapterDeviceID: ...",
                    "CrashTime": "1366703112",
                    "FramePoisonBase": "7ffffffff0dea000",
                    "FramePoisonSize": "4096",
                    "StartupTime": "1366702830",
                    "Add-ons": "activities%40gaiamobile.org:0.1,%40gaiam...",
                    "BuildID": "20130422105838",
                    "SecondsSinceLastCrash": "23484",
                    "ProductName": "WaterWolf",
                    "legacy_processing": 0,
                    "ProductID": "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}",
                    "AsyncShutdownTimeout": 12345,
                    "BIOS_Manufacturer": "abc123",
                    "Comments": "I visited http://p0rn.com and [email protected]",
                    "upload_file_minidump_browser": "a crash",
                    "upload_file_minidump_flash1": "a crash",
                    "upload_file_minidump_flash2": "a crash",
                    "upload_file_minidump_plugin": "a crash"
                }
            raise NotImplementedError

        RawCrash.implementation().get.side_effect = mocked_get

        url = reverse('api:model_wrapper', args=('RawCrash', ))
        response = self.client.get(url)
        assert response.status_code == 400
        assert response['Content-Type'] == 'application/json; charset=UTF-8'
        dump = json.loads(response.content)
        assert dump['errors']['crash_id']

        response = self.client.get(url, {'crash_id': 'abc123'})
        assert response.status_code == 200
        dump = json.loads(response.content)
        assert 'id' in dump
        assert 'URL' not in dump
        assert 'AsyncShutdownTimeout' in dump
        assert 'BIOS_Manufacturer' in dump
        assert 'upload_file_minidump_browser' in dump
        assert 'upload_file_minidump_flash1' in dump
        assert 'upload_file_minidump_flash2' in dump
        assert 'upload_file_minidump_plugin' in dump

        # `Comments` is scrubbed
        assert 'I visited' in dump['Comments']
        assert 'http://p0rn.com' not in dump['Comments']
        assert '*****@*****.**' not in dump['Comments']
Esempio n. 6
0
    def test_RawCrash(self):
        def mocked_get(**params):
            if 'uuid' in params and params['uuid'] == 'abc123':
                return {
                    "InstallTime": "1366691881",
                    "AdapterVendorID": "0x8086",
                    "Theme": "classic/1.0",
                    "Version": "23.0a1",
                    "id": "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}",
                    "Vendor": "Mozilla",
                    "EMCheckCompatibility": "true",
                    "Throttleable": "0",
                    "URL": "http://system.gaiamobile.org:8080/",
                    "version": "23.0a1",
                    "AdapterDeviceID": "0x  46",
                    "ReleaseChannel": "nightly",
                    "submitted_timestamp": "2013-04-29T16:42:28.961187+00:00",
                    "buildid": "20130422105838",
                    "timestamp": 1367253748.9612169,
                    "Notes": "AdapterVendorID: 0x8086, AdapterDeviceID: ...",
                    "CrashTime": "1366703112",
                    "FramePoisonBase": "7ffffffff0dea000",
                    "FramePoisonSize": "4096",
                    "StartupTime": "1366702830",
                    "Add-ons": "activities%40gaiamobile.org:0.1,%40gaiam...",
                    "BuildID": "20130422105838",
                    "SecondsSinceLastCrash": "23484",
                    "ProductName": "WaterWolf",
                    "legacy_processing": 0,
                    "ProductID": "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}",
                    "AsyncShutdownTimeout": 12345,
                    "BIOS_Manufacturer": "abc123",
                    "Comments": "I visited http://example.com and [email protected]",
                    "upload_file_minidump_browser": "a crash",
                    "upload_file_minidump_flash1": "a crash",
                    "upload_file_minidump_flash2": "a crash",
                    "upload_file_minidump_plugin": "a crash"
                }
            raise NotImplementedError

        RawCrash.implementation().get.side_effect = mocked_get

        url = reverse('api:model_wrapper', args=('RawCrash',))
        response = self.client.get(url)
        assert response.status_code == 400
        assert response['Content-Type'] == 'application/json; charset=UTF-8'
        dump = json.loads(response.content)
        assert dump['errors']['crash_id']

        response = self.client.get(url, {
            'crash_id': 'abc123'
        })
        assert response.status_code == 200
        dump = json.loads(response.content)
        assert 'id' in dump
        assert 'URL' not in dump
        assert 'AsyncShutdownTimeout' in dump
        assert 'BIOS_Manufacturer' in dump
        assert 'upload_file_minidump_browser' in dump
        assert 'upload_file_minidump_flash1' in dump
        assert 'upload_file_minidump_flash2' in dump
        assert 'upload_file_minidump_plugin' in dump