Signed-off-by: Paul Moore <[email protected]>
---
 tests/01-allow.py             |   45 ++++++++++++++++++++++++++++++
 tests/02-basic.py             |   49 +++++++++++++++++++++++++++++++++
 tests/03-basic-chains.py      |   50 ++++++++++++++++++++++++++++++++++
 tests/04-multilevel-chains.py |   61 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 205 insertions(+)
 create mode 100755 tests/01-allow.py
 create mode 100755 tests/02-basic.py
 create mode 100755 tests/03-basic-chains.py
 create mode 100755 tests/04-multilevel-chains.py

diff --git a/tests/01-allow.py b/tests/01-allow.py
new file mode 100755
index 0000000..b871d03
--- /dev/null
+++ b/tests/01-allow.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+
+#
+# Seccomp Library test program
+#
+# Copyright (c) 2012 Red Hat <[email protected]>
+# Author: Paul Moore <[email protected]>
+#
+
+#
+# This library is free software; you can redistribute it and/or modify it
+# under the terms of version 2.1 of the GNU Lesser General Public License as
+# published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+# for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, see <http://www.gnu.org/licenses>.
+#
+
+import argparse
+import sys
+
+from seccomp import *
+
+def test(args):
+    f = SyscallFilter(ALLOW)
+    return f
+
+if __name__ == "__main__":
+    parser = argparse.ArgumentParser()
+    parser.add_argument("-b", "--bpf", action="store_true")
+    parser.add_argument("-p", "--pfc", action="store_true")
+    args = parser.parse_args()
+    f = test(args)
+    if (args.bpf):
+        f.export_bpf(sys.stdout)
+    else:
+        f.export_pfc(sys.stdout)
+
+# kate: syntax python;
+# kate: indent-mode python; space-indent on; indent-width 4; mixedindent off;
diff --git a/tests/02-basic.py b/tests/02-basic.py
new file mode 100755
index 0000000..f4c2ac3
--- /dev/null
+++ b/tests/02-basic.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+
+#
+# Seccomp Library test program
+#
+# Copyright (c) 2012 Red Hat <[email protected]>
+# Author: Paul Moore <[email protected]>
+#
+
+#
+# This library is free software; you can redistribute it and/or modify it
+# under the terms of version 2.1 of the GNU Lesser General Public License as
+# published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+# for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, see <http://www.gnu.org/licenses>.
+#
+
+import argparse
+import sys
+
+from seccomp import *
+
+def test(args):
+    f = SyscallFilter(KILL)
+    f.add_rule_exactly(ALLOW, "read");
+    f.add_rule_exactly(ALLOW, "write");
+    f.add_rule_exactly(ALLOW, "close");
+    f.add_rule_exactly(ALLOW, "rt_sigreturn");
+    return f
+
+if __name__ == "__main__":
+    parser = argparse.ArgumentParser()
+    parser.add_argument("-b", "--bpf", action="store_true")
+    parser.add_argument("-p", "--pfc", action="store_true")
+    args = parser.parse_args()
+    f = test(args)
+    if (args.bpf):
+        f.export_bpf(sys.stdout)
+    else:
+        f.export_pfc(sys.stdout)
+
+# kate: syntax python;
+# kate: indent-mode python; space-indent on; indent-width 4; mixedindent off;
diff --git a/tests/03-basic-chains.py b/tests/03-basic-chains.py
new file mode 100755
index 0000000..169f41c
--- /dev/null
+++ b/tests/03-basic-chains.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+
+#
+# Seccomp Library test program
+#
+# Copyright (c) 2012 Red Hat <[email protected]>
+# Author: Paul Moore <[email protected]>
+#
+
+#
+# This library is free software; you can redistribute it and/or modify it
+# under the terms of version 2.1 of the GNU Lesser General Public License as
+# published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+# for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, see <http://www.gnu.org/licenses>.
+#
+
+import argparse
+import sys
+
+from seccomp import *
+
+def test(args):
+    f = SyscallFilter(KILL)
+    f.add_rule_exactly(ALLOW, "read", Arg(0, Arg.EQ, sys.stdin.fileno()));
+    f.add_rule_exactly(ALLOW, "write", Arg(0, Arg.EQ, sys.stdout.fileno()));
+    f.add_rule_exactly(ALLOW, "write", Arg(0, Arg.EQ, sys.stderr.fileno()));
+    f.add_rule_exactly(ALLOW, "close");
+    f.add_rule_exactly(ALLOW, "rt_sigreturn");
+    return f
+
+if __name__ == "__main__":
+    parser = argparse.ArgumentParser()
+    parser.add_argument("-b", "--bpf", action="store_true")
+    parser.add_argument("-p", "--pfc", action="store_true")
+    args = parser.parse_args()
+    f = test(args)
+    if (args.bpf):
+        f.export_bpf(sys.stdout)
+    else:
+        f.export_pfc(sys.stdout)
+
+# kate: syntax python;
+# kate: indent-mode python; space-indent on; indent-width 4; mixedindent off;
diff --git a/tests/04-multilevel-chains.py b/tests/04-multilevel-chains.py
new file mode 100755
index 0000000..6ed9228
--- /dev/null
+++ b/tests/04-multilevel-chains.py
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+
+#
+# Seccomp Library test program
+#
+# Copyright (c) 2012 Red Hat <[email protected]>
+# Author: Paul Moore <[email protected]>
+#
+
+#
+# This library is free software; you can redistribute it and/or modify it
+# under the terms of version 2.1 of the GNU Lesser General Public License as
+# published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+# for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, see <http://www.gnu.org/licenses>.
+#
+
+import argparse
+import sys
+
+from seccomp import *
+
+def test(args):
+    f = SyscallFilter(KILL)
+    f.add_rule_exactly(ALLOW, "open");
+    f.add_rule_exactly(ALLOW, "close");
+    f.add_rule_exactly(ALLOW, "read",
+                        Arg(0, Arg.EQ, sys.stdin.fileno()),
+                        Arg(1, Arg.NE, 0),
+                        Arg(2, Arg.LT, sys.maxsize));
+    f.add_rule_exactly(ALLOW, "write",
+                        Arg(0, Arg.EQ, sys.stdout.fileno()),
+                        Arg(1, Arg.NE, 0),
+                        Arg(2, Arg.LT, sys.maxsize));
+    f.add_rule_exactly(ALLOW, "write",
+                        Arg(0, Arg.EQ, sys.stderr.fileno()),
+                        Arg(1, Arg.NE, 0),
+                        Arg(2, Arg.LT, sys.maxsize));
+    f.add_rule_exactly(ALLOW, "close");
+    f.add_rule_exactly(ALLOW, "rt_sigreturn");
+    return f
+
+if __name__ == "__main__":
+    parser = argparse.ArgumentParser()
+    parser.add_argument("-b", "--bpf", action="store_true")
+    parser.add_argument("-p", "--pfc", action="store_true")
+    args = parser.parse_args()
+    f = test(args)
+    if (args.bpf):
+        f.export_bpf(sys.stdout)
+    else:
+        f.export_pfc(sys.stdout)
+
+# kate: syntax python;
+# kate: indent-mode python; space-indent on; indent-width 4; mixedindent off;


------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
libseccomp-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libseccomp-discuss

Reply via email to