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

Side by Side Diff: chrome/browser/safe_browsing/sandboxed_zip_analyzer_unittest.cc

Issue 1979153002: Use FileTypePolicies for is_archive and is_supported classifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@split_by_platform
Patch Set: rebase Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/safe_browsing/sandboxed_zip_analyzer.h" 5 #include "chrome/browser/safe_browsing/sandboxed_zip_analyzer.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 #include "chrome/common/chrome_paths.h" 16 #include "chrome/common/chrome_paths.h"
17 #include "chrome/common/safe_browsing/file_type_policies.h"
17 #include "chrome/common/safe_browsing/zip_analyzer_results.h" 18 #include "chrome/common/safe_browsing/zip_analyzer_results.h"
18 #include "content/public/test/test_browser_thread_bundle.h" 19 #include "content/public/test/test_browser_thread_bundle.h"
19 #include "content/public/test/test_utils.h" 20 #include "content/public/test/test_utils.h"
20 #include "crypto/sha2.h" 21 #include "crypto/sha2.h"
21 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
22 23
23 namespace safe_browsing { 24 namespace safe_browsing {
24 25
25 class SandboxedZipAnalyzerTest : public ::testing::Test { 26 class SandboxedZipAnalyzerTest : public ::testing::Test {
26 protected: 27 protected:
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 static const uint8_t kUnsignedDigest[]; 132 static const uint8_t kUnsignedDigest[];
132 static const uint8_t kSignedDigest[]; 133 static const uint8_t kSignedDigest[];
133 static const uint8_t kJSEFileDigest[]; 134 static const uint8_t kJSEFileDigest[];
134 static const BinaryData kUnsignedExe; 135 static const BinaryData kUnsignedExe;
135 static const BinaryData kSignedExe; 136 static const BinaryData kSignedExe;
136 static const BinaryData kJSEFile; 137 static const BinaryData kJSEFile;
137 138
138 base::FilePath dir_test_data_; 139 base::FilePath dir_test_data_;
139 content::TestBrowserThreadBundle browser_thread_bundle_; 140 content::TestBrowserThreadBundle browser_thread_bundle_;
140 content::InProcessUtilityThreadHelper utility_thread_helper_; 141 content::InProcessUtilityThreadHelper utility_thread_helper_;
142
143 // This manages the lifetime of FileTypePolicies::GlobalInstance()
144 safe_browsing::FileTypePoliciesManager file_type_policies_manager_;
141 }; 145 };
142 146
143 // static 147 // static
144 const uint8_t SandboxedZipAnalyzerTest::kUnsignedDigest[] = { 148 const uint8_t SandboxedZipAnalyzerTest::kUnsignedDigest[] = {
145 0x1e, 0x95, 0x4d, 0x9c, 0xe0, 0x38, 0x9e, 0x2b, 0xa7, 0x44, 0x72, 149 0x1e, 0x95, 0x4d, 0x9c, 0xe0, 0x38, 0x9e, 0x2b, 0xa7, 0x44, 0x72,
146 0x16, 0xf2, 0x17, 0x61, 0xf9, 0x8d, 0x1e, 0x65, 0x40, 0xc2, 0xab, 150 0x16, 0xf2, 0x17, 0x61, 0xf9, 0x8d, 0x1e, 0x65, 0x40, 0xc2, 0xab,
147 0xec, 0xdb, 0xec, 0xff, 0x57, 0x0e, 0x36, 0xc4, 0x93, 0xdb}; 151 0xec, 0xdb, 0xec, 0xff, 0x57, 0x0e, 0x36, 0xc4, 0x93, 0xdb};
148 const uint8_t SandboxedZipAnalyzerTest::kSignedDigest[] = { 152 const uint8_t SandboxedZipAnalyzerTest::kSignedDigest[] = {
149 0xe1, 0x1f, 0xfa, 0x0c, 0x9f, 0x25, 0x23, 0x44, 0x53, 0xa9, 0xed, 153 0xe1, 0x1f, 0xfa, 0x0c, 0x9f, 0x25, 0x23, 0x44, 0x53, 0xa9, 0xed,
150 0xd1, 0xcb, 0x25, 0x1d, 0x46, 0x10, 0x7f, 0x34, 0xb5, 0x36, 0xad, 154 0xd1, 0xcb, 0x25, 0x1d, 0x46, 0x10, 0x7f, 0x34, 0xb5, 0x36, 0xad,
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 RunAnalyzer(dir_test_data_.AppendASCII("zipfile_one_jse_file.zip"), &results); 281 RunAnalyzer(dir_test_data_.AppendASCII("zipfile_one_jse_file.zip"), &results);
278 ASSERT_TRUE(results.success); 282 ASSERT_TRUE(results.success);
279 EXPECT_TRUE(results.has_executable); 283 EXPECT_TRUE(results.has_executable);
280 EXPECT_FALSE(results.has_archive); 284 EXPECT_FALSE(results.has_archive);
281 ASSERT_EQ(1, results.archived_binary.size()); 285 ASSERT_EQ(1, results.archived_binary.size());
282 ExpectBinary(kJSEFile, results.archived_binary.Get(0)); 286 ExpectBinary(kJSEFile, results.archived_binary.Get(0));
283 EXPECT_TRUE(results.archived_archive_filenames.empty()); 287 EXPECT_TRUE(results.archived_archive_filenames.empty());
284 } 288 }
285 289
286 } // namespace safe_browsing 290 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698