Skip to content

Commit

Permalink
Merge pull request #436 from GDATASoftwareAG/python/fix-detection-and…
Browse files Browse the repository at this point in the history
…-file-mime-type

fix test
  • Loading branch information
lennartdohmann authored Apr 29, 2024
2 parents f66ed83 + a361f66 commit e4c2a2d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
5 changes: 3 additions & 2 deletions python/src/vaas/vaas.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ def map_response(verdict_response):
"Sha256": verdict_response.get("sha256"),
"Guid": verdict_response.get("guid"),
"Verdict": verdict_response.get("verdict"),
"LibMagic": verdict_response.get("lib_magic"),
"Detections": verdict_response.get("detections"),
"Detection": verdict_response.get("detection"),
"FileType": verdict_response.get("file_type"),
"MimeType": verdict_response.get("mime_type")
}


Expand Down
32 changes: 16 additions & 16 deletions python/tests/test_vaas.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,19 @@ async def test_for_sha256_returns_malicious_for_eicar(self):
self.assertEqual(verdict["Guid"].casefold(), guid)
)

# async def test_for_sha256_returns_pup_for_amtso(self):
# async with await create_and_connect() as vaas:
# guid = str(uuid.uuid4())
# verdict = await vaas.for_sha256(
# "d6f6c6b9fde37694e12b12009ad11ab9ec8dd0f193e7319c523933bdad8a50ad",
# guid=guid
# )
# self.assertEqual(verdict["Verdict"], "Pup")
# self.assertEqual(
# verdict["Sha256"].casefold(),
# "d6f6c6b9fde37694e12b12009ad11ab9ec8dd0f193e7319c523933bdad8a50ad".casefold(),
# )
# self.assertEqual(verdict["Guid"].casefold(), guid)
async def test_for_sha256_returns_pup_for_amtso(self):
async with await create_and_connect() as vaas:
guid = str(uuid.uuid4())
verdict = await vaas.for_sha256(
"d6f6c6b9fde37694e12b12009ad11ab9ec8dd0f193e7319c523933bdad8a50ad",
guid=guid
)
self.assertEqual(verdict["Verdict"], "Pup")
self.assertEqual(
verdict["Sha256"].casefold(),
"d6f6c6b9fde37694e12b12009ad11ab9ec8dd0f193e7319c523933bdad8a50ad".casefold(),
)
self.assertEqual(verdict["Guid"].casefold(), guid)

async def test_for_buffer_returns_malicious_for_eicar(self):
async with await create_and_connect() as vaas:
Expand Down Expand Up @@ -249,9 +249,9 @@ async def test_for_url_returns_detections_and_mime_type(self):
guid = str(uuid.uuid4())
verdict = await vaas.for_url("https://secure.eicar.org/eicar.com.txt", guid=guid)
self.assertEqual(verdict["Verdict"], "Malicious")
self.assertIsNotNone(verdict["Detections"])
self.assertEqual(verdict["LibMagic"]['file_type'], "EICAR virus test files")
self.assertEqual(verdict["LibMagic"]['mime_type'], "text/plain")
self.assertIsNotNone(verdict["Detection"])
self.assertEqual(verdict['FileType'], "EICAR virus test files")
self.assertEqual(verdict['MimeType'], "text/plain")


if __name__ == "__main__":
Expand Down

0 comments on commit e4c2a2d

Please sign in to comment.