From 1fb1bfe20fbde64d769e846b1581ce021d03e864 Mon Sep 17 00:00:00 2001 From: netblue30 Date: Sun, 1 Apr 2018 07:48:11 -0400 Subject: testing --- test/utils/audit.exp | 60 +++++++++++++++ test/utils/command.exp | 23 ++++++ test/utils/name.exp | 174 +++++++++++++++++++++++++++++++++++++++++++ test/utils/profile_print.exp | 27 +++++++ test/utils/utils.sh | 9 +++ 5 files changed, 293 insertions(+) create mode 100755 test/utils/command.exp create mode 100755 test/utils/name.exp create mode 100755 test/utils/profile_print.exp (limited to 'test/utils') diff --git a/test/utils/audit.exp b/test/utils/audit.exp index 684886af7..6352dc62d 100755 --- a/test/utils/audit.exp +++ b/test/utils/audit.exp @@ -96,4 +96,64 @@ expect { } after 100 +# test seccomp +send -- "firejail --seccomp.drop=mkdir --audit\r" +expect { + timeout {puts "TESTING ERROR 17\n";exit} + "Firejail Audit" +} +expect { + timeout {puts "TESTING ERROR 18\n";exit} + "GOOD: seccomp BPF enabled" +} +expect { + timeout {puts "TESTING ERROR 19\n";exit} + "UGLY: mount syscall permitted" +} +expect { + timeout {puts "TESTING ERROR 20\n";exit} + "UGLY: umount2 syscall permitted" +} +expect { + timeout {puts "TESTING ERROR 21\n";exit} + "UGLY: ptrace syscall permitted" +} +expect { + timeout {puts "TESTING ERROR 22\n";exit} + "UGLY: swapon syscall permitted" +} +expect { + timeout {puts "TESTING ERROR 23\n";exit} + "UGLY: swapoff syscall permitted" +} +expect { + timeout {puts "TESTING ERROR 24\n";exit} + "UGLY: init_module syscall permitted" +} +expect { + timeout {puts "TESTING ERROR 25\n";exit} + "UGLY: delete_module syscall permitted" +} +expect { + timeout {puts "TESTING ERROR 26\n";exit} + "UGLY: chroot syscall permitted" +} +expect { + timeout {puts "TESTING ERROR 27\n";exit} + "UGLY: pivot_root syscall permitted" +} +expect { + timeout {puts "TESTING ERROR 28\n";exit} + "UGLY: iopl syscall permitted" +} +expect { + timeout {puts "TESTING ERROR 29\n";exit} + "UGLY: ioperm syscall permitted" +} +expect { + timeout {puts "TESTING ERROR 30\n";exit} + "GOOD: all capabilities are disabled" +} +after 100 + puts "\nall done\n" diff --git a/test/utils/command.exp b/test/utils/command.exp new file mode 100755 index 000000000..3b18540db --- /dev/null +++ b/test/utils/command.exp @@ -0,0 +1,23 @@ +#!/usr/bin/expect -f +# This file is part of Firejail project +# Copyright (C) 2014-2018 Firejail Authors +# License GPL v2 + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "firejail --quiet --private-etc=passwd,group -c ls -al /etc\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "cron" {puts "TESTING ERROR 2\n";exit} + "group" +} +expect { + timeout {puts "TESTING ERROR 3\n";exit} + "passwd" +} + + +after 100 +puts "\nall done\n" diff --git a/test/utils/name.exp b/test/utils/name.exp new file mode 100755 index 000000000..f00b5866e --- /dev/null +++ b/test/utils/name.exp @@ -0,0 +1,174 @@ +#!/usr/bin/expect -f +# This file is part of Firejail project +# Copyright (C) 2014-2018 Firejail Authors +# License GPL v2 + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + + +send -- "firejail --name=ftest\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +after 100 + +spawn $env(SHELL) +send -- "firejail --name=ftest\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "Child process initialized" +} +after 100 + +spawn $env(SHELL) +send -- "firejail --name=ftest\r" +expect { + timeout {puts "TESTING ERROR 2\n";exit} + "Child process initialized" +} +after 100 + +spawn $env(SHELL) +send -- "firejail --name=ftest\r" +expect { + timeout {puts "TESTING ERROR 3\n";exit} + "Child process initialized" +} +after 100 + +spawn $env(SHELL) +send -- "firejail --name=ftest\r" +expect { + timeout {puts "TESTING ERROR 4\n";exit} + "Child process initialized" +} +after 100 + +spawn $env(SHELL) +send -- "firejail --name=ftest\r" +expect { + timeout {puts "TESTING ERROR 5\n";exit} + "Child process initialized" +} +after 100 + +spawn $env(SHELL) +send -- "firejail --name=ftest\r" +expect { + timeout {puts "TESTING ERROR 6\n";exit} + "Child process initialized" +} +after 100 + +spawn $env(SHELL) +send -- "firejail --name=ftest\r" +expect { + timeout {puts "TESTING ERROR 7\n";exit} + "Child process initialized" +} +after 100 + +spawn $env(SHELL) +send -- "firejail --name=ftest\r" +expect { + timeout {puts "TESTING ERROR 8\n";exit} + "Child process initialized" +} +after 100 + +spawn $env(SHELL) +send -- "firejail --name=ftest\r" +expect { + timeout {puts "TESTING ERROR 9\n";exit} + "Child process initialized" +} +after 100 + +spawn $env(SHELL) +send -- "firejail --name=ftest\r" +expect { + timeout {puts "TESTING ERROR 10\n";exit} + "Child process initialized" +} +after 100 + +spawn $env(SHELL) +send -- "firejail --name=ftest\r" +expect { + timeout {puts "TESTING ERROR 11\n";exit} + "Child process initialized" +} +after 100 + +spawn $env(SHELL) +send -- "firejail --list\r" +expect { + timeout {puts "TESTING ERROR 12\n";exit} + ":ftest:" +} +expect { + timeout {puts "TESTING ERROR 13\n";exit} + ":ftest-1:" +} +expect { + timeout {puts "TESTING ERROR 14\n";exit} + ":ftest-2:" +} +expect { + timeout {puts "TESTING ERROR 15\n";exit} + ":ftest-3:" +} +expect { + timeout {puts "TESTING ERROR 16\n";exit} + ":ftest-4:" +} +expect { + timeout {puts "TESTING ERROR 17\n";exit} + ":ftest-5:" +} +expect { + timeout {puts "TESTING ERROR 18\n";exit} + ":ftest-6:" +} +expect { + timeout {puts "TESTING ERROR 19\n";exit} + ":ftest-7:" +} +expect { + timeout {puts "TESTING ERROR 20\n";exit} + ":ftest-8:" +} +expect { + timeout {puts "TESTING ERROR 21\n";exit} + ":ftest-9:" +} +expect { + timeout {puts "TESTING ERROR 22\n";exit} + ":ftest-" +} +expect { + timeout {puts "TESTING ERROR 23\n";exit} + ":ftest-" +} +after 100 + +send -- "firejail --shutdown=ftest-5\r" +expect { + timeout {puts "TESTING ERROR 11\n";exit} + "Sending SIGTERM" +} +sleep 1 + +spawn $env(SHELL) +send -- "firejail --list\r" +expect { + timeout {puts "TESTING ERROR 12\n";exit} + ":ftest-5:" {puts "TESTING ERROR 15\n";exit} + ":ftest-9:" +} + +after 100 +puts "all done\n" diff --git a/test/utils/profile_print.exp b/test/utils/profile_print.exp new file mode 100755 index 000000000..20d88a264 --- /dev/null +++ b/test/utils/profile_print.exp @@ -0,0 +1,27 @@ +#!/usr/bin/expect -f +# This file is part of Firejail project +# Copyright (C) 2014-2018 Firejail Authors +# License GPL v2 + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + + +send -- "firejail --name=ftest\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +after 100 + +spawn $env(SHELL) +send -- "firejail --profile.print=ftest\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "/etc/firejail/default.profile" +} + + +after 100 +puts "all done\n" diff --git a/test/utils/utils.sh b/test/utils/utils.sh index d72cc2269..9259ee33a 100755 --- a/test/utils/utils.sh +++ b/test/utils/utils.sh @@ -20,6 +20,15 @@ rm -f ~/firejail-test-file-7699 echo "TESTING: audit (test/utils/audit.exp)" ./audit.exp +echo "TESTING: name (test/utils/name.exp)" +./name.exp + +echo "TESTING: command (test/utils/command.exp)" +./command.exp + +echo "TESTING: profile.print (test/utils/profile_print.exp)" +./profile_print.exp + echo "TESTING: version (test/utils/version.exp)" ./version.exp -- cgit v1.2.3-54-g00ecf