diff --git a/dotnet/.vscode/launch.json b/dotnet/.vscode/launch.json new file mode 100644 index 00000000..f85cf29f --- /dev/null +++ b/dotnet/.vscode/launch.json @@ -0,0 +1,26 @@ +{ + "version": "0.2.0", + "configurations": [ + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/Vaas/test/TestFiles/bin/Debug/net8.0/TestFiles.dll", + "args": [], + "cwd": "${workspaceFolder}/Vaas/test/TestFiles", + // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console + "console": "internalConsole", + "stopAtEntry": false + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + } + ] +} \ No newline at end of file diff --git a/dotnet/.vscode/tasks.json b/dotnet/.vscode/tasks.json new file mode 100644 index 00000000..c0710f14 --- /dev/null +++ b/dotnet/.vscode/tasks.json @@ -0,0 +1,41 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/Vaas/Vaas.sln", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary;ForceNoAlign" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/Vaas/Vaas.sln", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary;ForceNoAlign" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "--project", + "${workspaceFolder}/Vaas/Vaas.sln" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/dotnet/Vaas/.devcontainer/devcontainer.json b/dotnet/Vaas/.devcontainer/devcontainer.json new file mode 100644 index 00000000..9c333084 --- /dev/null +++ b/dotnet/Vaas/.devcontainer/devcontainer.json @@ -0,0 +1,29 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/dotnet +{ + "name": "C# (.NET)", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/dotnet:1-8.0-bookworm", + "customizations": { + "vscode": { + "extensions": [ + "ms-dotnettools.csdevkit" + ] + } + } + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [5000, 5001], + // "portsAttributes": { + // "5001": { + // "protocol": "https" + // } + // } + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "dotnet restore", + // Configure tool-specific properties. + // "customizations": {}, + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} \ No newline at end of file diff --git a/dotnet/Vaas/.github/dependabot.yml b/dotnet/Vaas/.github/dependabot.yml new file mode 100644 index 00000000..f33a02cd --- /dev/null +++ b/dotnet/Vaas/.github/dependabot.yml @@ -0,0 +1,12 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for more information: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates +# https://containers.dev/guide/dependabot + +version: 2 +updates: + - package-ecosystem: "devcontainers" + directory: "/" + schedule: + interval: weekly diff --git a/dotnet/Vaas/.mono/registry/CurrentUser/software/microsoft/csdevkit/telemetry/persistentpropertybag/microsoft.visualstudio.code.servicehost/values.xml b/dotnet/Vaas/.mono/registry/CurrentUser/software/microsoft/csdevkit/telemetry/persistentpropertybag/microsoft.visualstudio.code.servicehost/values.xml new file mode 100644 index 00000000..a0dc4cbf --- /dev/null +++ b/dotnet/Vaas/.mono/registry/CurrentUser/software/microsoft/csdevkit/telemetry/persistentpropertybag/microsoft.visualstudio.code.servicehost/values.xml @@ -0,0 +1,5 @@ + + 0 + 5 + 1 + \ No newline at end of file diff --git a/dotnet/Vaas/test/Vaas.Test/IntegrationTests.cs b/dotnet/Vaas/test/Vaas.Test/IntegrationTests.cs index 68598d06..224a2444 100644 --- a/dotnet/Vaas/test/Vaas.Test/IntegrationTests.cs +++ b/dotnet/Vaas/test/Vaas.Test/IntegrationTests.cs @@ -51,10 +51,10 @@ public async void FromSha256SingleMaliciousHash() { var vaas = await AuthenticateWithCredentials(); var verdict = await vaas.ForSha256Async( - new ChecksumSha256("000005c43196142f01d615a67b7da8a53cb0172f8e9317a2ec9a0a39a1da6fe8"), + new ChecksumSha256("ab5788279033b0a96f2d342e5f35159f103f69e0191dd391e036a1cd711791a2"), CancellationToken.None); Assert.Equal(Verdict.Malicious, verdict.Verdict); - Assert.Equal("000005c43196142f01d615a67b7da8a53cb0172f8e9317a2ec9a0a39a1da6fe8", verdict.Sha256); + Assert.Equal("ab5788279033b0a96f2d342e5f35159f103f69e0191dd391e036a1cd711791a2", verdict.Sha256); } [Fact] @@ -62,10 +62,10 @@ public async void FromSha256SingleCleanHash() { var vaas = await AuthenticateWithCredentials(); var verdict = await vaas.ForSha256Async( - new ChecksumSha256("3A78F382E8E2968EC201B33178102E06DB72E4F2D1505E058A4613C1E977825C"), + new ChecksumSha256("cd617c5c1b1ff1c94a52ab8cf07192654f271a3f8bad49490288131ccb9efc1e"), CancellationToken.None); Assert.Equal(Verdict.Clean, verdict.Verdict); - Assert.Equal("3A78F382E8E2968EC201B33178102E06DB72E4F2D1505E058A4613C1E977825C", verdict.Sha256, true); + Assert.Equal("cd617c5c1b1ff1c94a52ab8cf07192654f271a3f8bad49490288131ccb9efc1e", verdict.Sha256, true); } [Fact(Skip = "Remove Skip to test keepalive")] @@ -98,18 +98,18 @@ public async void From256ListMultipleHashes() { var myList = new List { - "000005c43196142f01d615a67b7da8a53cb0172f8e9317a2ec9a0a39a1da6fe8", - "3A78F382E8E2968EC201B33178102E06DB72E4F2D1505E058A4613C1E977825C", - "110005c43196142f01d615a67b7da8a53cb0172f8e9317a2ec9a0a39a1da6fe9" + "ab5788279033b0a96f2d342e5f35159f103f69e0191dd391e036a1cd711791a2", + "cd617c5c1b1ff1c94a52ab8cf07192654f271a3f8bad49490288131ccb9efc1e", + "1f72c1111111111111f912e40b7323a0192a300b376186c10f6803dc5efe28df" }; var vaas = await AuthenticateWithCredentials(); var verdictList = await vaas.ForSha256ListAsync(myList, CancellationToken.None); Assert.Equal(Verdict.Malicious, verdictList[0].Verdict); - Assert.Equal("000005c43196142f01d615a67b7da8a53cb0172f8e9317a2ec9a0a39a1da6fe8", verdictList[0].Sha256, true); + Assert.Equal("ab5788279033b0a96f2d342e5f35159f103f69e0191dd391e036a1cd711791a2", verdictList[0].Sha256, true); Assert.Equal(Verdict.Clean, verdictList[1].Verdict); - Assert.Equal("3A78F382E8E2968EC201B33178102E06DB72E4F2D1505E058A4613C1E977825C", verdictList[1].Sha256, true); + Assert.Equal("cd617c5c1b1ff1c94a52ab8cf07192654f271a3f8bad49490288131ccb9efc1e", verdictList[1].Sha256, true); Assert.Equal(Verdict.Unknown, verdictList[2].Verdict); - Assert.Equal("110005c43196142f01d615a67b7da8a53cb0172f8e9317a2ec9a0a39a1da6fe9", verdictList[2].Sha256, true); + Assert.Equal("1f72c1111111111111f912e40b7323a0192a300b376186c10f6803dc5efe28df", verdictList[2].Sha256, true); } @@ -180,7 +180,7 @@ public async Task ForUrl_WithUrlWithStatusCode4xx_ThrowsVaasClientException() "Call failed with status code 404 (Not Found): GET https://upload.production.vaas.gdatasecurity.de/nocontenthere", e.Message); } - + [Fact] public async Task ForStream_WithEicarString_ReturnsMalicious() { @@ -190,14 +190,14 @@ public async Task ForStream_WithEicarString_ReturnsMalicious() var eicarBytes = System.Text.Encoding.UTF8.GetBytes("X5O!P%@AP[4\\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*"); targetStream.Write(eicarBytes, 0, eicarBytes.Length); targetStream.Position = 0; - + // Act var verdict = await vaas.ForStreamAsync(targetStream, CancellationToken.None); - + // Assert Assert.Equal(Verdict.Malicious, verdict.Verdict); } - + [Fact] public async Task ForStream_WithCleanString_ReturnsClean() { @@ -207,10 +207,10 @@ public async Task ForStream_WithCleanString_ReturnsClean() var cleanBytes = System.Text.Encoding.UTF8.GetBytes("This is a clean file"); targetStream.Write(cleanBytes, 0, cleanBytes.Length); targetStream.Position = 0; - + // Act var verdict = await vaas.ForStreamAsync(targetStream, CancellationToken.None); - + // Assert Assert.Equal(Verdict.Clean, verdict.Verdict); } @@ -223,14 +223,14 @@ public async Task ForStream_WithCleanUrl_ReturnsClean() var url = new Uri("https://raw.githubusercontent.com/GDATASoftwareAG/vaas/main/Readme.md"); var response = await _httpClient.SendAsync(new HttpRequestMessage(HttpMethod.Get, url), CancellationToken.None); var targetStream = await response.Content.ReadAsStreamAsync(); - + // Act var verdict = await vaas.ForStreamAsync(targetStream, CancellationToken.None); - + // Assert Assert.Equal(Verdict.Clean, verdict.Verdict); } - + [Fact] public async Task ForStream_WithEicarUrl_ReturnsEicar() { @@ -239,10 +239,10 @@ public async Task ForStream_WithEicarUrl_ReturnsEicar() var url = new Uri("https://secure.eicar.org/eicar.com.txt"); var response = await _httpClient.SendAsync(new HttpRequestMessage(HttpMethod.Get, url), CancellationToken.None); var targetStream = await response.Content.ReadAsStreamAsync(); - + // Act var verdict = await vaas.ForStreamAsync(targetStream, CancellationToken.None); - + // Assert Assert.Equal(Verdict.Malicious, verdict.Verdict); } @@ -305,7 +305,7 @@ public async Task Connect_WithResourceOwnerPasswordGrantAuthenticator() var vaas = provider.GetRequiredService(); await vaas.Connect(CancellationToken.None); } - + [Fact] public async Task ForStream_WithEicarUrl_ReturnsMaliciousWithDetectionsAndMimeType() { @@ -313,24 +313,24 @@ public async Task ForStream_WithEicarUrl_ReturnsMaliciousWithDetectionsAndMimeTy var url = new Uri("https://secure.eicar.org/eicar.com.txt"); var response = await _httpClient.SendAsync(new HttpRequestMessage(HttpMethod.Get, url), CancellationToken.None); var targetStream = await response.Content.ReadAsStreamAsync(); - + var verdict = await vaas.ForStreamAsync(targetStream, CancellationToken.None); - + Assert.Equal(Verdict.Malicious, verdict.Verdict); Assert.NotNull(verdict.LibMagic); Assert.NotNull(verdict.Detections); Assert.Equal("text/plain", verdict.LibMagic.MimeType); Assert.Contains(verdict.Detections, detection => detection.Virus == "EICAR_TEST_FILE"); } - + [Fact] public async Task ForUrl_WithEicarUrl_ReturnsMaliciousWithDetectionAndMimeType() { var vaas = await AuthenticateWithCredentials(); var uri = new Uri("https://secure.eicar.org/eicar.com"); - + var verdict = await vaas.ForUrlAsync(uri, CancellationToken.None); - + Assert.Equal(Verdict.Malicious, verdict.Verdict); Assert.NotNull(verdict.LibMagic); Assert.NotNull(verdict.Detections); diff --git a/golang/vaas/pkg/vaas/vaas_test.go b/golang/vaas/pkg/vaas/vaas_test.go index 42f0e028..48b13a57 100644 --- a/golang/vaas/pkg/vaas/vaas_test.go +++ b/golang/vaas/pkg/vaas/vaas_test.go @@ -78,9 +78,9 @@ func (tf *testFixture) tearDown(t *testing.T) { func TestVaas_ForSha256(t *testing.T) { const ( - cleanSha256 string = "3A78F382E8E2968EC201B33178102E06DB72E4F2D1505E058A4613C1E977825C" - maliciousSha256 string = "00000b68934493af2f5954593fe8127b9dda6d4b520e78265aa5875623b58c9c" - unknownSha256 string = "110005c43196142f01d615a67b7da8a53cb0172f8e9317a2ec9a0a39a1da6fe9" + cleanSha256 string = "cd617c5c1b1ff1c94a52ab8cf07192654f271a3f8bad49490288131ccb9efc1e" + maliciousSha256 string = "ab5788279033b0a96f2d342e5f35159f103f69e0191dd391e036a1cd711791a2" + unknownSha256 string = "1f72c1111111111111f912e40b7323a0192a300b376186c10f6803dc5efe28df" ) type fields struct { testingOptions options.VaasOptions @@ -443,9 +443,9 @@ func TestVaas_ForSha256List(t *testing.T) { vaasClient := fixture.setUp(t) defer fixture.tearDown(t) - maliciousSha256 := strings.ToLower("00000b68934493af2f5954593fe8127b9dda6d4b520e78265aa5875623b58c9c") - cleanSha256 := strings.ToLower("3A78F382E8E2968EC201B33178102E06DB72E4F2D1505E058A4613C1E977825C") - unknownSha256 := strings.ToLower("110005c43196142f01d615a67b7da8a53cb0172f8e9317a2ec9a0a39a1da6fe9") + maliciousSha256 := strings.ToLower("ab5788279033b0a96f2d342e5f35159f103f69e0191dd391e036a1cd711791a2") + cleanSha256 := strings.ToLower("cd617c5c1b1ff1c94a52ab8cf07192654f271a3f8bad49490288131ccb9efc1e") + unknownSha256 := strings.ToLower("1f72c1111111111111f912e40b7323a0192a300b376186c10f6803dc5efe28df") verdicts, err := vaasClient.ForSha256List(context.Background(), []string{maliciousSha256, cleanSha256, unknownSha256}) if err != nil { diff --git a/java/src/test/java/de/gdata/test/integration/RealApiIntegrationTests.java b/java/src/test/java/de/gdata/test/integration/RealApiIntegrationTests.java index 0929e888..077a88ff 100644 --- a/java/src/test/java/de/gdata/test/integration/RealApiIntegrationTests.java +++ b/java/src/test/java/de/gdata/test/integration/RealApiIntegrationTests.java @@ -71,13 +71,13 @@ public void resourceOwnerPasswordAuthenticatorGetToken() throws Exception { @Test public void forSha256SingleMaliciousHash() throws Exception { var vaas = this.getVaasWithCredentials(); - var sha256 = new Sha256("000005c43196142f01d615a67b7da8a53cb0172f8e9317a2ec9a0a39a1da6fe8"); + var sha256 = new Sha256("ab5788279033b0a96f2d342e5f35159f103f69e0191dd391e036a1cd711791a2"); var verdict = vaas.forSha256(sha256); vaas.disconnect(); assertEquals(Verdict.MALICIOUS, verdict.getVerdict()); - assertTrue("000005c43196142f01d615a67b7da8a53cb0172f8e9317a2ec9a0a39a1da6fe8" + assertTrue("ab5788279033b0a96f2d342e5f35159f103f69e0191dd391e036a1cd711791a2" .equalsIgnoreCase(verdict.getSha256())); } @@ -134,11 +134,11 @@ public String getToken() throws IOException, InterruptedException { } @Test - public void forSha256MultipleMaliciousHash() throws Exception { + public void forSha256MultipleHashes() throws Exception { var vaas = this.getVaasWithCredentials(); - var sha256_1 = new Sha256("000005c43196142f01d615a67b7da8a53cb0172f8e9317a2ec9a0a39a1da6fe8"); - var sha256_2 = new Sha256("00000b68934493af2f5954593fe8127b9dda6d4b520e78265aa5875623b58c9c"); - var sha256_3 = new Sha256("00000f83e3120f79a21b7b395dd3dd6a9c31ce00857f78d7cf487476ca75fd1a"); + var sha256_1 = new Sha256("ab5788279033b0a96f2d342e5f35159f103f69e0191dd391e036a1cd711791a2"); + var sha256_2 = new Sha256("cd617c5c1b1ff1c94a52ab8cf07192654f271a3f8bad49490288131ccb9efc1e"); + var sha256_3 = new Sha256("1f72c1111111111111f912e40b7323a0192a300b376186c10f6803dc5efe28df"); var verdict_1 = vaas.forSha256(sha256_1); var verdict_2 = vaas.forSha256(sha256_2); @@ -146,38 +146,14 @@ public void forSha256MultipleMaliciousHash() throws Exception { vaas.disconnect(); assertEquals(Verdict.MALICIOUS, verdict_1.getVerdict()); - assertEquals(Verdict.MALICIOUS, verdict_2.getVerdict()); - assertEquals(Verdict.MALICIOUS, verdict_3.getVerdict()); - - assertTrue("000005c43196142f01d615a67b7da8a53cb0172f8e9317a2ec9a0a39a1da6fe8" - .equalsIgnoreCase(verdict_1.getSha256())); - assertTrue("00000b68934493af2f5954593fe8127b9dda6d4b520e78265aa5875623b58c9c" - .equalsIgnoreCase(verdict_2.getSha256())); - assertTrue("00000f83e3120f79a21b7b395dd3dd6a9c31ce00857f78d7cf487476ca75fd1a" - .equalsIgnoreCase(verdict_3.getSha256())); - } - - @Test - public void forSha256MultipleCleanHash() throws Exception { - var vaas = this.getVaasWithCredentials(); - var sha256_1 = new Sha256("3A78F382E8E2968EC201B33178102E06DB72E4F2D1505E058A4613C1E977825C"); - var sha256_2 = new Sha256("1AFAFE9157FF5670BBEC8CE622F45D1CE51B3EE77B7348D3A237E232F06C5391"); - var sha256_3 = new Sha256("4447FAACEFABA8F040822101E2A4103031660DE9139E70ECFF9AA3A89455A783"); - - var verdict_1 = vaas.forSha256(sha256_1); - var verdict_2 = vaas.forSha256(sha256_2); - var verdict_3 = vaas.forSha256(sha256_3); - vaas.disconnect(); - - assertEquals(Verdict.CLEAN, verdict_1.getVerdict()); assertEquals(Verdict.CLEAN, verdict_2.getVerdict()); - assertEquals(Verdict.CLEAN, verdict_3.getVerdict()); + assertEquals(Verdict.UNKNOWN, verdict_3.getVerdict()); - assertTrue("3A78F382E8E2968EC201B33178102E06DB72E4F2D1505E058A4613C1E977825C" + assertTrue("ab5788279033b0a96f2d342e5f35159f103f69e0191dd391e036a1cd711791a2" .equalsIgnoreCase(verdict_1.getSha256())); - assertTrue("1AFAFE9157FF5670BBEC8CE622F45D1CE51B3EE77B7348D3A237E232F06C5391" + assertTrue("cd617c5c1b1ff1c94a52ab8cf07192654f271a3f8bad49490288131ccb9efc1e" .equalsIgnoreCase(verdict_2.getSha256())); - assertTrue("4447FAACEFABA8F040822101E2A4103031660DE9139E70ECFF9AA3A89455A783" + assertTrue("1f72c1111111111111f912e40b7323a0192a300b376186c10f6803dc5efe28df" .equalsIgnoreCase(verdict_3.getSha256())); } diff --git a/php/tests/vaas/VaasTest.php b/php/tests/vaas/VaasTest.php index 1723e18f..b4ad44db 100644 --- a/php/tests/vaas/VaasTest.php +++ b/php/tests/vaas/VaasTest.php @@ -34,7 +34,7 @@ final class VaasTest extends TestCase { use ProphecyTrait; - const MALICIOUS_HASH = "000005c43196142f01d615a67b7da8a53cb0172f8e9317a2ec9a0a39a1da6fe8"; + const MALICIOUS_HASH = "ab5788279033b0a96f2d342e5f35159f103f69e0191dd391e036a1cd711791a2"; const MALICIOUS_URL = "https://secure.eicar.org/eicar.com.txt"; public function setUp(): void @@ -162,39 +162,10 @@ public function testForSha256MaliciousSha256WithFlag_BothFlagsFalse_GetsMaliciou $this->assertEqualsIgnoringCase(self::MALICIOUS_HASH, $verdict->Sha256); } - public function testForMultipleMaliciousSha256_GetsMaliciousResponses(): void - { - $vaas = $this->_getVaas(); - $vaas->Connect($this->getClientCredentialsGrantAuthenticator()->getToken()); - - $uuid1 = $this->getUuid(); - $sha256_1 = "000005c43196142f01d615a67b7da8a53cb0172f8e9317a2ec9a0a39a1da6fe8"; - $uuid2 = $this->getUuid(); - $sha256_2 = "00000b68934493af2f5954593fe8127b9dda6d4b520e78265aa5875623b58c9c"; - $uuid3 = $this->getUuid(); - $sha256_3 = "00000f83e3120f79a21b7b395dd3dd6a9c31ce00857f78d7cf487476ca75fd1a"; - - $verdict1 = $vaas->ForSha256($sha256_1, $uuid1); - $verdict2 = $vaas->ForSha256($sha256_2, $uuid2); - $verdict3 = $vaas->ForSha256($sha256_3, $uuid3); - - $this->assertEquals(Verdict::MALICIOUS, $verdict1->Verdict); - $this->assertEquals($uuid1, $verdict1->Guid); - $this->assertEqualsIgnoringCase($sha256_1, $verdict1->Sha256); - - $this->assertEquals(Verdict::MALICIOUS, $verdict2->Verdict); - $this->assertEquals($uuid2, $verdict2->Guid); - $this->assertEqualsIgnoringCase($sha256_2, $verdict2->Sha256); - - $this->assertEquals(Verdict::MALICIOUS, $verdict3->Verdict); - $this->assertEquals($uuid3, $verdict3->Guid); - $this->assertEqualsIgnoringCase($sha256_3, $verdict3->Sha256); - } - public function testForSha256CleanSha256_GetsCleanResponse(): void { $uuid = $this->getUuid(); - $cleanSha256 = "3A78F382E8E2968EC201B33178102E06DB72E4F2D1505E058A4613C1E977825C"; + $cleanSha256 = "cd617c5c1b1ff1c94a52ab8cf07192654f271a3f8bad49490288131ccb9efc1e"; $vaas = $this->_getVaas(); $vaas->Connect($this->getClientCredentialsGrantAuthenticator()->getToken()); @@ -219,14 +190,14 @@ public function testForSha256CleanSha256_GetsCleanResponse(): void // $this->assertEqualsIgnoringCase($pupSha256, $verdict->Sha256); // } - public function testForMultipleCleanFiles_GetsCleanResponses(): void + public function testForMultipleHashes_GetsResponse(): void { $uuid1 = $this->getUuid(); $uuid2 = $this->getUuid(); $uuid3 = $this->getUuid(); - $cleanHash1 = "3A78F382E8E2968EC201B33178102E06DB72E4F2D1505E058A4613C1E977825C"; - $cleanHash2 = "1AFAFE9157FF5670BBEC8CE622F45D1CE51B3EE77B7348D3A237E232F06C5391"; - $cleanHash3 = "4447FAACEFABA8F040822101E2A4103031660DE9139E70ECFF9AA3A89455A783"; + $cleanHash1 = "ab5788279033b0a96f2d342e5f35159f103f69e0191dd391e036a1cd711791a2"; + $cleanHash2 = "cd617c5c1b1ff1c94a52ab8cf07192654f271a3f8bad49490288131ccb9efc1e"; + $cleanHash3 = "1f72c1111111111111f912e40b7323a0192a300b376186c10f6803dc5efe28df"; $vaas = $this->_getVaas(); $vaas->Connect($this->getClientCredentialsGrantAuthenticator()->getToken()); @@ -235,13 +206,13 @@ public function testForMultipleCleanFiles_GetsCleanResponses(): void $verdict2 = $vaas->ForSha256($cleanHash2, $uuid2); $verdict3 = $vaas->ForSha256($cleanHash3, $uuid3); - $this->assertEquals(Verdict::CLEAN, $verdict1->Verdict); + $this->assertEquals(Verdict::MALICIOUS, $verdict1->Verdict); $this->assertEquals($uuid1, $verdict1->Guid); $this->assertEqualsIgnoringCase($cleanHash1, $verdict1->Sha256); $this->assertEquals(Verdict::CLEAN, $verdict2->Verdict); $this->assertEquals($uuid2, $verdict2->Guid); $this->assertEqualsIgnoringCase($cleanHash2, $verdict2->Sha256); - $this->assertEquals(Verdict::CLEAN, $verdict3->Verdict); + $this->assertEquals(Verdict::UNKNOWN, $verdict3->Verdict); $this->assertEquals($uuid3, $verdict3->Guid); $this->assertEqualsIgnoringCase($cleanHash3, $verdict3->Sha256); } diff --git a/python/tests/test_vaas.py b/python/tests/test_vaas.py index f7083dfb..2112a6c8 100644 --- a/python/tests/test_vaas.py +++ b/python/tests/test_vaas.py @@ -58,12 +58,12 @@ async def test_connects(self): async def test_for_sha256_returns_clean_for_clean_sha256(self): async with await create_and_connect() as vaas: verdict = await vaas.for_sha256( - "3A78F382E8E2968EC201B33178102E06DB72E4F2D1505E058A4613C1E977825C" + "cd617c5c1b1ff1c94a52ab8cf07192654f271a3f8bad49490288131ccb9efc1e" ) self.assertEqual(verdict["Verdict"], "Clean") self.assertEqual( verdict["Sha256"].casefold(), - "3A78F382E8E2968EC201B33178102E06DB72E4F2D1505E058A4613C1E977825C".casefold(), + "cd617c5c1b1ff1c94a52ab8cf07192654f271a3f8bad49490288131ccb9efc1e".casefold(), ) async def test_use_for_sha256_when_connection_already_closed(self): diff --git a/ruby/test/vaas_test.rb b/ruby/test/vaas_test.rb index 64fce7af..d8f316a8 100644 --- a/ruby/test/vaas_test.rb +++ b/ruby/test/vaas_test.rb @@ -45,7 +45,7 @@ def create(token = nil, timeout = nil) Async do vaas.connect(token) - result = vaas.for_sha256("275a021bbfb6489e54d471899f7db9d1663fc695ec2fe2a2c4538aabf651fd0f") + result = vaas.for_sha256("ab5788279033b0a96f2d342e5f35159f103f69e0191dd391e036a1cd711791a2") verdict = result.wait.verdict assert_equal "Malicious", verdict @@ -127,7 +127,7 @@ def create(token = nil, timeout = nil) specify 'not_connected' do vaas = VAAS::VaasMain.new assert_raises VAAS::VaasInvalidStateError do - vaas.for_sha256("275a021bbfb6489e54d471899f7db9d1663fc695ec2fe2a2c4538aabf651fd0f").wait + vaas.for_sha256("ab5788279033b0a96f2d342e5f35159f103f69e0191dd391e036a1cd711791a2").wait end end @@ -147,7 +147,7 @@ def create(token = nil, timeout = nil) vaas.connect(token) vaas.close assert_raises VAAS::VaasConnectionClosedError do - vaas.for_sha256("275a021bbfb6489e54d471899f7db9d1663fc695ec2fe2a2c4538aabf651fd0f").wait + vaas.for_sha256("ab5788279033b0a96f2d342e5f35159f103f69e0191dd391e036a1cd711791a2").wait end end end diff --git a/rust/tests/real_api_integration_tests.rs b/rust/tests/real_api_integration_tests.rs index 73d8afc0..14b26ca7 100644 --- a/rust/tests/real_api_integration_tests.rs +++ b/rust/tests/real_api_integration_tests.rs @@ -63,13 +63,13 @@ async fn from_sha256_list_multiple_hashes() { let vaas = get_vaas().await; let ct = CancellationToken::from_seconds(10); let sha256_malicious = - Sha256::try_from("000005c43196142f01d615a67b7da8a53cb0172f8e9317a2ec9a0a39a1da6fe8") + Sha256::try_from("ab5788279033b0a96f2d342e5f35159f103f69e0191dd391e036a1cd711791a2") .unwrap(); let sha256_clean = - Sha256::try_from("3A78F382E8E2968EC201B33178102E06DB72E4F2D1505E058A4613C1E977825C") + Sha256::try_from("cd617c5c1b1ff1c94a52ab8cf07192654f271a3f8bad49490288131ccb9efc1e") .unwrap(); let sha256_unknown = - Sha256::try_from("00000f83e3120f79a21b7b395dd3dd6a9c31ce00857f78d7cf487476ca75fbbb") + Sha256::try_from("1f72c1111111111111f912e40b7323a0192a300b376186c10f6803dc5efe28df") .unwrap(); let sha256_list = vec![ sha256_malicious.clone(), @@ -81,12 +81,12 @@ async fn from_sha256_list_multiple_hashes() { assert_eq!(Verdict::Malicious, results[0].as_ref().unwrap().verdict); assert_eq!( - "000005c43196142f01d615a67b7da8a53cb0172f8e9317a2ec9a0a39a1da6fe8", + "ab5788279033b0a96f2d342e5f35159f103f69e0191dd391e036a1cd711791a2", results[0].as_ref().unwrap().sha256.deref() ); assert_eq!(Verdict::Clean, results[1].as_ref().unwrap().verdict); assert_eq!( - "3A78F382E8E2968EC201B33178102E06DB72E4F2D1505E058A4613C1E977825C".to_lowercase(), + "cd617c5c1b1ff1c94a52ab8cf07192654f271a3f8bad49490288131ccb9efc1e".to_lowercase(), results[1].as_ref().unwrap().sha256.deref() ); assert!(matches!( @@ -94,7 +94,7 @@ async fn from_sha256_list_multiple_hashes() { Verdict::Unknown { .. } )); assert_eq!( - "00000f83e3120f79a21b7b395dd3dd6a9c31ce00857f78d7cf487476ca75fbbb", + "1f72c1111111111111f912e40b7323a0192a300b376186c10f6803dc5efe28df", results[2].as_ref().unwrap().sha256.deref() ); } @@ -104,14 +104,14 @@ async fn from_sha256_single_malicious_hash() { let vaas = get_vaas().await; let ct = CancellationToken::from_seconds(10); let sha256 = - Sha256::try_from("000005c43196142f01d615a67b7da8a53cb0172f8e9317a2ec9a0a39a1da6fe8") + Sha256::try_from("ab5788279033b0a96f2d342e5f35159f103f69e0191dd391e036a1cd711791a2") .unwrap(); let verdict = vaas.for_sha256(&sha256, &ct).await; assert_eq!(Verdict::Malicious, verdict.as_ref().unwrap().verdict); assert_eq!( - "000005c43196142f01d615a67b7da8a53cb0172f8e9317a2ec9a0a39a1da6fe8", + "ab5788279033b0a96f2d342e5f35159f103f69e0191dd391e036a1cd711791a2", verdict.unwrap().sha256.deref() ); } @@ -198,33 +198,25 @@ async fn from_sha256_multiple_malicious_hash() { let vaas = get_vaas().await; let ct = CancellationToken::from_seconds(10); let sha256_1 = - Sha256::try_from("000005c43196142f01d615a67b7da8a53cb0172f8e9317a2ec9a0a39a1da6fe8") + Sha256::try_from("ab5788279033b0a96f2d342e5f35159f103f69e0191dd391e036a1cd711791a2") .unwrap(); let sha256_2 = - Sha256::try_from("00000b68934493af2f5954593fe8127b9dda6d4b520e78265aa5875623b58c9c") - .unwrap(); - let sha256_3 = - Sha256::try_from("00000f83e3120f79a21b7b395dd3dd6a9c31ce00857f78d7cf487476ca75fd1a") + Sha256::try_from("cd617c5c1b1ff1c94a52ab8cf07192654f271a3f8bad49490288131ccb9efc1e") .unwrap(); + let verdict_1 = vaas.for_sha256(&sha256_1, &ct).await; let verdict_2 = vaas.for_sha256(&sha256_2, &ct).await; - let verdict_3 = vaas.for_sha256(&sha256_3, &ct).await; assert_eq!( - "000005c43196142f01d615a67b7da8a53cb0172f8e9317a2ec9a0a39a1da6fe8", + "ab5788279033b0a96f2d342e5f35159f103f69e0191dd391e036a1cd711791a2", verdict_1.as_ref().unwrap().sha256.deref() ); assert_eq!(Verdict::Malicious, verdict_1.unwrap().verdict); assert_eq!( - "00000b68934493af2f5954593fe8127b9dda6d4b520e78265aa5875623b58c9c", + "cd617c5c1b1ff1c94a52ab8cf07192654f271a3f8bad49490288131ccb9efc1e", verdict_2.as_ref().unwrap().sha256.deref() ); - assert_eq!(Verdict::Malicious, verdict_2.unwrap().verdict); - assert_eq!( - "00000f83e3120f79a21b7b395dd3dd6a9c31ce00857f78d7cf487476ca75fd1a", - verdict_3.as_ref().unwrap().sha256.deref() - ); - assert_eq!(Verdict::Malicious, verdict_3.unwrap().verdict); + assert_eq!(Verdict::Clean, verdict_2.unwrap().verdict); } #[tokio::test] @@ -232,67 +224,24 @@ async fn from_sha256_multiple_malicious_hash_without_cache() { let vaas = get_vaas_with_flags(false, true).await; let ct = CancellationToken::from_seconds(10); let sha256_1 = - Sha256::try_from("000005c43196142f01d615a67b7da8a53cb0172f8e9317a2ec9a0a39a1da6fe8") + Sha256::try_from("ab5788279033b0a96f2d342e5f35159f103f69e0191dd391e036a1cd711791a2") .unwrap(); let sha256_2 = - Sha256::try_from("00000b68934493af2f5954593fe8127b9dda6d4b520e78265aa5875623b58c9c") - .unwrap(); - let sha256_3 = - Sha256::try_from("00000f83e3120f79a21b7b395dd3dd6a9c31ce00857f78d7cf487476ca75fd1a") + Sha256::try_from("cd617c5c1b1ff1c94a52ab8cf07192654f271a3f8bad49490288131ccb9efc1e") .unwrap(); let verdict_1 = vaas.for_sha256(&sha256_1, &ct).await; let verdict_2 = vaas.for_sha256(&sha256_2, &ct).await; - let verdict_3 = vaas.for_sha256(&sha256_3, &ct).await; assert_eq!( - "000005c43196142f01d615a67b7da8a53cb0172f8e9317a2ec9a0a39a1da6fe8", + "ab5788279033b0a96f2d342e5f35159f103f69e0191dd391e036a1cd711791a2", verdict_1.as_ref().unwrap().sha256.deref() ); assert_eq!(Verdict::Malicious, verdict_1.unwrap().verdict); assert_eq!( - "00000b68934493af2f5954593fe8127b9dda6d4b520e78265aa5875623b58c9c", + "cd617c5c1b1ff1c94a52ab8cf07192654f271a3f8bad49490288131ccb9efc1e", verdict_2.as_ref().unwrap().sha256.deref() ); - assert_eq!(Verdict::Malicious, verdict_2.unwrap().verdict); - assert_eq!( - "00000f83e3120f79a21b7b395dd3dd6a9c31ce00857f78d7cf487476ca75fd1a", - verdict_3.as_ref().unwrap().sha256.deref() - ); - assert_eq!(Verdict::Malicious, verdict_3.unwrap().verdict); -} - -#[tokio::test] -async fn from_sha256_multiple_clean_hash() { - let vaas = get_vaas().await; - let ct = CancellationToken::from_seconds(10); - let sha256_1 = - Sha256::try_from("3A78F382E8E2968EC201B33178102E06DB72E4F2D1505E058A4613C1E977825C") - .unwrap(); - let sha256_2 = - Sha256::try_from("1AFAFE9157FF5670BBEC8CE622F45D1CE51B3EE77B7348D3A237E232F06C5391") - .unwrap(); - let sha256_3 = - Sha256::try_from("4447FAACEFABA8F040822101E2A4103031660DE9139E70ECFF9AA3A89455A783") - .unwrap(); - let verdict_1 = vaas.for_sha256(&sha256_1, &ct).await; - let verdict_2 = vaas.for_sha256(&sha256_2, &ct).await; - let verdict_3 = vaas.for_sha256(&sha256_3, &ct).await; - - assert_eq!(Verdict::Clean, verdict_1.as_ref().unwrap().verdict); - assert_eq!( - "3A78F382E8E2968EC201B33178102E06DB72E4F2D1505E058A4613C1E977825C".to_lowercase(), - verdict_1.unwrap().sha256.deref() - ); - assert_eq!(Verdict::Clean, verdict_2.as_ref().unwrap().verdict); - assert_eq!( - "1AFAFE9157FF5670BBEC8CE622F45D1CE51B3EE77B7348D3A237E232F06C5391".to_lowercase(), - verdict_2.unwrap().sha256.deref() - ); - assert_eq!(Verdict::Clean, verdict_3.as_ref().unwrap().verdict); - assert_eq!( - "4447FAACEFABA8F040822101E2A4103031660DE9139E70ECFF9AA3A89455A783".to_lowercase(), - verdict_3.unwrap().sha256.deref() - ); + assert_eq!(Verdict::Clean, verdict_2.unwrap().verdict); } #[tokio::test] @@ -500,27 +449,22 @@ async fn from_sha256_multiple_clean_hash_on_separate_thread() { let vaas = get_vaas().await; let ct = CancellationToken::from_seconds(10); let sha256_1 = - Sha256::try_from("3A78F382E8E2968EC201B33178102E06DB72E4F2D1505E058A4613C1E977825C") + Sha256::try_from("ab5788279033b0a96f2d342e5f35159f103f69e0191dd391e036a1cd711791a2") .unwrap(); let sha256_2 = - Sha256::try_from("1AFAFE9157FF5670BBEC8CE622F45D1CE51B3EE77B7348D3A237E232F06C5391") - .unwrap(); - let sha256_3 = - Sha256::try_from("4447FAACEFABA8F040822101E2A4103031660DE9139E70ECFF9AA3A89455A783") + Sha256::try_from("cd617c5c1b1ff1c94a52ab8cf07192654f271a3f8bad49490288131ccb9efc1e") .unwrap(); - let (v1, v2, v3) = tokio::spawn(async move { + let (v1, v2) = tokio::spawn(async move { let v1 = vaas.for_sha256(&sha256_1, &ct).await; let v2 = vaas.for_sha256(&sha256_2, &ct).await; - let v3 = vaas.for_sha256(&sha256_3, &ct).await; - (v1, v2, v3) + (v1, v2) }) .await .unwrap(); - assert_eq!(Verdict::Clean, v1.unwrap().verdict); + assert_eq!(Verdict::Malicious, v1.unwrap().verdict); assert_eq!(Verdict::Clean, v2.unwrap().verdict); - assert_eq!(Verdict::Clean, v3.unwrap().verdict); } #[tokio::test] @@ -528,23 +472,18 @@ async fn from_sha256_multiple_clean_hash_await_concurrent_fixed_jobs() { let vaas = get_vaas().await; let ct = CancellationToken::from_seconds(10); let sha256_1 = - Sha256::try_from("3A78F382E8E2968EC201B33178102E06DB72E4F2D1505E058A4613C1E977825C") + Sha256::try_from("ab5788279033b0a96f2d342e5f35159f103f69e0191dd391e036a1cd711791a2") .unwrap(); let sha256_2 = - Sha256::try_from("1AFAFE9157FF5670BBEC8CE622F45D1CE51B3EE77B7348D3A237E232F06C5391") - .unwrap(); - let sha256_3 = - Sha256::try_from("4447FAACEFABA8F040822101E2A4103031660DE9139E70ECFF9AA3A89455A783") + Sha256::try_from("cd617c5c1b1ff1c94a52ab8cf07192654f271a3f8bad49490288131ccb9efc1e") .unwrap(); let v1 = vaas.for_sha256(&sha256_1, &ct); let v2 = vaas.for_sha256(&sha256_2, &ct); - let v3 = vaas.for_sha256(&sha256_3, &ct); - let (v1, v2, v3) = tokio::join!(v1, v2, v3); - assert_eq!(Verdict::Clean, v1.unwrap().verdict); + let (v1, v2) = tokio::join!(v1, v2); + assert_eq!(Verdict::Malicious, v1.unwrap().verdict); assert_eq!(Verdict::Clean, v2.unwrap().verdict); - assert_eq!(Verdict::Clean, v3.unwrap().verdict); } #[tokio::test] @@ -552,27 +491,22 @@ async fn from_sha256_multiple_clean_hash_await_concurrent_unknown_jobs() { let vaas = get_vaas().await; let ct = CancellationToken::from_seconds(10); let sha256_1 = - Sha256::try_from("3A78F382E8E2968EC201B33178102E06DB72E4F2D1505E058A4613C1E977825C") + Sha256::try_from("ab5788279033b0a96f2d342e5f35159f103f69e0191dd391e036a1cd711791a2") .unwrap(); let sha256_2 = - Sha256::try_from("1AFAFE9157FF5670BBEC8CE622F45D1CE51B3EE77B7348D3A237E232F06C5391") - .unwrap(); - let sha256_3 = - Sha256::try_from("4447FAACEFABA8F040822101E2A4103031660DE9139E70ECFF9AA3A89455A783") + Sha256::try_from("cd617c5c1b1ff1c94a52ab8cf07192654f271a3f8bad49490288131ccb9efc1e") .unwrap(); let handles = vec![ vaas.for_sha256(&sha256_1, &ct), vaas.for_sha256(&sha256_2, &ct), - vaas.for_sha256(&sha256_3, &ct), ]; let result = try_join_all(handles).await; let verdicts = result.unwrap(); - assert_eq!(Verdict::Clean, verdicts[0].verdict); + assert_eq!(Verdict::Malicious, verdicts[0].verdict); assert_eq!(Verdict::Clean, verdicts[1].verdict); - assert_eq!(Verdict::Clean, verdicts[2].verdict); } #[tokio::test] diff --git a/typescript/tests/test.ts b/typescript/tests/test.ts index d59bb371..e02d424a 100644 --- a/typescript/tests/test.ts +++ b/typescript/tests/test.ts @@ -121,11 +121,11 @@ describe("Test verdict requests", function () { it('if a clean SHA256 is submitted, a verdict "clean" is expected', async () => { const vaas = await createVaasWithClientCredentialsGrantAuthenticator(); const verdict = await vaas.forSha256( - "3A78F382E8E2968EC201B33178102E06DB72E4F2D1505E058A4613C1E977825C", + "cd617c5c1b1ff1c94a52ab8cf07192654f271a3f8bad49490288131ccb9efc1e", ); expect(verdict.verdict).to.equal("Clean"); expect(verdict.sha256.toUpperCase()).to.equal( - "3A78F382E8E2968EC201B33178102E06DB72E4F2D1505E058A4613C1E977825C", + "cd617c5c1b1ff1c94a52ab8cf07192654f271a3f8bad49490288131ccb9efc1e".toUpperCase(), ); }); @@ -164,16 +164,16 @@ describe("Test verdict requests", function () { it("if a list of SHA256 is uploaded, they are detected", async () => { const vaas = await createVaasWithClientCredentialsGrantAuthenticator(); const verdicts = await vaas.forSha256List([ - "275a021bbfb6489e54d471899f7db9d1663fc695ec2fe2a2c4538aabf651fd0f", - "3A78F382E8E2968EC201B33178102E06DB72E4F2D1505E058A4613C1E977825C", + "ab5788279033b0a96f2d342e5f35159f103f69e0191dd391e036a1cd711791a2", + "cd617c5c1b1ff1c94a52ab8cf07192654f271a3f8bad49490288131ccb9efc1e", ]); expect(verdicts[0].verdict).to.equal("Malicious"); expect(verdicts[0].sha256).to.equal( - "275a021bbfb6489e54d471899f7db9d1663fc695ec2fe2a2c4538aabf651fd0f", + "ab5788279033b0a96f2d342e5f35159f103f69e0191dd391e036a1cd711791a2", ); expect(verdicts[1].verdict).to.equal("Clean"); - expect(verdicts[1].sha256.toUpperCase()).to.equal( - "3A78F382E8E2968EC201B33178102E06DB72E4F2D1505E058A4613C1E977825C", + expect(verdicts[1].sha256).to.equal( + "cd617c5c1b1ff1c94a52ab8cf07192654f271a3f8bad49490288131ccb9efc1e", ); }); @@ -205,18 +205,18 @@ describe("Test verdict requests", function () { it("if we request the same guid twice, both calls return a result", async () => { const vaas = await createVaasWithClientCredentialsGrantAuthenticator(); const sha256 = - "3A78F382E8E2968EC201B33178102E06DB72E4F2D1505E058A4613C1E977825C"; + "cd617c5c1b1ff1c94a52ab8cf07192654f271a3f8bad49490288131ccb9efc1e"; const request1 = vaas.forSha256(sha256); const request2 = vaas.forSha256(sha256); const verdict1 = await request1; const verdict2 = await request2; expect(verdict1.verdict).to.equal("Clean"); - expect(verdict1.sha256.toUpperCase()).to.equal( - "3A78F382E8E2968EC201B33178102E06DB72E4F2D1505E058A4613C1E977825C", + expect(verdict1.sha256).to.equal( + "cd617c5c1b1ff1c94a52ab8cf07192654f271a3f8bad49490288131ccb9efc1e", ); expect(verdict2.verdict).to.equal("Clean"); - expect(verdict2.sha256.toUpperCase()).to.equal( - "3A78F382E8E2968EC201B33178102E06DB72E4F2D1505E058A4613C1E977825C", + expect(verdict2.sha256).to.equal( + "cd617c5c1b1ff1c94a52ab8cf07192654f271a3f8bad49490288131ccb9efc1e", ); }); //www.virustotal.com/gui/file/edb6991d68ba5c7ed43f198c3d2593c770f2634beeb8c83afe3138279e5e81f3