Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Unified Diff: chrome/browser/safe_browsing/sandboxed_zip_analyzer_unittest.cc

Issue 1262753002: [SafeBrowsing] Send pings for Zip files that contain other archives. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/sandboxed_zip_analyzer_unittest.cc
diff --git a/chrome/browser/safe_browsing/sandboxed_zip_analyzer_unittest.cc b/chrome/browser/safe_browsing/sandboxed_zip_analyzer_unittest.cc
index db9cebf9e4bdf364c567b5e4083e729d61d4f65c..35a9136768e01a14a0d93867a215cfe8d9887143 100644
--- a/chrome/browser/safe_browsing/sandboxed_zip_analyzer_unittest.cc
+++ b/chrome/browser/safe_browsing/sandboxed_zip_analyzer_unittest.cc
@@ -117,8 +117,10 @@ class SandboxedZipAnalyzerTest : public ::testing::Test {
static const uint8_t kUnsignedDigest[];
static const uint8_t kSignedDigest[];
+ static const uint8_t kJSEFileDigest[];
static const BinaryData kUnsignedExe;
static const BinaryData kSignedExe;
+ static const BinaryData kJSEFile;
base::FilePath dir_test_data_;
content::TestBrowserThreadBundle browser_thread_bundle_;
@@ -127,15 +129,17 @@ class SandboxedZipAnalyzerTest : public ::testing::Test {
// static
const uint8_t SandboxedZipAnalyzerTest::kUnsignedDigest[] = {
- 0x1e, 0x95, 0x4d, 0x9c, 0xe0, 0x38, 0x9e, 0x2b, 0xa7, 0x44, 0x72, 0x16,
- 0xf2, 0x17, 0x61, 0xf9, 0x8d, 0x1e, 0x65, 0x40, 0xc2, 0xab, 0xec, 0xdb,
- 0xec, 0xff, 0x57, 0x0e, 0x36, 0xc4, 0x93, 0xdb
-};
+ 0x1e, 0x95, 0x4d, 0x9c, 0xe0, 0x38, 0x9e, 0x2b, 0xa7, 0x44, 0x72,
+ 0x16, 0xf2, 0x17, 0x61, 0xf9, 0x8d, 0x1e, 0x65, 0x40, 0xc2, 0xab,
+ 0xec, 0xdb, 0xec, 0xff, 0x57, 0x0e, 0x36, 0xc4, 0x93, 0xdb};
const uint8_t SandboxedZipAnalyzerTest::kSignedDigest[] = {
- 0xe1, 0x1f, 0xfa, 0x0c, 0x9f, 0x25, 0x23, 0x44, 0x53, 0xa9, 0xed, 0xd1,
- 0xcb, 0x25, 0x1d, 0x46, 0x10, 0x7f, 0x34, 0xb5, 0x36, 0xad, 0x74, 0x64,
- 0x2a, 0x85, 0x84, 0xac, 0xa8, 0xc1, 0xa8, 0xce
-};
+ 0xe1, 0x1f, 0xfa, 0x0c, 0x9f, 0x25, 0x23, 0x44, 0x53, 0xa9, 0xed,
+ 0xd1, 0xcb, 0x25, 0x1d, 0x46, 0x10, 0x7f, 0x34, 0xb5, 0x36, 0xad,
+ 0x74, 0x64, 0x2a, 0x85, 0x84, 0xac, 0xa8, 0xc1, 0xa8, 0xce};
+const uint8_t SandboxedZipAnalyzerTest::kJSEFileDigest[] = {
+ 0x58, 0x91, 0xb5, 0xb5, 0x22, 0xd5, 0xdf, 0x08, 0x6d, 0x0f, 0xf0,
+ 0xb1, 0x10, 0xfb, 0xd9, 0xd2, 0x1b, 0xb4, 0xfc, 0x71, 0x63, 0xaf,
+ 0x34, 0xd0, 0x82, 0x86, 0xa2, 0xe8, 0x46, 0xf6, 0xbe, 0x03};
const SandboxedZipAnalyzerTest::BinaryData
SandboxedZipAnalyzerTest::kUnsignedExe = {
"unsigned.exe",
@@ -153,6 +157,15 @@ const SandboxedZipAnalyzerTest::BinaryData
true, // is_signed
};
+const SandboxedZipAnalyzerTest::BinaryData
+SandboxedZipAnalyzerTest::kJSEFile = {
+ "hello.jse",
+ ClientDownloadRequest_DownloadType_WIN_EXECUTABLE,
+ &kJSEFileDigest[0],
+ 6,
+ false, // is_signed
+};
+
TEST_F(SandboxedZipAnalyzerTest, NoBinaries) {
zip_analyzer::Results results;
RunAnalyzer(dir_test_data_.AppendASCII("zipfile_no_binaries.zip"), &results);
@@ -185,4 +198,46 @@ TEST_F(SandboxedZipAnalyzerTest, TwoBinariesOneSigned) {
ExpectBinary(kSignedExe, results.archived_binary.Get(1));
}
+TEST_F(SandboxedZipAnalyzerTest, ZippedArchiveNoBinaries) {
+ zip_analyzer::Results results;
+ RunAnalyzer(dir_test_data_.AppendASCII("zipfile_archive_no_binaries.zip"),
+ &results);
+ ASSERT_TRUE(results.success);
+ EXPECT_FALSE(results.has_executable);
+ EXPECT_TRUE(results.has_archive);
+ EXPECT_EQ(0, results.archived_binary.size());
+}
+
+TEST_F(SandboxedZipAnalyzerTest, ZippedRarArchiveNoBinaries) {
+ zip_analyzer::Results results;
+ RunAnalyzer(dir_test_data_.AppendASCII("zipfile_rar_archive_no_binaries.zip"),
+ &results);
+ ASSERT_TRUE(results.success);
+ EXPECT_FALSE(results.has_executable);
+ EXPECT_TRUE(results.has_archive);
+ EXPECT_EQ(0, results.archived_binary.size());
+}
+
+TEST_F(SandboxedZipAnalyzerTest, ZippedArchiveAndBinaries) {
+ zip_analyzer::Results results;
+ RunAnalyzer(dir_test_data_.AppendASCII("zipfile_archive_and_binaries.zip"),
+ &results);
+ ASSERT_TRUE(results.success);
+ EXPECT_TRUE(results.has_executable);
+ EXPECT_TRUE(results.has_archive);
+ ASSERT_EQ(1, results.archived_binary.size());
+ ExpectBinary(kSignedExe, results.archived_binary.Get(0));
+}
+
+TEST_F(SandboxedZipAnalyzerTest, ZippedJSEFile) {
+ zip_analyzer::Results results;
+ RunAnalyzer(dir_test_data_.AppendASCII("zipfile_one_jse_file.zip"),
+ &results);
+ ASSERT_TRUE(results.success);
+ EXPECT_TRUE(results.has_executable);
+ EXPECT_FALSE(results.has_archive);
+ ASSERT_EQ(1, results.archived_binary.size());
+ ExpectBinary(kJSEFile, results.archived_binary.Get(0));
+}
+
} // namespace safe_browsing

Powered by Google App Engine
This is Rietveld 408576698