Exemplo n.º 1
0
        public void Should_be_able_to_retrieve_well_known_hash()
        {
            var configuration = OpswatSection.Configuration();
            var api           = new OpswatApi(configuration);

            var response =
                api.GetResponse(
                    new RestRequest(api.GetFullApiUrl("hash/6A5C19D9FFE8804586E8F4C0DFCC66DE"),
                                    DataFormat.Json))
                .AsDynamic();

            Assert.That(response.scan_results.scan_all_result_a.ToString(), Is.EqualTo("Infected"));
        }
Exemplo n.º 2
0
        public void Should_be_able_to_handle_a_macro_enabled_spreadsheet()
        {
            var configuration = OpswatSection.Configuration();
            var service       = new OpswatMalwareService(configuration, new OpswatApi(configuration));

            var document = new Document(Guid.NewGuid(), Guid.NewGuid(), "sanitize.xlsx",
                                        "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
                                        File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ".files\\sanitize.xlsm")),
                                        "integration-test", "system", DateTime.Now);

            service.Register(document);

            Assert.That(document.ContainsProperty("data_id"), Is.True);
            Assert.That(document.ContainsProperty("sha256"), Is.True);
            Assert.That(document.ContainsProperty("in_queue"), Is.True);
            Assert.That(document.GetPropertyValue("status"), Is.EqualTo("inqueue"));

            Assert.That(document.ContainsProperty("scan_all_result_i"), Is.False);
            Assert.That(document.ContainsProperty("scan_all_result_a"), Is.False);
            Assert.That(document.ContainsProperty("progress_percentage"), Is.False);
            Assert.That(document.ContainsProperty("PollIntervalTimespan"), Is.False);

            Poll(service, document, 120);

            Assert.That(document.ContainsProperty("data_id"), Is.True);

            if (configuration.ShouldSandbox(".xlsx"))
            {
                Assert.That(document.ContainsProperty("sandbox_id"), Is.True);
            }

            Assert.That(document.ContainsProperty("in_queue"), Is.False);
            Assert.That(document.ContainsProperty("status"), Is.False);
            Assert.That(document.ContainsProperty("PollIntervalTimespan"), Is.False);

            Assert.That(document.GetPropertyValue("scan_all_result_i"), Is.EqualTo("0"));
            Assert.That(document.GetPropertyValue("scan_all_result_a").ToLowerInvariant(),
                        Is.EqualTo("no threat detected"));
            Assert.That(document.GetPropertyValue("progress_percentage"), Is.EqualTo("100"));
        }