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

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

Issue 2961373002: Improve Zip File Scanning on Mac (Closed)
Patch Set: removing check for .app on windows Created 3 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 4b434d82f51a35b6122fa95f623e857f44fc95bf..b123999963ac194db0133111614b3a2cefc6f254 100644
--- a/chrome/browser/safe_browsing/sandboxed_zip_analyzer_unittest.cc
+++ b/chrome/browser/safe_browsing/sandboxed_zip_analyzer_unittest.cc
@@ -66,7 +66,7 @@ class SandboxedZipAnalyzerTest : public ::testing::Test {
void SetUp() override {
ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &dir_test_data_));
dir_test_data_ = dir_test_data_.AppendASCII("safe_browsing");
- dir_test_data_ = dir_test_data_.AppendASCII("download_protection");
+ // dir_test_data_ = dir_test_data_.AppendASCII("download_protection");
}
// Runs a sandboxed zip analyzer on |file_path|, writing its results into
@@ -124,7 +124,11 @@ class SandboxedZipAnalyzerTest : public ::testing::Test {
}
#endif // OS_WIN
ASSERT_FALSE(binary.has_signature());
+#if defined(OS_MACOSX)
+ ASSERT_TRUE(binary.has_image_headers());
+#else
ASSERT_FALSE(binary.has_image_headers());
+#endif
}
static const uint8_t kUnsignedDigest[];
@@ -134,6 +138,11 @@ class SandboxedZipAnalyzerTest : public ::testing::Test {
static const BinaryData kSignedExe;
static const BinaryData kJSEFile;
+#if defined(OS_MACOSX)
+ static const uint8_t kMachODigest[];
+ static const BinaryData kMachO;
+#endif // OS_MACOSX
+
base::FilePath dir_test_data_;
content::TestBrowserThreadBundle browser_thread_bundle_;
content::InProcessUtilityThreadHelper utility_thread_helper_;
@@ -177,9 +186,25 @@ const SandboxedZipAnalyzerTest::BinaryData SandboxedZipAnalyzerTest::kJSEFile =
false, // is_signed
};
+#if defined(OS_MACOSX)
+const uint8_t SandboxedZipAnalyzerTest::kMachODigest[] = {
+ 0xe4, 0x62, 0xff, 0x75, 0x2f, 0xf9, 0xd8, 0x4e, 0x34, 0xd8, 0x43,
+ 0xe5, 0xd4, 0x6e, 0x20, 0x12, 0xad, 0xcb, 0xd4, 0x85, 0x40, 0xa8,
+ 0x47, 0x3f, 0xb7, 0x94, 0xb2, 0x86, 0xa3, 0x89, 0xb9, 0x45};
+const SandboxedZipAnalyzerTest::BinaryData SandboxedZipAnalyzerTest::kMachO = {
+ "executablefat",
+ ClientDownloadRequest_DownloadType_MAC_EXECUTABLE,
+ &kMachODigest[0],
+ 16640,
+ false, // !is_signed
+};
+#endif // OS_MACOSX
+
TEST_F(SandboxedZipAnalyzerTest, NoBinaries) {
ArchiveAnalyzerResults results;
- RunAnalyzer(dir_test_data_.AppendASCII("zipfile_no_binaries.zip"), &results);
+ RunAnalyzer(
+ dir_test_data_.AppendASCII("download_protection/zipfile_no_binaries.zip"),
+ &results);
ASSERT_TRUE(results.success);
EXPECT_FALSE(results.has_executable);
EXPECT_FALSE(results.has_archive);
@@ -188,7 +213,8 @@ TEST_F(SandboxedZipAnalyzerTest, NoBinaries) {
TEST_F(SandboxedZipAnalyzerTest, OneUnsignedBinary) {
ArchiveAnalyzerResults results;
- RunAnalyzer(dir_test_data_.AppendASCII("zipfile_one_unsigned_binary.zip"),
+ RunAnalyzer(dir_test_data_.AppendASCII(
+ "download_protection/zipfile_one_unsigned_binary.zip"),
&results);
ASSERT_TRUE(results.success);
EXPECT_TRUE(results.has_executable);
@@ -199,7 +225,8 @@ TEST_F(SandboxedZipAnalyzerTest, OneUnsignedBinary) {
TEST_F(SandboxedZipAnalyzerTest, TwoBinariesOneSigned) {
ArchiveAnalyzerResults results;
- RunAnalyzer(dir_test_data_.AppendASCII("zipfile_two_binaries_one_signed.zip"),
+ RunAnalyzer(dir_test_data_.AppendASCII(
+ "download_protection/zipfile_two_binaries_one_signed.zip"),
&results);
ASSERT_TRUE(results.success);
EXPECT_TRUE(results.has_executable);
@@ -211,7 +238,8 @@ TEST_F(SandboxedZipAnalyzerTest, TwoBinariesOneSigned) {
TEST_F(SandboxedZipAnalyzerTest, ZippedArchiveNoBinaries) {
ArchiveAnalyzerResults results;
- RunAnalyzer(dir_test_data_.AppendASCII("zipfile_archive_no_binaries.zip"),
+ RunAnalyzer(dir_test_data_.AppendASCII(
+ "download_protection/zipfile_archive_no_binaries.zip"),
&results);
ASSERT_TRUE(results.success);
EXPECT_FALSE(results.has_executable);
@@ -224,7 +252,8 @@ TEST_F(SandboxedZipAnalyzerTest, ZippedArchiveNoBinaries) {
TEST_F(SandboxedZipAnalyzerTest, ZippedRarArchiveNoBinaries) {
ArchiveAnalyzerResults results;
- RunAnalyzer(dir_test_data_.AppendASCII("zipfile_rar_archive_no_binaries.zip"),
+ RunAnalyzer(dir_test_data_.AppendASCII(
+ "download_protection/zipfile_rar_archive_no_binaries.zip"),
&results);
ASSERT_TRUE(results.success);
EXPECT_FALSE(results.has_executable);
@@ -237,7 +266,8 @@ TEST_F(SandboxedZipAnalyzerTest, ZippedRarArchiveNoBinaries) {
TEST_F(SandboxedZipAnalyzerTest, ZippedArchiveAndBinaries) {
ArchiveAnalyzerResults results;
- RunAnalyzer(dir_test_data_.AppendASCII("zipfile_archive_and_binaries.zip"),
+ RunAnalyzer(dir_test_data_.AppendASCII(
+ "download_protection/zipfile_archive_and_binaries.zip"),
&results);
ASSERT_TRUE(results.success);
EXPECT_TRUE(results.has_executable);
@@ -252,8 +282,9 @@ TEST_F(SandboxedZipAnalyzerTest, ZippedArchiveAndBinaries) {
TEST_F(SandboxedZipAnalyzerTest,
ZippedArchiveAndBinariesWithTrailingSpaceAndPeriodChars) {
ArchiveAnalyzerResults results;
- RunAnalyzer(dir_test_data_.AppendASCII("zipfile_two_binaries_one_archive_"
- "trailing_space_and_period_chars.zip"),
+ RunAnalyzer(dir_test_data_.AppendASCII(
+ "download_protection/zipfile_two_binaries_one_archive_"
+ "trailing_space_and_period_chars.zip"),
&results);
ASSERT_TRUE(results.success);
EXPECT_TRUE(results.has_executable);
@@ -273,7 +304,9 @@ TEST_F(SandboxedZipAnalyzerTest,
TEST_F(SandboxedZipAnalyzerTest, ZippedJSEFile) {
ArchiveAnalyzerResults results;
- RunAnalyzer(dir_test_data_.AppendASCII("zipfile_one_jse_file.zip"), &results);
+ RunAnalyzer(dir_test_data_.AppendASCII(
+ "download_protection/zipfile_one_jse_file.zip"),
+ &results);
ASSERT_TRUE(results.success);
EXPECT_TRUE(results.has_executable);
EXPECT_FALSE(results.has_archive);
@@ -282,4 +315,18 @@ TEST_F(SandboxedZipAnalyzerTest, ZippedJSEFile) {
EXPECT_TRUE(results.archived_archive_filenames.empty());
}
+#if defined(OS_MACOSX)
+TEST_F(SandboxedZipAnalyzerTest, ZippedAppWithExecutable) {
+ ArchiveAnalyzerResults results;
+ RunAnalyzer(
+ dir_test_data_.AppendASCII("mach_o/zipped-app-with-executable.zip"),
+ &results);
+ ASSERT_TRUE(results.success);
+ EXPECT_TRUE(results.has_executable);
+ EXPECT_FALSE(results.has_archive);
+ ASSERT_EQ(1, results.archived_binary.size());
+ ExpectBinary(kMachO, results.archived_binary.Get(0));
+}
+#endif // OS_MACOSX
+
} // namespace safe_browsing
« no previous file with comments | « no previous file | chrome/common/safe_browsing/download_protection_util.cc » ('j') | third_party/zlib/google/zip_reader.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698