From 45060ec40f0e9790d5e6a503486867951df71300 Mon Sep 17 00:00:00 2001 From: netblue30 Date: Tue, 20 Oct 2015 11:01:40 -0400 Subject: testing and fixes --- test/extract_command.exp | 16 ++-- test/invalid_filename.exp | 236 ++++++++++++++++++++++++++++++++++++++++++++++ test/private.exp | 2 +- test/profile_apps.exp | 48 ---------- test/test.sh | 6 +- 5 files changed, 250 insertions(+), 58 deletions(-) create mode 100755 test/invalid_filename.exp delete mode 100755 test/profile_apps.exp (limited to 'test') diff --git a/test/extract_command.exp b/test/extract_command.exp index c49614b84..b4a1eeeb5 100755 --- a/test/extract_command.exp +++ b/test/extract_command.exp @@ -4,20 +4,24 @@ set timeout 10 spawn $env(SHELL) match_max 100000 -send -- "firejail --debug /usr/bin/firefox www.gentoo.org\r" +send -- "firejail --debug ls -al\r" expect { timeout {puts "TESTING ERROR 0\n";exit} - "Reading profile /etc/firejail/firefox.profile" + "Reading profile /etc/firejail/generic.profile" } expect { timeout {puts "TESTING ERROR 1\n";exit} - "Starting /usr/bin/firefox" + "Starting ls -al" } expect { - timeout {puts "TESTING ERROR 1\n";exit} + timeout {puts "TESTING ERROR 2\n";exit} "Child process initialized" } -sleep 5 +expect { + timeout {puts "TESTING ERROR 2\n";exit} + "parent is shutting down, bye" +} +sleep 1 -puts "\n" +puts "\nall done\n" diff --git a/test/invalid_filename.exp b/test/invalid_filename.exp new file mode 100755 index 000000000..ca35262f8 --- /dev/null +++ b/test/invalid_filename.exp @@ -0,0 +1,236 @@ +#!/usr/bin/expect -f + +#invalid_filename checks: +# +#--bind (two files) - profile.c - Note: The test is not implemented here, need to be root to test it +#--blacklist - profile.c +#--cgroup - cgroup.c +#--chroot - main.c +#--netfilter - netfilter.c +#--output - output.c +#--private - fs_home.c +#--privte-bin (list) - fs_bin.c +#--private-keep/--private-home (list) - fs_home.c +#--private-etc (list) - fs_etc.c +#--profile - main.c +#--read_only - profile.c +#--shell - main.c +#--tmpfs - profile.c +#--white-list + + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "firejail --debug --noprofile --blacklist=\"bla&&bla\"\r" +expect { + timeout {puts "TESTING ERROR 1.1\n";exit} + "Checking filename bla&&bla" +} +expect { + timeout {puts "TESTING ERROR 1.2\n";exit} + "Error:" +} +expect { + timeout {puts "TESTING ERROR 1.3\n";exit} + "is an invalid filename" +} +after 100 + +send -- "firejail --debug --noprofile --cgroup=\"bla&&bla\"\r" +expect { + timeout {puts "TESTING ERROR 2.1\n";exit} + "Checking filename bla&&bla" +} +expect { + timeout {puts "TESTING ERROR 2.2\n";exit} + "Error:" +} +expect { + timeout {puts "TESTING ERROR 2.3\n";exit} + "is an invalid filename" +} +after 100 + +send -- "firejail --debug --noprofile --chroot=\"bla&&bla\"\r" +expect { + timeout {puts "TESTING ERROR 3.1\n";exit} + "Checking filename bla&&bla" +} +expect { + timeout {puts "TESTING ERROR 3.2\n";exit} + "Error:" +} +expect { + timeout {puts "TESTING ERROR 3.3\n";exit} + "is an invalid filename" +} +after 100 + +send -- "firejail --debug --noprofile --netfilter=\"bla&&bla\"\r" +expect { + timeout {puts "TESTING ERROR 4.1\n";exit} + "Checking filename bla&&bla" +} +expect { + timeout {puts "TESTING ERROR 4.2\n";exit} + "Error:" +} +expect { + timeout {puts "TESTING ERROR 4.3\n";exit} + "is an invalid filename" +} +after 100 + +send -- "firejail --debug --noprofile --output=\"bla&&bla\"\r" +expect { + timeout {puts "TESTING ERROR 5.2\n";exit} + "Error:" +} +expect { + timeout {puts "TESTING ERROR 5.3\n";exit} + "is an invalid filename" +} +after 100 + +send -- "firejail --debug --noprofile --private=\"bla&&bla\"\r" +expect { + timeout {puts "TESTING ERROR 6.1\n";exit} + "Checking filename bla&&bla" +} +expect { + timeout {puts "TESTING ERROR 6.2\n";exit} + "Error:" +} +expect { + timeout {puts "TESTING ERROR 6.3\n";exit} + "is an invalid filename" +} +after 100 + +send -- "firejail --debug --noprofile --private-bin=\"bla&&bla\"\r" +expect { + timeout {puts "TESTING ERROR 7.1\n";exit} + "Checking filename bla&&bla" +} +expect { + timeout {puts "TESTING ERROR 7.2\n";exit} + "Error:" +} +expect { + timeout {puts "TESTING ERROR 7.3\n";exit} + "is an invalid filename" +} +after 100 + +send -- "firejail --debug --noprofile --private-home=\"bla&&bla\"\r" +expect { + timeout {puts "TESTING ERROR 8.1\n";exit} + "Checking filename bla&&bla" +} +expect { + timeout {puts "TESTING ERROR 8.2\n";exit} + "Error:" +} +expect { + timeout {puts "TESTING ERROR 8.3\n";exit} + "is an invalid filename" +} +after 100 + + +send -- "firejail --debug --noprofile --private-etc=\"bla&&bla\"\r" +expect { + timeout {puts "TESTING ERROR 9.1\n";exit} + "Checking filename bla&&bla" +} +expect { + timeout {puts "TESTING ERROR 9.2\n";exit} + "Error:" +} +expect { + timeout {puts "TESTING ERROR 9.3\n";exit} + "is an invalid filename" +} +after 100 + +send -- "firejail --debug --profile=\"bla&&bla\"\r" +expect { + timeout {puts "TESTING ERROR 10.1\n";exit} + "Checking filename bla&&bla" +} +expect { + timeout {puts "TESTING ERROR 10.2\n";exit} + "Error:" +} +expect { + timeout {puts "TESTING ERROR 10.3\n";exit} + "is an invalid filename" +} +after 100 + +send -- "firejail --debug --read-only=\"bla&&bla\"\r" +expect { + timeout {puts "TESTING ERROR 11.1\n";exit} + "Checking filename bla&&bla" +} +expect { + timeout {puts "TESTING ERROR 11.2\n";exit} + "Error:" +} +expect { + timeout {puts "TESTING ERROR 11.3\n";exit} + "is an invalid filename" +} +after 100 + +send -- "firejail --debug --shell=\"bla&&bla\"\r" +expect { + timeout {puts "TESTING ERROR 12.1\n";exit} + "Checking filename bla&&bla" +} +expect { + timeout {puts "TESTING ERROR 12.2\n";exit} + "Error:" +} +expect { + timeout {puts "TESTING ERROR 12.3\n";exit} + "is an invalid filename" +} +after 100 + +send -- "firejail --debug --tmpfs=\"bla&&bla\"\r" +expect { + timeout {puts "TESTING ERROR 13.1\n";exit} + "Checking filename bla&&bla" +} +expect { + timeout {puts "TESTING ERROR 13.2\n";exit} + "Error:" +} +expect { + timeout {puts "TESTING ERROR 13.3\n";exit} + "is an invalid filename" +} +after 100 + +send -- "firejail --debug --whitelist=\"bla&&bla\"\r" +expect { + timeout {puts "TESTING ERROR 14.1\n";exit} + "Checking filename bla&&bla" +} +expect { + timeout {puts "TESTING ERROR 14.2\n";exit} + "Error:" +} +expect { + timeout {puts "TESTING ERROR 14.3\n";exit} + "is an invalid filename" +} +after 100 + + + +puts "\nall done\n" + diff --git a/test/private.exp b/test/private.exp index 6f9dadf8f..8a6796802 100755 --- a/test/private.exp +++ b/test/private.exp @@ -12,7 +12,7 @@ if { $argc != 1 } { } # testing profile and private -send -- "firejail --private --profile=/etc/firejail/firefox.profile\r" +send -- "firejail --private --profile=/etc/firejail/generic.profile\r" expect { timeout {puts "TESTING ERROR 0\n";exit} "Child process initialized" diff --git a/test/profile_apps.exp b/test/profile_apps.exp deleted file mode 100755 index c57b31489..000000000 --- a/test/profile_apps.exp +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/expect -f - -set timeout 10 -spawn $env(SHELL) -match_max 100000 - -# firefox -send -- "firejail --profile=/etc/firejail/firefox.profile\r" -expect { - timeout {puts "TESTING ERROR 0\n";exit} - "Child process initialized" -} -sleep 1 -send -- "exit\r" -sleep 1 - -# iceweasel -send -- "firejail --profile=/etc/firejail/iceweasel.profile\r" -expect { - timeout {puts "TESTING ERROR 1\n";exit} - "Child process initialized" -} -sleep 1 -send -- "exit\r" -sleep 1 - -# evince -send -- "firejail --profile=/etc/firejail/evince.profile\r" -expect { - timeout {puts "TESTING ERROR 2\n";exit} - "Child process initialized" -} -sleep 1 -send -- "exit\r" -sleep 1 - -# midori -send -- "firejail --profile=/etc/firejail/midori.profile\r" -expect { - timeout {puts "TESTING ERROR 3\n";exit} - "Child process initialized" -} -sleep 1 -send -- "exit\r" -sleep 1 - - -puts "\n" diff --git a/test/test.sh b/test/test.sh index 7d43a5786..c986b5f29 100755 --- a/test/test.sh +++ b/test/test.sh @@ -12,6 +12,9 @@ done ./fscheck.sh +echo "TESTING: invalid filename" +./invalid_filename.exp + echo "TESTING: environment variables" ./env.exp @@ -276,9 +279,6 @@ echo "TESTING: profile read-only" echo "TESTING: profile tmpfs" ./profile_tmpfs.exp -echo "TESTING: profile applications" -./profile_apps.exp - echo "TESTING: private" ./private.exp `whoami` -- cgit v1.2.3-70-g09d2