|
29 | 29 | #include "absl/strings/match.h" |
30 | 30 | #include "absl/strings/string_view.h" |
31 | 31 | #include "sandboxed_api/config.h" |
| 32 | +#include "sandboxed_api/sandbox2/allowlists/seccomp_speculation.h" |
32 | 33 | #include "sandboxed_api/sandbox2/executor.h" |
33 | 34 | #include "sandboxed_api/sandbox2/policybuilder.h" |
34 | 35 | #include "sandboxed_api/sandbox2/result.h" |
@@ -410,6 +411,28 @@ TEST_P(PolicyTest, SecondExecveatNotAllowedByDefault) { |
410 | 411 | EXPECT_THAT(result.reason_code(), Eq(0)); |
411 | 412 | } |
412 | 413 |
|
| 414 | +TEST_P(PolicyTest, SpeculationAllowed) { |
| 415 | + const std::string path = GetTestSourcePath("sandbox2/testcases/policy"); |
| 416 | + std::unique_ptr<Sandbox2> s2 = CreateTestSandbox( |
| 417 | + {"policy", "11"}, // Calls TestSpeculationAllowed() |
| 418 | + CreateDefaultPermissiveTestPolicy(path).Allow(SeccompSpeculation())); |
| 419 | + Result result = s2->Run(); |
| 420 | + |
| 421 | + ASSERT_THAT(result.final_status(), Eq(Result::OK)); |
| 422 | + EXPECT_THAT(result.reason_code(), Eq(0)); |
| 423 | +} |
| 424 | + |
| 425 | +TEST_P(PolicyTest, SpeculationBlockedByDefault) { |
| 426 | + const std::string path = GetTestSourcePath("sandbox2/testcases/policy"); |
| 427 | + std::unique_ptr<Sandbox2> s2 = |
| 428 | + CreateTestSandbox({"policy", "12"}, // Calls TestSpeculationBlocked() |
| 429 | + CreateDefaultPermissiveTestPolicy(path)); |
| 430 | + Result result = s2->Run(); |
| 431 | + |
| 432 | + ASSERT_THAT(result.final_status(), Eq(Result::OK)); |
| 433 | + EXPECT_THAT(result.reason_code(), Eq(0)); |
| 434 | +} |
| 435 | + |
413 | 436 | INSTANTIATE_TEST_SUITE_P(Sandbox2, PolicyTest, ::testing::Values(false, true), |
414 | 437 | [](const ::testing::TestParamInfo<bool>& info) { |
415 | 438 | return info.param ? "UnotifyMonitor" |
|
0 commit comments