From 3cc86927c990f85326d4b6f6b8b9d8ee9d8613e5 Mon Sep 17 00:00:00 2001 From: netblue30 Date: Mon, 13 Jun 2016 12:04:35 -0400 Subject: testing --- test/dns.exp | 69 ------------------------------- test/doubledash.exp | 60 --------------------------- test/environment/dns.exp | 30 ++++++++++++++ test/environment/doubledash.exp | 60 +++++++++++++++++++++++++++ test/environment/environment.sh | 16 ++++++++ test/environment/extract_command.exp | 23 +++++++++++ test/environment/output.exp | 65 +++++++++++++++++++++++++++++ test/environment/output.sh | 9 ++++ test/extract_command.exp | 23 ----------- test/google-chrome.exp | 80 ------------------------------------ test/output.exp | 66 ----------------------------- test/output.sh | 9 ---- test/test.sh | 7 ---- 13 files changed, 203 insertions(+), 314 deletions(-) delete mode 100755 test/dns.exp delete mode 100755 test/doubledash.exp create mode 100755 test/environment/dns.exp create mode 100755 test/environment/doubledash.exp create mode 100755 test/environment/extract_command.exp create mode 100755 test/environment/output.exp create mode 100755 test/environment/output.sh delete mode 100755 test/extract_command.exp delete mode 100755 test/google-chrome.exp delete mode 100755 test/output.exp delete mode 100755 test/output.sh (limited to 'test') diff --git a/test/dns.exp b/test/dns.exp deleted file mode 100755 index 96513f278..000000000 --- a/test/dns.exp +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/expect -f - -set timeout 30 -spawn $env(SHELL) -match_max 100000 - -# no chroot -send -- "firejail --trace --dns=208.67.222.222 wget -q debian.org\r" -expect { - timeout {puts "TESTING ERROR 1.1\n";exit} - "Child process initialized" -} -expect { - timeout {puts "TESTING ERROR 1.2\n";exit} - "1:wget:connect 208.67.222.222:53" -} -sleep 1 - -send -- "rm index.html\r" -sleep 1 - -# with chroot -send -- "firejail --chroot=/tmp/chroot --trace --dns=208.67.222.222 wget -q debian.org\r" -expect { - timeout {puts "TESTING ERROR 2.1\n";exit} - "Child process initialized" -} -expect { - timeout {puts "TESTING ERROR 2.2\n";exit} - "1:wget:connect 208.67.222.222:53" -} -sleep 1 - -send -- "rm index.html\r" -sleep 1 - -# net eth0 -send -- "firejail --net=eth0 --trace --dns=208.67.222.222 wget -q debian.org\r" -expect { - timeout {puts "TESTING ERROR 3.1\n";exit} - "Child process initialized" -} -expect { - timeout {puts "TESTING ERROR 3.2\n";exit} - "1:wget:connect 208.67.222.222:53" -} -sleep 1 - -send -- "rm index.html\r" -sleep 1 - -# net eth0 and chroot -send -- "firejail --net=eth0 --chroot=/tmp/chroot --trace --dns=208.67.222.222 wget -q debian.org\r" -expect { - timeout {puts "TESTING ERROR 4.1\n";exit} - "Child process initialized" -} -expect { - timeout {puts "TESTING ERROR 4.2\n";exit} - "1:wget:connect 208.67.222.222:53" -} -sleep 1 - -send -- "rm index.html\r" -sleep 1 - - -puts "\n" - diff --git a/test/doubledash.exp b/test/doubledash.exp deleted file mode 100755 index 668468980..000000000 --- a/test/doubledash.exp +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/expect -f - -set timeout 10 -spawn $env(SHELL) -match_max 100000 - -send -- "firejail -- ls -- -testdir\r" -expect { - timeout {puts "TESTING ERROR 1\n";exit} - "Child process initialized" -} -expect { - timeout {puts "TESTING ERROR 2\n";exit} - "ttt" -} -expect { - timeout {puts "TESTING ERROR 3\n";exit} - "Parent is shutting down" -} -sleep 1 - - -send -- "firejail --name=testing -- -testdir/bash\r" -expect { - timeout {puts "TESTING ERROR 4\n";exit} - "Child process initialized" -} -sleep 3 - -spawn $env(SHELL) -send -- "firejail --join=testing -- -testdir/bash\r" -expect { - timeout {puts "TESTING ERROR 5\n";exit} - "the first child process inside the sandbox" -} -sleep 3 - -spawn $env(SHELL) -send -- "firejail --list;pwd\r" -expect { - timeout {puts "TESTING ERROR 6\n";exit} - "name=testing" -} -expect { - timeout {puts "TESTING ERROR 7\n";exit} - "home" -} -send -- "firejail --list;pwd\r" -expect { - timeout {puts "TESTING ERROR 8 (join)\n";exit} - "join=testing" -} -expect { - timeout {puts "TESTING ERROR 9\n";exit} - "home" -} - -sleep 1 - -puts "\n" diff --git a/test/environment/dns.exp b/test/environment/dns.exp new file mode 100755 index 000000000..6ffb124cf --- /dev/null +++ b/test/environment/dns.exp @@ -0,0 +1,30 @@ +#!/usr/bin/expect -f + +set timeout 30 +spawn $env(SHELL) +match_max 100000 + +# no chroot +send -- "firejail --trace --dns=208.67.222.222 wget -q debian.org\r" +expect { + timeout {puts "TESTING ERROR 1.1\n";exit} + "Child process initialized" +} +expect { + timeout {puts "TESTING ERROR 1.2\n";exit} + "connect" +} +expect { + timeout {puts "TESTING ERROR 1.2\n";exit} + "208.67.222.222" +} +expect { + timeout {puts "TESTING ERROR 1.2\n";exit} + "53" +} + +after 100 + +send -- "rm index.html\r" +after 100 +puts "\nall done\n" diff --git a/test/environment/doubledash.exp b/test/environment/doubledash.exp new file mode 100755 index 000000000..668468980 --- /dev/null +++ b/test/environment/doubledash.exp @@ -0,0 +1,60 @@ +#!/usr/bin/expect -f + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "firejail -- ls -- -testdir\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "Child process initialized" +} +expect { + timeout {puts "TESTING ERROR 2\n";exit} + "ttt" +} +expect { + timeout {puts "TESTING ERROR 3\n";exit} + "Parent is shutting down" +} +sleep 1 + + +send -- "firejail --name=testing -- -testdir/bash\r" +expect { + timeout {puts "TESTING ERROR 4\n";exit} + "Child process initialized" +} +sleep 3 + +spawn $env(SHELL) +send -- "firejail --join=testing -- -testdir/bash\r" +expect { + timeout {puts "TESTING ERROR 5\n";exit} + "the first child process inside the sandbox" +} +sleep 3 + +spawn $env(SHELL) +send -- "firejail --list;pwd\r" +expect { + timeout {puts "TESTING ERROR 6\n";exit} + "name=testing" +} +expect { + timeout {puts "TESTING ERROR 7\n";exit} + "home" +} +send -- "firejail --list;pwd\r" +expect { + timeout {puts "TESTING ERROR 8 (join)\n";exit} + "join=testing" +} +expect { + timeout {puts "TESTING ERROR 9\n";exit} + "home" +} + +sleep 1 + +puts "\n" diff --git a/test/environment/environment.sh b/test/environment/environment.sh index 49b50797a..a6fe07a1c 100755 --- a/test/environment/environment.sh +++ b/test/environment/environment.sh @@ -6,6 +6,22 @@ export MALLOC_CHECK_=3 export MALLOC_PERTURB_=$(($RANDOM % 255 + 1)) +echo "TESTING: DNS (test/environment/dns.exp)" +./dns.exp + +echo "TESTING: doubledash (test/environment/doubledash.exp" +mkdir -- -testdir +touch -- -testdir/ttt +cp -- /bin/bash -testdir/. +./doubledash.exp +rm -fr -- -testdir + +echo "TESTING: output (test/environment/output.exp)" +./output.exp + +echo "TESTING: extract command (extract_command.exp)" +./extract_command.exp + echo "TESTING: environment variables (test/environment/env.exp)" ./env.exp diff --git a/test/environment/extract_command.exp b/test/environment/extract_command.exp new file mode 100755 index 000000000..266f66ff5 --- /dev/null +++ b/test/environment/extract_command.exp @@ -0,0 +1,23 @@ +#!/usr/bin/expect -f + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "firejail --debug ls -al\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Reading profile /etc/firejail/default.profile" +} +expect { + timeout {puts "TESTING ERROR 2\n";exit} + "Child process initialized" +} +expect { + timeout {puts "TESTING ERROR 2\n";exit} + "Parent is shutting down, bye" +} +after 100 + +puts "\nall done\n" + diff --git a/test/environment/output.exp b/test/environment/output.exp new file mode 100755 index 000000000..10c325832 --- /dev/null +++ b/test/environment/output.exp @@ -0,0 +1,65 @@ +#!/usr/bin/expect -f + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "rm -f logfile*\r" +sleep 1 +puts "\n" + +send -- "firejail --output=logfile -- ./output.sh\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "20000" +} +expect { + timeout {puts "TESTING ERROR 1.1\n";exit} + "60000" +} +expect { + timeout {puts "TESTING ERROR 1.2\n";exit} + "100000" +} +expect { + timeout {puts "TESTING ERROR 1.3\n";exit} + "120000" +} +expect { + timeout {puts "TESTING ERROR 1.4\n";exit} + "14999" +} +sleep 2 +puts "\n" + + +set timeout 2 +send -- "ls -al logfile*\r" +expect { + timeout {puts "TESTING ERROR 2\n";exit} + "logfile" +} +expect { + timeout {puts "TESTING ERROR 3\n";exit} + "logfile.1" +} +expect { + timeout {puts "TESTING ERROR 4\n";exit} + "logfile.2" +} +expect { + timeout {puts "TESTING ERROR 5\n";exit} + "logfile.3" +} +expect { + timeout {puts "TESTING ERROR 6\n";exit} + "logfile.4" +} +expect { + timeout {puts "TESTING ERROR 7\n";exit} + "logfile.5" +} +after 100 +send -- "rm -f logfile*\r" +after 100 +puts "\nall done\n" diff --git a/test/environment/output.sh b/test/environment/output.sh new file mode 100755 index 000000000..2be188e3a --- /dev/null +++ b/test/environment/output.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +i="0" + +while [ $i -lt 150000 ] +do + echo message number $i + i=$[$i+1] +done diff --git a/test/extract_command.exp b/test/extract_command.exp deleted file mode 100755 index 851b793c9..000000000 --- a/test/extract_command.exp +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/expect -f - -set timeout 10 -spawn $env(SHELL) -match_max 100000 - -send -- "firejail --debug ls -al\r" -expect { - timeout {puts "TESTING ERROR 0\n";exit} - "Reading profile /etc/firejail/default.profile" -} -expect { - timeout {puts "TESTING ERROR 2\n";exit} - "Child process initialized" -} -expect { - timeout {puts "TESTING ERROR 2\n";exit} - "Parent is shutting down, bye" -} -sleep 1 - -puts "\nall done\n" - diff --git a/test/google-chrome.exp b/test/google-chrome.exp deleted file mode 100755 index 389988e3c..000000000 --- a/test/google-chrome.exp +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/expect -f - -set timeout 10 -spawn $env(SHELL) -match_max 100000 - -send -- "firejail google-chrome www.gentoo.org\r" -expect { - timeout {puts "TESTING ERROR 0\n";exit} - "Reading profile /etc/firejail/google-chrome.profile" -} -expect { - timeout {puts "TESTING ERROR 1\n";exit} - "Child process initialized" -} -sleep 10 - -spawn $env(SHELL) -send -- "firejail --list\r" -expect { - timeout {puts "TESTING ERROR 3\n";exit} - ":firejail" -} -expect { - timeout {puts "TESTING ERROR 3.1\n";exit} - "google-chrome" -} -sleep 1 - -# grsecurity exit -send -- "file /proc/sys/kernel/grsecurity\r" -expect { - timeout {puts "TESTING ERROR - grsecurity detection\n";exit} - "grsecurity: directory" {puts "grsecurity present, exiting...\n";exit} - "cannot open" {puts "grsecurity not present\n"} -} - -send -- "firejail --name=blablabla\r" -expect { - timeout {puts "TESTING ERROR 4\n";exit} - "Child process initialized" -} -sleep 2 - -spawn $env(SHELL) -send -- "firemon --seccomp\r" -expect { - timeout {puts "TESTING ERROR 5\n";exit} - ":firejail google-chrome" -} -expect { - timeout {puts "TESTING ERROR 5.1\n";exit} - "Seccomp: 0" -} -expect { - timeout {puts "TESTING ERROR 5.1\n";exit} - "name=blablabla" -} -sleep 1 -send -- "firemon --caps\r" -expect { - timeout {puts "TESTING ERROR 6\n";exit} - ":firejail google-chrome" -} -expect { - timeout {puts "TESTING ERROR 6.1\n";exit} - "CapBnd:" -} -expect { - timeout {puts "TESTING ERROR 6.2\n";exit} - "fffffffff" -} -expect { - timeout {puts "TESTING ERROR 6.3\n";exit} - "name=blablabla" -} -sleep 1 - -puts "\n" - diff --git a/test/output.exp b/test/output.exp deleted file mode 100755 index 90a9d64b6..000000000 --- a/test/output.exp +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/expect -f - -set timeout 10 -spawn $env(SHELL) -match_max 100000 - -send -- "rm -f logfile*\r" -sleep 1 -puts "\n" - -send -- "firejail --output=logfile -- ./output.sh\r" -expect { - timeout {puts "TESTING ERROR 1\n";exit} - "20000" -} -expect { - timeout {puts "TESTING ERROR 1.1\n";exit} - "60000" -} -expect { - timeout {puts "TESTING ERROR 1.2\n";exit} - "100000" -} -expect { - timeout {puts "TESTING ERROR 1.3\n";exit} - "120000" -} -expect { - timeout {puts "TESTING ERROR 1.4\n";exit} - "14999" -} -sleep 2 -puts "\n" - - -set timeout 2 -send -- "ls -al logfile*\r" -expect { - timeout {puts "TESTING ERROR 2\n";exit} - "logfile" -} -expect { - timeout {puts "TESTING ERROR 3\n";exit} - "logfile.1" -} -expect { - timeout {puts "TESTING ERROR 4\n";exit} - "logfile.2" -} -expect { - timeout {puts "TESTING ERROR 5\n";exit} - "logfile.3" -} -expect { - timeout {puts "TESTING ERROR 6\n";exit} - "logfile.4" -} -expect { - timeout {puts "TESTING ERROR 7\n";exit} - "logfile.5" -} -sleep 1 -send -- "rm -f logfile*\r" -sleep 1 - -puts "\n" diff --git a/test/output.sh b/test/output.sh deleted file mode 100755 index 2be188e3a..000000000 --- a/test/output.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -i="0" - -while [ $i -lt 150000 ] -do - echo message number $i - i=$[$i+1] -done diff --git a/test/test.sh b/test/test.sh index c4f0afd94..4d57aaad2 100755 --- a/test/test.sh +++ b/test/test.sh @@ -27,13 +27,6 @@ rm -fr auto2 rm -fr auto3 rm -fr auto4 -echo "TESTING: doubledash" -mkdir -- -testdir -touch -- -testdir/ttt -cp -- /bin/bash -testdir/. -./doubledash.exp -rm -fr -- -testdir - echo "TESTING: extract command (extract_command.exp)" ./extract_command.exp -- cgit v1.2.3-54-g00ecf