Skip to content

Commit

Permalink
Merge pull request #443 from GDATASoftwareAG/php/fix-detection-and-mi…
Browse files Browse the repository at this point in the history
…me-file-type

fix detection and file mime type
  • Loading branch information
doxthree authored Apr 29, 2024
2 parents 4b00a32 + 3257fb5 commit 8aa7a11
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
10 changes: 6 additions & 4 deletions php/src/vaas/Message/VaasVerdict.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ public function __construct(VerdictResponse $verdictResponse)
$this->Sha256 = $verdictResponse->sha256 ?? "";
$this->Verdict = $verdictResponse->verdict ?? Verdict::UNKNOWN;
$this->Guid = $verdictResponse->guid ?? "";
$this->LibMagic = $verdictResponse->lib_magic ?? null;
$this->Detections = $verdictResponse->detections ?? null;
$this->MimeType = $verdictResponse->mime_type ?? null;
$this->FileType = $verdictResponse->file_type ?? null;
$this->Detection = $verdictResponse->detection ?? null;
}

public string $Sha256;
public Verdict $Verdict;
public string $Guid;
public ?LibMagic $LibMagic;
public ?array $Detections;
public ?string $FileType;
public ?string $MimeType;
public ?string $Detection;
}
5 changes: 3 additions & 2 deletions php/src/vaas/Message/VerdictResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class VerdictResponse extends BaseMessage
public string $guid;
public string $sha256;
public ?string $upload_token;
public ?LibMagic $lib_magic;
public ?array $detections;
public ?string $file_type;
public ?string $mime_type;
public ?string $detection;
}
26 changes: 13 additions & 13 deletions php/tests/vaas/VaasTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,19 +176,19 @@ public function testForSha256CleanSha256_GetsCleanResponse(): void
$this->assertEqualsIgnoringCase($cleanSha256, $verdict->Sha256);
}

// public function testForSha256AmtsoPupSample_GetsPupResponse(): void
// {
// $uuid = $this->getUuid();
// $pupSha256 = "d6f6c6b9fde37694e12b12009ad11ab9ec8dd0f193e7319c523933bdad8a50ad";
// $vaas = $this->_getVaas();
// $vaas->Connect($this->getClientCredentialsGrantAuthenticator()->getToken());
public function testForSha256AmtsoPupSample_GetsPupResponse(): void
{
$uuid = $this->getUuid();
$pupSha256 = "d6f6c6b9fde37694e12b12009ad11ab9ec8dd0f193e7319c523933bdad8a50ad";
$vaas = $this->_getVaas();
$vaas->Connect($this->getClientCredentialsGrantAuthenticator()->getToken());

// $verdict = $vaas->ForSha256($pupSha256, $uuid);
$verdict = $vaas->ForSha256($pupSha256, $uuid);

// $this->assertEquals(Verdict::PUP, $verdict->Verdict);
// $this->assertEquals($uuid, $verdict->Guid);
// $this->assertEqualsIgnoringCase($pupSha256, $verdict->Sha256);
// }
$this->assertEquals(Verdict::PUP, $verdict->Verdict);
$this->assertEquals($uuid, $verdict->Guid);
$this->assertEqualsIgnoringCase($pupSha256, $verdict->Sha256);
}

public function testForMultipleHashes_GetsResponse(): void
{
Expand Down Expand Up @@ -579,7 +579,7 @@ public function testForStream_WithEicarUrlContentAsStream_ReturnsMaliciousWithDe
$verdict = $vaas->ForStream($stream);

$this->assertEquals(Verdict::MALICIOUS, $verdict->Verdict);
$this->assertEquals("text/plain", $verdict->LibMagic->mime_type);
$this->assertContains("EICAR-Test-File", array_column($verdict->Detections, "virus"));
$this->assertEquals("text/plain", $verdict->MimeType);
$this->assertNotEmpty($verdict->Detection);
}
}

0 comments on commit 8aa7a11

Please sign in to comment.