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

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

Issue 2934373002: Record Code Signature of Downloaded DMG files (Closed)
Patch Set: correcting rebase mixup 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_dmg_analyzer_mac_unittest.cc
diff --git a/chrome/browser/safe_browsing/sandboxed_dmg_analyzer_mac_unittest.cc b/chrome/browser/safe_browsing/sandboxed_dmg_analyzer_mac_unittest.cc
index bbf91ba7dbac5b8324e447f163a10755db6cba3f..8e8dc81e416d3a32f1a62af5e1eb6cfda94ab48f 100644
--- a/chrome/browser/safe_browsing/sandboxed_dmg_analyzer_mac_unittest.cc
+++ b/chrome/browser/safe_browsing/sandboxed_dmg_analyzer_mac_unittest.cc
@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/files/file_path.h"
+#include "base/files/file_util.h"
#include "base/macros.h"
#include "base/path_service.h"
#include "base/run_loop.h"
@@ -141,5 +142,44 @@ TEST_F(SandboxedDMGAnalyzerTest, AnalyzeDMG) {
EXPECT_TRUE(got_dylib);
}
+TEST_F(SandboxedDMGAnalyzerTest, AnalyzeDmgNoSignature) {
+ base::FilePath unsigned_dmg;
+ ASSERT_NO_FATAL_FAILURE(unsigned_dmg = GetFilePath("mach_o_in_dmg.dmg"));
+
+ ArchiveAnalyzerResults results;
+ AnalyzeFile(unsigned_dmg, &results);
+
+ EXPECT_TRUE(results.success);
+ EXPECT_EQ(0u, results.signature_blob.size());
+ EXPECT_EQ(nullptr, results.signature_blob.data());
+}
+
+TEST_F(SandboxedDMGAnalyzerTest, AnalyzeDmgWithSignature) {
+ base::FilePath signed_dmg;
+ EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &signed_dmg));
+ signed_dmg = signed_dmg.AppendASCII("safe_browsing")
+ .AppendASCII("mach_o")
+ .AppendASCII("signed-archive.dmg");
+
+ ArchiveAnalyzerResults results;
+ AnalyzeFile(signed_dmg, &results);
+
+ EXPECT_TRUE(results.success);
+ EXPECT_EQ(2215u, results.signature_blob.size());
+
+ base::FilePath signed_dmg_signature;
+ EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &signed_dmg_signature));
+ signed_dmg_signature = signed_dmg_signature.AppendASCII("safe_browsing")
+ .AppendASCII("mach_o")
+ .AppendASCII("signed-archive-signature.data");
+
+ std::string from_file;
+ base::ReadFileToString(signed_dmg_signature, &from_file);
+ EXPECT_EQ(2215u, from_file.length());
+ std::string signature(results.signature_blob.begin(),
+ results.signature_blob.end());
+ EXPECT_EQ(from_file, signature);
+}
+
} // namespace
} // namespace safe_browsing

Powered by Google App Engine
This is Rietveld 408576698