OLD | NEW |
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/signature_evaluator_mac.h" | 5 #include "chrome/browser/safe_browsing/signature_evaluator_mac.h" |
6 | 6 |
7 #include <CoreFoundation/CoreFoundation.h> | 7 #include <CoreFoundation/CoreFoundation.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string.h> | 9 #include <string.h> |
10 #include <sys/xattr.h> | 10 #include <sys/xattr.h> |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 | 240 |
241 TEST_F(MacSignatureEvaluatorTest, ModifiedBundleTest) { | 241 TEST_F(MacSignatureEvaluatorTest, ModifiedBundleTest) { |
242 // Now test a modified, signed bundle. This bundle has | 242 // Now test a modified, signed bundle. This bundle has |
243 // the following problems: | 243 // the following problems: |
244 // 1) A file was added (This should not be reported) | 244 // 1) A file was added (This should not be reported) |
245 // 2) libsigned64.dylib was modified | 245 // 2) libsigned64.dylib was modified |
246 // 3) executable32 was modified | 246 // 3) executable32 was modified |
247 | 247 |
248 base::FilePath orig_path = testdata_path_.AppendASCII("modified-bundle.app"); | 248 base::FilePath orig_path = testdata_path_.AppendASCII("modified-bundle.app"); |
249 base::FilePath copied_path = | 249 base::FilePath copied_path = |
250 temp_dir_.path().AppendASCII("modified-bundle.app"); | 250 temp_dir_.GetPath().AppendASCII("modified-bundle.app"); |
251 CHECK(base::CopyDirectory(orig_path, copied_path, true)); | 251 CHECK(base::CopyDirectory(orig_path, copied_path, true)); |
252 | 252 |
253 // Setup the extended attributes, which don't persist in the git repo. | 253 // Setup the extended attributes, which don't persist in the git repo. |
254 ASSERT_TRUE(SetupXattrs( | 254 ASSERT_TRUE(SetupXattrs( |
255 copied_path.AppendASCII("Contents/Resources/Base.lproj/MainMenu.nib"))); | 255 copied_path.AppendASCII("Contents/Resources/Base.lproj/MainMenu.nib"))); |
256 | 256 |
257 std::string requirement( | 257 std::string requirement( |
258 "certificate leaf[subject.CN]=\"untrusted@goat.local\""); | 258 "certificate leaf[subject.CN]=\"untrusted@goat.local\""); |
259 MacSignatureEvaluator evaluator(copied_path, requirement); | 259 MacSignatureEvaluator evaluator(copied_path, requirement); |
260 ASSERT_TRUE(evaluator.Initialize()); | 260 ASSERT_TRUE(evaluator.Initialize()); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 std::vector<std::string> xattrs_seen; | 328 std::vector<std::string> xattrs_seen; |
329 for (const auto& xattr : mainmenunib->signature().xattr()) { | 329 for (const auto& xattr : mainmenunib->signature().xattr()) { |
330 ASSERT_TRUE(xattr.has_key()); | 330 ASSERT_TRUE(xattr.has_key()); |
331 EXPECT_TRUE(xattr.has_value()); | 331 EXPECT_TRUE(xattr.has_value()); |
332 xattrs_seen.push_back(xattr.key()); | 332 xattrs_seen.push_back(xattr.key()); |
333 } | 333 } |
334 EXPECT_THAT(xattrs_known, ::testing::ContainerEq(xattrs_seen)); | 334 EXPECT_THAT(xattrs_known, ::testing::ContainerEq(xattrs_seen)); |
335 } | 335 } |
336 | 336 |
337 } // namespace safe_browsing | 337 } // namespace safe_browsing |
OLD | NEW |