Add image_test.sh 24/116124/3
authorjin-gyu.kim <jin-gyu.kim@samsung.com>
Thu, 23 Feb 2017 05:34:09 +0000 (14:34 +0900)
committerjin-gyu.kim <jin-gyu.kim@samsung.com>
Fri, 24 Feb 2017 04:24:06 +0000 (13:24 +0900)
- This script will be used at the time of image build.

Change-Id: I94c67b397450ede4913360afed0851c88678e087

packaging/security-config.spec
test/CMakeLists.txt
test/aslr_test/CMakeLists.txt
test/aslr_test/scripts/_sh_util_lib [deleted file]
test/dep_test/CMakeLists.txt
test/dep_test/scripts/_sh_util_lib [deleted file]
test/dep_test/scripts/run_dep_test.sh
test/dep_test/scripts/utillib.i386 [deleted file]
test/dep_test/scripts/utillib.x86_64 [deleted file]
test/image_test.sh [new file with mode: 0644]
test/utils/_sh_util_lib

index 8c5574a1a52b035c95875787515c9be596a0f8df..7e7b3eb5f947ddd1d83d4318b6fa65cf219cc0c9 100755 (executable)
@@ -92,9 +92,10 @@ rm /opt/share/security-config/test/capability_test/*
 %attr(755,root,root) /usr/share/security-config/set_capability
 %attr(755,root,root) /usr/share/security-config/mdm_blacklist
 %attr(644,root,root) /usr/lib/tmpfiles.d/security-config.conf
-#%attr(755,root,root) /usr/share/security-config/test/aslr_test/*
+%attr(755,root,root) /opt/share/security-config/test/*
+%attr(755,root,root) /opt/share/security-config/test/aslr_test/*
 %attr(755,root,root) /opt/share/security-config/test/utils/*
-#%attr(755,root,root) /usr/share/security-config/test/dep_test/*
+%attr(755,root,root) /opt/share/security-config/test/dep_test/*
 %attr(755,root,root) /opt/share/security-config/test/setuid_test/*
 %attr(755,root,root) /opt/share/security-config/test/smack_rule_test/*
 %attr(755,root,root) /opt/share/security-config/test/root_test/*
index 1b483fa9ee60a4379ee6cd85b1113a5a19a5c845..bbd2944853f1ac0b30bd70d9c187aa6e3856bd1a 100755 (executable)
@@ -1,6 +1,12 @@
+INSTALL(FILES
+          image_test.sh
+          DESTINATION
+          /opt/share/security-config/test/
+)
+
 ADD_SUBDIRECTORY(utils)
-#ADD_SUBDIRECTORY(aslr_test)    #This test is not included in image.
-#ADD_SUBDIRECTORY(dep_test)     #This test is not included in image.
+ADD_SUBDIRECTORY(aslr_test)
+ADD_SUBDIRECTORY(dep_test)
 ADD_SUBDIRECTORY(setuid_test)
 ADD_SUBDIRECTORY(path_check_test)
 ADD_SUBDIRECTORY(capability_test)
index d2ce362713d71e84dffb71f5cc85663c0c6c8973..8817fda028b8797aea60d77d905084176d9392e9 100755 (executable)
@@ -1,13 +1,5 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 
-FILE(GLOB SHELL_SCRIPT *.sh)
-INSTALL(FILES
-       ${SHELL_SCRIPT}
-       README
-       DESTINATION
-       /opt/share/security-config/test/aslr_test
-)
-
 INSTALL(DIRECTORY
        ${CMAKE_SOURCE_DIR}/test/aslr_test/scripts
        DESTINATION
diff --git a/test/aslr_test/scripts/_sh_util_lib b/test/aslr_test/scripts/_sh_util_lib
deleted file mode 100644 (file)
index 771d798..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-#!/bin/bash
-
-PATH=/bin:/usr/bin:/sbin:/usr/sbin
-
-#========================================================
-# [Cmd]
-#========================================================
-BIN="/usr/bin"
-GREP="${BIN}/grep"
-CAT="${BIN}/cat"
-FIND="${BIN}/find"
-XARGS="${BIN}/xargs"
-TOUCH="${BIN}/touch"
-RM="${BIN}/rm"
-SED="${BIN}/sed"
-WHOAMI="${BIN}/whoami"
-CUT="${BIN}/cut"
-SORT="${BIN}/sort"
-EXPR="${BIN}/expr"
-MKDIR="${BIN}/mkdir"
-MV="${BIN}/mv"
-UNIQ="${BIN}/uniq"
-CP="${BIN}/cp"
-LN="${BIN}/ln"
-LS="${BIN}/ls"
-#========================================================
-# [Directory and file]
-#========================================================
-base_dir="/opt/share/security-config"
-utils_dir="$base_dir/test/utils"
-aslr_script_dir="$base_dir/test/aslr_test"
-dep_script_dir="$base_dir/test/dep_test"
-suid_script_dir="$base_dir/test/setuid_test"
-log_dir="$base_dir/log"
-result_dir="$base_dir/result"
-
-#========================================================
-# [Functions]
-#========================================================
-#========================================================
-# [fn] Change console color
-#========================================================
-RESET=0;BRIGHT=1;DIM=2;ITALIC=3;UNDERLINE=4
-BLINK_SLOW=5;BLINK_RAPID=6;REVERSE=7;HIDDEN=8
-
-BLACK=0;RED=1;GREEN=2;YELLOW=3
-BLUE=4;MAGENTA=5;CYAN=6;WHITE=7
-
-FONT_OFFSET=30
-BACK_OFFSET=40
-
-# Ignore Background now
-function fnChangeConsoleColor {
-
-       argc=$#
-       if [ $argc -eq 3 ]; then
-               FontColor=`expr $2 + $FONT_OFFSET`
-               cmd="\e[$1;$FontColor""m"
-               echo -e $cmd
-       else
-               echo "[Usage] ChangeConsoleColor Brightness FontColor BackColor"
-       fi
-
-}
-
-function fnRestoreOriginalColor {
-
-       echo -e "\e[m";
-
-}
-
-#=========================================================
-# [fn] Modified echo
-#=========================================================
-#echo Info
-function echoI {
-
-       fnChangeConsoleColor $BRIGHT $BLUE $BLACK
-       echo "========================================================="
-       echo $@
-       echo "========================================================="
-       fnRestoreOriginalColor
-
-}
-
-# echo Success
-function echoS {
-
-       fnChangeConsoleColor $BRIGHT $GREEN $BLACK
-       echo $@
-       fnRestoreOriginalColor
-
-}
-
-# echo Error
-function echoE {
-
-       fnChangeConsoleColor $BRIGHT $RED $BLACK
-       echo $@
-       fnRestoreOriginalColor
-
-}
-
-#=========================================================
-# [fn] Print done
-#=========================================================
-function fnPrintSDone {
-
-       echoS "Successfully Done!"
-
-}
-
-#=========================================================
-# [fn] Finish the script
-#=========================================================
-function fnFinishThisScript {
-
-       ret_val=$1
-       
-       if [ $ret_val -eq 0 ]
-       then
-               echoS "This script has completed successfully."
-       else
-               echoE "An error has occurred in this script."
-       fi
-
-       exit $ret_val
-
-}
index b4f664901c2aa8841cc42d0a3ac60c81d54867a7..96c3cbeb6c10e9559d6d66dbfd5cf7e82da931fa 100755 (executable)
@@ -1,13 +1,5 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 
-FILE(GLOB SHELL_SCRIPT *.sh)
-INSTALL(FILES
-       ${SHELL_SCRIPT}
-       README
-       DESTINATION
-       /opt/share/security-config/test/dep_test
-)
-
 INSTALL(DIRECTORY
        ${CMAKE_SOURCE_DIR}/test/dep_test/scripts
        DESTINATION
diff --git a/test/dep_test/scripts/_sh_util_lib b/test/dep_test/scripts/_sh_util_lib
deleted file mode 100644 (file)
index 771d798..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-#!/bin/bash
-
-PATH=/bin:/usr/bin:/sbin:/usr/sbin
-
-#========================================================
-# [Cmd]
-#========================================================
-BIN="/usr/bin"
-GREP="${BIN}/grep"
-CAT="${BIN}/cat"
-FIND="${BIN}/find"
-XARGS="${BIN}/xargs"
-TOUCH="${BIN}/touch"
-RM="${BIN}/rm"
-SED="${BIN}/sed"
-WHOAMI="${BIN}/whoami"
-CUT="${BIN}/cut"
-SORT="${BIN}/sort"
-EXPR="${BIN}/expr"
-MKDIR="${BIN}/mkdir"
-MV="${BIN}/mv"
-UNIQ="${BIN}/uniq"
-CP="${BIN}/cp"
-LN="${BIN}/ln"
-LS="${BIN}/ls"
-#========================================================
-# [Directory and file]
-#========================================================
-base_dir="/opt/share/security-config"
-utils_dir="$base_dir/test/utils"
-aslr_script_dir="$base_dir/test/aslr_test"
-dep_script_dir="$base_dir/test/dep_test"
-suid_script_dir="$base_dir/test/setuid_test"
-log_dir="$base_dir/log"
-result_dir="$base_dir/result"
-
-#========================================================
-# [Functions]
-#========================================================
-#========================================================
-# [fn] Change console color
-#========================================================
-RESET=0;BRIGHT=1;DIM=2;ITALIC=3;UNDERLINE=4
-BLINK_SLOW=5;BLINK_RAPID=6;REVERSE=7;HIDDEN=8
-
-BLACK=0;RED=1;GREEN=2;YELLOW=3
-BLUE=4;MAGENTA=5;CYAN=6;WHITE=7
-
-FONT_OFFSET=30
-BACK_OFFSET=40
-
-# Ignore Background now
-function fnChangeConsoleColor {
-
-       argc=$#
-       if [ $argc -eq 3 ]; then
-               FontColor=`expr $2 + $FONT_OFFSET`
-               cmd="\e[$1;$FontColor""m"
-               echo -e $cmd
-       else
-               echo "[Usage] ChangeConsoleColor Brightness FontColor BackColor"
-       fi
-
-}
-
-function fnRestoreOriginalColor {
-
-       echo -e "\e[m";
-
-}
-
-#=========================================================
-# [fn] Modified echo
-#=========================================================
-#echo Info
-function echoI {
-
-       fnChangeConsoleColor $BRIGHT $BLUE $BLACK
-       echo "========================================================="
-       echo $@
-       echo "========================================================="
-       fnRestoreOriginalColor
-
-}
-
-# echo Success
-function echoS {
-
-       fnChangeConsoleColor $BRIGHT $GREEN $BLACK
-       echo $@
-       fnRestoreOriginalColor
-
-}
-
-# echo Error
-function echoE {
-
-       fnChangeConsoleColor $BRIGHT $RED $BLACK
-       echo $@
-       fnRestoreOriginalColor
-
-}
-
-#=========================================================
-# [fn] Print done
-#=========================================================
-function fnPrintSDone {
-
-       echoS "Successfully Done!"
-
-}
-
-#=========================================================
-# [fn] Finish the script
-#=========================================================
-function fnFinishThisScript {
-
-       ret_val=$1
-       
-       if [ $ret_val -eq 0 ]
-       then
-               echoS "This script has completed successfully."
-       else
-               echoE "An error has occurred in this script."
-       fi
-
-       exit $ret_val
-
-}
index a467d8a4a1d5f3a2b46b2c05aed4d9efa6c3ef9d..ae823002ffbfd3bc3a183b12b67252ac587db41b 100755 (executable)
@@ -97,8 +97,6 @@ $TOUCH $log_file
 $RM $result_file
 $TOUCH $result_file
 
-LIBDW="libdw-0.153.so"
-lib_dir=
 # Rename utils
 file_cmd=`$FIND $utils_dir -name file.*`
 readelf_cmd=`$FIND $utils_dir -name readelf.*`
@@ -109,44 +107,6 @@ if [ "$readelf_cmd" != "" ]; then
     $MV $readelf_cmd $utils_dir/readelf
 fi
 
-# Set lib_dir
-if [ -d "/usr/lib64" ]; then
-    lib_dir="/usr/lib64"
-elif [ -d "/usr/lib" ]; then
-    lib_dir="/usr/lib"
-else
-    echo "No proper lib dir"
-    exit 1
-fi
-echo "lib_dir = $lib_dir"
-
-arch_info=`$utils_dir/file $utils_dir/file`
-if [[ $arch_info == *"aarch64"* ]]
-then
-       echo "aarch64!!"
-       arch="aarch64"
-elif [[ $arch_info == *"ARM"* ]]
-then
-       echo "arm!!"
-       arch="arm"
-elif [[ $arch_info == *"x86-64"* ]]
-then
-       echo "x86_64!!"
-       arch="x86_64"
-elif [[ $arch_info == *"Intel"* ]]
-then
-       echo "i386!!"
-       arch="i386"
-fi
-
-# Set required utils
-libdw_lib=`$FIND $dep_script_dir -name utillib.$arch`
-if [ "$libdw_lib" != "" ]; then
-    $MV $libdw_lib $dep_script_dir/"$LIBDW"
-    $CP $dep_script_dir/$LIBDW $lib_dir
-    $LN $lib_dir/$LIBDW $lib_dir/libdw.so.1
-fi
-
 #=========================================================
 # [02] Make List
 #=========================================================
@@ -188,8 +148,4 @@ if [ -a $dep_script_dir/log.csv ]; then
        $MV $dep_script_dir/log.csv $log_dir/dep_test.log
 fi
 $MV $dep_script_dir/result $result_dir/dep_test.result
-
-if [ "$libdw_lib" != "" ]; then
-       rm $lib_dir/libdw*
-fi
 fnPrintSDone
diff --git a/test/dep_test/scripts/utillib.i386 b/test/dep_test/scripts/utillib.i386
deleted file mode 100755 (executable)
index 4ce0230..0000000
Binary files a/test/dep_test/scripts/utillib.i386 and /dev/null differ
diff --git a/test/dep_test/scripts/utillib.x86_64 b/test/dep_test/scripts/utillib.x86_64
deleted file mode 100755 (executable)
index 39afb2d..0000000
Binary files a/test/dep_test/scripts/utillib.x86_64 and /dev/null differ
diff --git a/test/image_test.sh b/test/image_test.sh
new file mode 100644 (file)
index 0000000..7c57561
--- /dev/null
@@ -0,0 +1,79 @@
+#!/bin/bash
+
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+security_test_path="/opt/share/security-config/test"
+log_path="/opt/share/security-config/log"
+log_file="$log_path/image_test_log"
+
+# This script is running automatically at the time of image build.
+
+# Init log
+if [ -e "$log_file" ]
+then
+       rm $log_file
+fi
+
+# ASLR test
+aslr_test="$security_test_path/aslr_test/scripts/run_aslr_test.sh"
+aslr_log="$log_path/aslr_test.log"
+if [ -e  $aslr_test ]
+then
+       $aslr_test 1>/dev/null 2>/dev/null
+       if [ -e "$aslr_log" ]
+       then
+               echo "###### ASLR not applied list ######" >> $log_file
+               cat $aslr_log >> $log_file
+       fi
+fi
+
+# DEP test
+dep_test="$security_test_path/dep_test/scripts/run_dep_test.sh"
+dep_log="$log_path/dep_test.log"
+if [ -e  $dep_test ]
+then
+       $dep_test 1>/dev/null 2>/dev/null
+       if [ -e "$dep_log" ]
+       then
+               echo "###### DEP not applied list ######" >> $log_file
+               cat $dep_log >> $log_file
+       fi
+fi
+
+# SERVICE test
+service_test="$security_test_path/root_test/root_minimization.sh"
+failed_service_log="$log_path/root_test_failed_list.log"
+new_service_log="$log_path/root_test_new_root.log"
+if [ -e  $service_test ]
+then
+       $service_test 1>/dev/null 2>/dev/null
+       if [ -e "$failed_service_log" ]
+       then
+               echo "###### failed service list ######" >> $log_file
+               cat $failed_service_log >> $log_file
+       fi
+       if [ -e "$new_service_log" ]
+       then
+               echo "###### new service list ######" >> $log_file
+               cat $new_service_log >> $log_file 
+       fi
+fi
+
+# PATH test
+path_check_test="$security_test_path/path_check_test/path_check.sh"
+path_log="$log_path/path_check.log"
+if [ -e  $path_check_test ]
+then
+       $path_check_test 1>/dev/null 2>/dev/null
+       if [ -e "$path_log" ]
+       then
+               echo "###### path check error list ######" >> $log_file
+               cat $path_log >> $log_file
+       fi
+fi
+
+# Print the failed lists in build log
+if [ -e "$log_file" ]
+then
+       cat $log_file
+fi
+
index 2842340bf77422017f47eb8bda6511dbe9f84733..6e8e5f428f22e62e17100404eb1768244e056492 100644 (file)
@@ -26,8 +26,8 @@ LS="${BIN}/ls"
 #========================================================
 base_dir="/opt/share/security-config"
 utils_dir="$base_dir/test/utils"
-aslr_script_dir="$base_dir/test/aslr_test"
-dep_script_dir="$base_dir/test/dep_test"
+aslr_script_dir="$base_dir/test/aslr_test/scripts"
+dep_script_dir="$base_dir/test/dep_test/scripts"
 suid_script_dir="$base_dir/test/setuid_test"
 log_dir="$base_dir/log"
 result_dir="$base_dir/result"