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

Unified Diff: sandbox/linux/seccomp-bpf-helpers/bpf_dsl_unittest.cc

Issue 299683004: Rewrite all BPF policies to use DSL API Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Overhaul of DSL and implementation Created 6 years, 7 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: sandbox/linux/seccomp-bpf-helpers/bpf_dsl_unittest.cc
diff --git a/sandbox/linux/seccomp-bpf-helpers/bpf_dsl_unittest.cc b/sandbox/linux/seccomp-bpf-helpers/bpf_dsl_unittest.cc
index 31d9549b8bdb33a1d8ce9647247905f4849f8322..4402ed701a1c1fede7806ad42ca999d01409242d 100644
--- a/sandbox/linux/seccomp-bpf-helpers/bpf_dsl_unittest.cc
+++ b/sandbox/linux/seccomp-bpf-helpers/bpf_dsl_unittest.cc
@@ -14,22 +14,23 @@
namespace sandbox {
+namespace bpf_dsl {
+
namespace {
-class BasicPolicy : public SandboxBPFPolicy {
+class BasicPolicy : public SandboxBPFPolicyDSL {
public:
BasicPolicy() {}
- virtual ErrorCode EvaluateSyscall(SandboxBPF* sb, int sysno) const OVERRIDE {
+ virtual ResultExpr EvaluateSyscall(int sysno) const OVERRIDE {
if (sysno == __NR_getpgid) {
const Arg<pid_t> pid(0);
- return DSL(sb)
- .If(pid == 0).Then(
- ErrorCode(EPERM)
- ).Else(
- ErrorCode(EINVAL)
- );
+ return If(pid == 0).Then(
+ Error(EPERM)
+ ).Else(
+ Error(EINVAL)
+ );
}
- return ErrorCode(ErrorCode::ERR_ALLOWED);
+ return Allow();
}
private:
@@ -44,22 +45,21 @@ BPF_TEST_C(BPFDSL, Basic, BasicPolicy) {
BPF_ASSERT_EQ(EINVAL, errno);
}
-class FancyPolicy : public SandboxBPFPolicy {
+class FancyPolicy : public SandboxBPFPolicyDSL {
public:
FancyPolicy() {}
- virtual ErrorCode EvaluateSyscall(SandboxBPF* sb, int sysno) const OVERRIDE {
+ virtual ResultExpr EvaluateSyscall(int sysno) const OVERRIDE {
if (sysno == __NR_socketpair) {
const Arg<int> domain(0), type(1), protocol(2);
- return DSL(sb)
- .If(domain == AF_UNIX &&
- (type == SOCK_STREAM || type == SOCK_DGRAM) &&
- protocol == 0).Then(
- ErrorCode(EPERM)
- ).Else(
- ErrorCode(EINVAL)
- );
+ return If(domain == AF_UNIX &&
+ (type == SOCK_STREAM || type == SOCK_DGRAM) &&
+ protocol == 0).Then(
+ Error(EPERM)
+ ).Else(
+ Error(EINVAL)
+ );
}
- return ErrorCode(ErrorCode::ERR_ALLOWED);
+ return Allow();
}
private:
@@ -91,4 +91,6 @@ BPF_TEST_C(BPFDSL, Fancy, FancyPolicy) {
} // namespace
+} // namespace bpf_dsl
+
} // namespace sandbox
« no previous file with comments | « sandbox/linux/seccomp-bpf-helpers/bpf_dsl.cc ('k') | sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698