Commit 5ffaaea7 authored by Greg Kerr's avatar Greg Kerr Committed by Commit Bot

macOS Sandbox: Port SSL init test to V2.

Bug: 902597
Change-Id: I3e422c88d774705a1c67682d0fdb1b18e3568170
Reviewed-on: https://chromium-review.googlesource.com/c/1327426
Commit-Queue: Greg Kerr <kerrnel@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611441}
parent 6cdc929e
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "base/test/multiprocess_test.h" #include "base/test/multiprocess_test.h"
#include "base/test/test_timeouts.h" #include "base/test/test_timeouts.h"
#include "content/browser/sandbox_parameters_mac.h" #include "content/browser/sandbox_parameters_mac.h"
#include "crypto/openssl_util.h"
#include "sandbox/mac/seatbelt.h" #include "sandbox/mac/seatbelt.h"
#include "sandbox/mac/seatbelt_exec.h" #include "sandbox/mac/seatbelt_exec.h"
#include "services/service_manager/sandbox/mac/audio.sb.h" #include "services/service_manager/sandbox/mac/audio.sb.h"
...@@ -30,6 +31,7 @@ ...@@ -30,6 +31,7 @@
#include "services/service_manager/sandbox/switches.h" #include "services/service_manager/sandbox/switches.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "testing/multiprocess_func_list.h" #include "testing/multiprocess_func_list.h"
#include "third_party/boringssl/src/include/openssl/rand.h"
#import "ui/base/clipboard/clipboard_util_mac.h" #import "ui/base/clipboard/clipboard_util_mac.h"
namespace content { namespace content {
...@@ -141,7 +143,9 @@ class SandboxMacTest : public base::MultiProcessTest { ...@@ -141,7 +143,9 @@ class SandboxMacTest : public base::MultiProcessTest {
for (ExecuteFuncT execute_func : kExecuteFuncs) { for (ExecuteFuncT execute_func : kExecuteFuncs) {
(this->*execute_func)(multiprocess_main); (this->*execute_func)(multiprocess_main);
after_each.Run(); if (!after_each.is_null()) {
after_each.Run();
}
} }
} }
...@@ -222,4 +226,18 @@ TEST_F(SandboxMacClipboardTest, ClipboardAccess) { ...@@ -222,4 +226,18 @@ TEST_F(SandboxMacClipboardTest, ClipboardAccess) {
pb)); pb));
} }
MULTIPROCESS_TEST_MAIN(SSLProcess) {
CheckCreateSeatbeltServer();
crypto::EnsureOpenSSLInit();
// Ensure that RAND_bytes is functional within the sandbox.
uint8_t byte;
CHECK(RAND_bytes(&byte, 1) == 1);
return 0;
}
TEST_F(SandboxMacTest, SSLInitTest) {
ExecuteInAllSandboxTypes("SSLProcess", base::RepeatingClosure());
}
} // namespace content } // namespace content
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import <Cocoa/Cocoa.h>
#include <stdint.h>
#include "base/files/file_util.h"
#include "base/files/scoped_file.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/strings/sys_string_conversions.h"
#include "content/common/sandbox_mac_unittest_helper.h"
#include "crypto/openssl_util.h"
#include "services/service_manager/sandbox/mac/sandbox_mac.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/boringssl/src/include/openssl/rand.h"
#import "ui/base/clipboard/clipboard_util_mac.h"
namespace content {
//--------------------- OpenSSL Sandboxing ----------------------
// Test case for checking sandboxing of OpenSSL initialization.
class MacSandboxedOpenSSLTestCase : public MacSandboxTestCase {
public:
bool SandboxedTest() override;
};
REGISTER_SANDBOX_TEST_CASE(MacSandboxedOpenSSLTestCase);
bool MacSandboxedOpenSSLTestCase::SandboxedTest() {
crypto::EnsureOpenSSLInit();
// Ensure that RAND_bytes is functional within the sandbox.
uint8_t byte;
return RAND_bytes(&byte, 1) == 1;
}
TEST_F(MacSandboxTest, OpenSSLAccess) {
EXPECT_TRUE(RunTestInAllSandboxTypes("MacSandboxedOpenSSLTestCase", NULL));
}
} // namespace content
...@@ -1683,7 +1683,6 @@ test("content_unittests") { ...@@ -1683,7 +1683,6 @@ test("content_unittests") {
"../common/page_zoom_unittest.cc", "../common/page_zoom_unittest.cc",
"../common/plugin_list_unittest.cc", "../common/plugin_list_unittest.cc",
"../common/sandbox_mac_fontloading_unittest.mm", "../common/sandbox_mac_fontloading_unittest.mm",
"../common/sandbox_mac_system_access_unittest.mm",
"../common/sandbox_mac_unittest_helper.h", "../common/sandbox_mac_unittest_helper.h",
"../common/sandbox_mac_unittest_helper.mm", "../common/sandbox_mac_unittest_helper.mm",
"../common/service_manager/service_manager_connection_impl_unittest.cc", "../common/service_manager/service_manager_connection_impl_unittest.cc",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment