Exemplo n.º 1
0
 async def test_scan_virustotal(self):
     # dont raise on VT error cause of API limitations
     # to 4 requests per minute
     try:
         await self._scan_eicar('VirusTotal')
     except Exception:
         raise asynctest.SkipTest("Virustotal test Failed")
Exemplo n.º 2
0
 async def _scan_eicar(self, probe):
     if probe not in self.probes:
         raise asynctest.SkipTest("Skipping %s not present" % probe)
     probelist = [probe]
     filelist = [EICAR_PATH]
     res = await self._test_scan_file(filelist, probelist, force=True)
     self._check_probe_result(res[EICAR_NAME], EICAR_RESULTS)
Exemplo n.º 3
0
    async def test_zip(self):
        async with AAPI() as api:
            probelist = await api.probes.list()
            probe = 'Unarchive'
            if probe not in probelist:
                raise asynctest.SkipTest(
                    "Skipping {} not present".format(probe))

            sample = SAMPLES_DIR / ZIP_SAMPLE
            scan = await api.scans.scan([sample],
                                        raw=True,
                                        linger=True,
                                        probes=[probe],
                                        force=True)
            self.assertEqual(len(scan.files_ext), 2)
            self.assertEqual(scan.probes_finished, 1)
Exemplo n.º 4
0
 async def setUp(self):
     async with AAPI() as api:
         if self.taglist is None:
             self.taglist = await api.tags.list()
         if not self.taglist:
             raise asynctest.SkipTest(
                 "Skipping No tag found (please add some)")
         # Insure file is present (Force=False)
         scan = await api.scans.scan([self.file_path],
                                     linger=True,
                                     force=False)
         self.result = await api.scans.result(scan.files_ext[0])
         # Insure file got no tags for test
         self.former_tags = self.result.file_infos.tags
         if self.former_tags:
             removals = [
                 api.files.remove_tag(self.file_sha256, tag)
                 for tag in self.former_tags
             ]
             await asyncio.gather(*removals)
             self.result = await api.scans.result(scan.files_ext[0])
Exemplo n.º 5
0
    async def test_zipbomb(self):
        async with AAPI() as api:
            probelist = await api.probes.list()
            probe = 'Unarchive'
            if probe not in probelist:
                raise asynctest.SkipTest(
                    "Skipping {} not present".format(probe))

            sample = SAMPLES_DIR / ZIP_SAMPLE
            scan = api.scans.scan([sample],
                                  linger=True,
                                  probes=[probe],
                                  force=True)

            self.assertEqual(len(scan.results), 1)
            self.assertEqual(scan.probes_finished, 1)

            result = await api.scans.result(scan.results[0])

            self.assertEqual(len(result.probe_results), 1)
            probe_result = result.probe_results[0]
            self.assertEqual(probe_result.status, -1)
            self.assertIsNotNone(probe_result.error)
            self.assertNone(probe_result.results)
 async def setUp(self):
     self.api = await AAPI().__aenter__()
     self.probes = await self.api.probes.list()
     if not await srcode_api_enabled():
         raise asynctest.SkipTest(
             "Skipping srcode API disabled")