| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #import <Foundation/Foundation.h> | 5 #import <Foundation/Foundation.h> |
| 6 #import <IOSurface/IOSurface.h> | 6 #import <IOSurface/IOSurface.h> |
| 7 | 7 |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <sys/mman.h> | 10 #include <sys/mman.h> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // These tests are designed to begin testing the V2 style sandbox rules on the | 28 // These tests are designed to begin testing the V2 style sandbox rules on the |
| 29 // bots, rendering the earliest possible test results on how the rules perform | 29 // bots, rendering the earliest possible test results on how the rules perform |
| 30 // consistently across all test bots and supported OS versions. | 30 // consistently across all test bots and supported OS versions. |
| 31 class SandboxMacCompilerV2Test : public base::MultiProcessTest {}; | 31 class SandboxMacCompilerV2Test : public base::MultiProcessTest {}; |
| 32 | 32 |
| 33 MULTIPROCESS_TEST_MAIN(V2ProfileProcess) { | 33 MULTIPROCESS_TEST_MAIN(V2ProfileProcess) { |
| 34 // Note: newlines are not necessary in the profile, but do make it easier to | 34 // Note: newlines are not necessary in the profile, but do make it easier to |
| 35 // print the profile out for debugging purposes. | 35 // print the profile out for debugging purposes. |
| 36 std::string profile = | 36 std::string profile = |
| 37 "(version 1)\n" | 37 "(version 1)\n" |
| 38 "(deny default)\n" | 38 "(deny default (with no-log))\n" |
| 39 "(define allowed-dir \"ALLOWED_READ_DIR\")\n" | 39 "(define allowed-dir \"ALLOWED_READ_DIR\")\n" |
| 40 "(define temp-file \"ALLOWED_TEMP_FILE\")\n" | 40 "(define temp-file \"ALLOWED_TEMP_FILE\")\n" |
| 41 "(define is-pre-10_10 \"IS_PRE_10_10\")\n" | 41 "(define is-pre-10_10 \"IS_PRE_10_10\")\n" |
| 42 "; Make it easier to drop (literal) once we stop supporting 10.9\n" | 42 "; Make it easier to drop (literal) once we stop supporting 10.9\n" |
| 43 "(define (path x) (literal x))\n" | 43 "(define (path x) (literal x))\n" |
| 44 "(allow file-read-metadata (subpath \"/Applications\"))\n" | 44 "(allow file-read-metadata (subpath \"/Applications\"))\n" |
| 45 "(allow file-read* (subpath (param allowed-dir)))\n" | 45 "(allow file-read* (subpath (param allowed-dir)))\n" |
| 46 "(allow file-read-data (path \"/usr/share/zoneinfo/zone.tab\"))\n" | 46 "(allow file-read-data (path \"/usr/share/zoneinfo/zone.tab\"))\n" |
| 47 "(allow file-write* (path (param temp-file)))\n" | 47 "(allow file-write* (path (param temp-file)))\n" |
| 48 "(allow ipc-posix-shm-read-data (ipc-posix-name " | 48 "(allow ipc-posix-shm-read-data (ipc-posix-name " |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 TEST_F(SandboxMacCompilerV2Test, V2ProfileTest) { | 128 TEST_F(SandboxMacCompilerV2Test, V2ProfileTest) { |
| 129 base::SpawnChildResult spawn_child = SpawnChild("V2ProfileProcess"); | 129 base::SpawnChildResult spawn_child = SpawnChild("V2ProfileProcess"); |
| 130 ASSERT_TRUE(spawn_child.process.IsValid()); | 130 ASSERT_TRUE(spawn_child.process.IsValid()); |
| 131 int exit_code = 42; | 131 int exit_code = 42; |
| 132 EXPECT_TRUE(spawn_child.process.WaitForExitWithTimeout( | 132 EXPECT_TRUE(spawn_child.process.WaitForExitWithTimeout( |
| 133 TestTimeouts::action_max_timeout(), &exit_code)); | 133 TestTimeouts::action_max_timeout(), &exit_code)); |
| 134 EXPECT_EQ(exit_code, 0); | 134 EXPECT_EQ(exit_code, 0); |
| 135 } | 135 } |
| 136 | 136 |
| 137 } // namespace sandbox | 137 } // namespace sandbox |
| OLD | NEW |