summaryrefslogtreecommitdiffstats
path: root/chrome/test/security_tests
diff options
context:
space:
mode:
authorjorgelo@chromium.org <jorgelo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-26 13:36:06 +0000
committerjorgelo@chromium.org <jorgelo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-26 13:36:06 +0000
commit1f59ace540ec21aad2b99a6e50d1136448df23c9 (patch)
tree078d8baeb0580243d3d7e52756ab6eff258e8970 /chrome/test/security_tests
parentccfa9c4e8369201affa30532db49dbcbb5937356 (diff)
downloadchromium_src-1f59ace540ec21aad2b99a6e50d1136448df23c9.zip
chromium_src-1f59ace540ec21aad2b99a6e50d1136448df23c9.tar.gz
chromium_src-1f59ace540ec21aad2b99a6e50d1136448df23c9.tar.bz2
Create Sandbox{Linux|Win}Test and add Linux SandboxStatus test.
The resulting BrowserTest can be run on Chrome OS successfully. (Reland with fix for ASan.) BUG=None TEST=Passes TBR=sky Review URL: https://chromiumcodereview.appspot.com/20133003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@213887 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/security_tests')
-rw-r--r--chrome/test/security_tests/sandbox_browsertest_linux.cc34
-rw-r--r--chrome/test/security_tests/sandbox_browsertest_win.cc (renamed from chrome/test/security_tests/sandbox_browsertest.cc)10
2 files changed, 38 insertions, 6 deletions
diff --git a/chrome/test/security_tests/sandbox_browsertest_linux.cc b/chrome/test/security_tests/sandbox_browsertest_linux.cc
new file mode 100644
index 0000000..f9c26599
--- /dev/null
+++ b/chrome/test/security_tests/sandbox_browsertest_linux.cc
@@ -0,0 +1,34 @@
+// Copyright 2013 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.
+
+#include "chrome/test/base/in_process_browser_test.h"
+#include "content/public/browser/zygote_host_linux.h"
+#include "content/public/common/sandbox_linux.h"
+
+typedef InProcessBrowserTest SandboxLinuxTest;
+
+// Both the SUID sandbox (http://crbug.com/137653) and the Seccomp-BPF sandbox
+// are currently incompatible with ASan.
+#if defined(OS_LINUX) && !defined(ADDRESS_SANITIZER)
+#define MAYBE_SandboxStatus \
+ SandboxStatus
+#else
+#define MAYBE_SandboxStatus \
+ DISABLED_SandboxStatus
+#endif
+
+IN_PROC_BROWSER_TEST_F(SandboxLinuxTest, MAYBE_SandboxStatus) {
+ // Get expected sandboxing status of renderers.
+ const int status = content::ZygoteHost::GetInstance()->GetSandboxStatus();
+
+ // The setuid sandbox is required as our first-layer sandbox.
+ bool good_layer1 = status & content::kSandboxLinuxSUID &&
+ status & content::kSandboxLinuxPIDNS &&
+ status & content::kSandboxLinuxNetNS;
+ // A second-layer sandbox is also required to be adequately sandboxed.
+ bool good_layer2 = status & content::kSandboxLinuxSeccompBpf;
+
+ EXPECT_TRUE(good_layer1);
+ EXPECT_TRUE(good_layer2);
+}
diff --git a/chrome/test/security_tests/sandbox_browsertest.cc b/chrome/test/security_tests/sandbox_browsertest_win.cc
index 8b09a95..05c10bb 100644
--- a/chrome/test/security_tests/sandbox_browsertest.cc
+++ b/chrome/test/security_tests/sandbox_browsertest_win.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright 2013 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.
@@ -8,9 +8,9 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/in_process_browser_test.h"
-class SandboxTest : public InProcessBrowserTest {
+class SandboxWinTest : public InProcessBrowserTest {
protected:
- SandboxTest() : InProcessBrowserTest() {}
+ SandboxWinTest() : InProcessBrowserTest() {}
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
command_line->AppendSwitchASCII(switches::kTestSandbox,
@@ -19,9 +19,7 @@ class SandboxTest : public InProcessBrowserTest {
};
// Need a cross-platform test library: http://crbug.com/45771
-#if defined(OS_WIN)
// Verifies that chrome is running properly.
-IN_PROC_BROWSER_TEST_F(SandboxTest, ExecuteDll) {
+IN_PROC_BROWSER_TEST_F(SandboxWinTest, ExecuteDll) {
EXPECT_EQ(1, browser()->tab_strip_model()->count());
}
-#endif