diff --git a/php/src/vaas/Message/Detection.php b/php/src/vaas/Message/Detection.php new file mode 100644 index 00000000..c275574f --- /dev/null +++ b/php/src/vaas/Message/Detection.php @@ -0,0 +1,10 @@ +kind = Kind::Error; } - - /** - * @return string - */ - public function getType(): string - { - return $this->type; - } - - /** - * @return Kind - */ - public function getKind(): Kind - { - return $this->kind; - } - - /** - * @return ProblemDetails - */ - public function getProblemDetails(): ProblemDetails - { - return $this->problem_details; - } - - /** - * @return string - */ - public function getRequestId(): string - { - return $this->requestId; - } - - /** - * @return string - */ - public function getText(): string - { - return $this->text; - } } diff --git a/php/src/vaas/Message/LibMagic.php b/php/src/vaas/Message/LibMagic.php new file mode 100644 index 00000000..e09509f0 --- /dev/null +++ b/php/src/vaas/Message/LibMagic.php @@ -0,0 +1,9 @@ +detail; - } - - /** - * @return string - */ - public function getType(): string - { - return $this->type; - } -} \ No newline at end of file +} diff --git a/php/src/vaas/Message/VaasVerdict.php b/php/src/vaas/Message/VaasVerdict.php index 03508658..68bdb945 100644 --- a/php/src/vaas/Message/VaasVerdict.php +++ b/php/src/vaas/Message/VaasVerdict.php @@ -9,9 +9,13 @@ public function __construct(VerdictResponse $verdictResponse) $this->Sha256 = $verdictResponse->sha256 ?? ""; $this->Verdict = $verdictResponse->verdict ?? Verdict::UNKNOWN; $this->Guid = $verdictResponse->guid ?? ""; + $this->LibMagic = $verdictResponse->libMagic ?? null; + $this->Detections = $verdictResponse->detections ?? null; } public string $Sha256; public Verdict $Verdict; public string $Guid; + public ?LibMagic $LibMagic; + public ?array $Detections; } diff --git a/php/src/vaas/Message/VerdictResponse.php b/php/src/vaas/Message/VerdictResponse.php index 75b5cea7..fec27bff 100644 --- a/php/src/vaas/Message/VerdictResponse.php +++ b/php/src/vaas/Message/VerdictResponse.php @@ -9,4 +9,6 @@ class VerdictResponse extends BaseMessage public string $guid; public string $sha256; public ?string $upload_token; + public ?LibMagic $libMagic; + public ?array $detections; } diff --git a/php/src/vaas/Vaas.php b/php/src/vaas/Vaas.php index a6616b6c..0a904be4 100644 --- a/php/src/vaas/Vaas.php +++ b/php/src/vaas/Vaas.php @@ -374,11 +374,11 @@ private function _waitForVerdict(string $guid): VerdictResponse private function _handleWebSocketErrorResponse(Error $errorResponse): void { if (isset($errorResponse->problem_details->detail)) { - $details = $errorResponse->problem_details->getDetail(); + $details = $errorResponse->problem_details->detail; } else { $details = null; } - $errorType = $errorResponse->getType(); + $errorType = $errorResponse->type; if ($errorType == "ClientError") { throw new VaasClientException($details); } diff --git a/php/tests/vaas/VaasTest.php b/php/tests/vaas/VaasTest.php index 85139188..a4e16b92 100644 --- a/php/tests/vaas/VaasTest.php +++ b/php/tests/vaas/VaasTest.php @@ -596,4 +596,19 @@ public function testForStream_WithEicarUrlContentAsStream_ReturnsMalicious() $this->assertEquals(Verdict::MALICIOUS, $verdict->Verdict); } + + public function testForStream_WithEicarUrlContentAsStream_ReturnsMaliciousWithDetectionAndMimeType() + { + $vaas = $this->_getVaas(); + $vaas->Connect($this->getClientCredentialsGrantAuthenticator()->getToken()); + $httpClient = new Client(); + $response = $httpClient->get(self::MALICIOUS_URL); + $stream = new Stream($response->getBody()->detach()); + + $verdict = $vaas->ForStream($stream); + + $this->assertEquals(Verdict::MALICIOUS, $verdict->Verdict); + $this->assertEquals("text/plain", $verdict->LibMagic->mimeType); + $this->assertContains("EICAR-Test-File", array_column($verdict->Detections, "virus")); + } }