Allow strict code checking for developers

This commit is contained in:
Michael Boelen 2016-07-28 11:39:10 +02:00
parent db5d825701
commit af999d3207
5 changed files with 27 additions and 9 deletions

View File

@ -4,4 +4,5 @@
debug=yes
developer-mode=yes
quick=yes
strict=yes
verbose=yes

View File

@ -58,6 +58,7 @@ unset LANG
BINARY_SCAN_FINISHED=0
CHECK=0
CHECK_BINARIES=1
CHECK_OPTION_ARRAY=""
CHKROOTKITBINARY=""
CHKCONFIGBINARY=""
COLORS=1
@ -80,6 +81,7 @@ unset LANG
DEVELOPER_MODE=0
DISCOVERED_BINARIES=""
DOCKER_DAEMON_RUNNING=0
ECHOCMD=""
ERROR_ON_WARNINGS=0
FILEVALUE=""
FIND=""
@ -95,6 +97,7 @@ unset LANG
HOSTID=""
IDS_IPS_TOOL_FOUND=0
IPTABLESBINARY=""
LDAP_CLIENT_CONFIG_FILE=""
LINUX_VERSION=""
LINUXCONFIGFILE=""
LMDBINARY=""
@ -149,6 +152,7 @@ unset LANG
PLUGIN_PHASE=0
POSTGRES_RUNNING=0
PRIVILEGED=0
PROFILES=""
PROFILEVALUE=""
PSBINARY="ps"
REDIS_RUNNING=0
@ -164,6 +168,7 @@ unset LANG
SERVICE_MANAGER=""
SETTINGS=""
SETTINGS_FILE=""
SET_STRICT=0
SHELL_IS_BUSYBOX=0
SHOW_PROGRAM_DETAILS=1
SHOW_REPORT=1

View File

@ -122,8 +122,7 @@
SHOW_TOOL_TIPS=0
QUIET=1
SHOW_PROGRAM_DETAILS=0
shift
HELPER_PARAMS="$1 $2"
shift; HELPER_PARAMS="$@"
break
;;

View File

@ -254,6 +254,12 @@
AddSetting "skip-upgrade-test" "${SKIP_UPGRADE_TEST}" "Skip upgrade test"
;;
# Set strict mode for development and quality purposes
strict)
FIND=`echo "${VALUE}" | egrep "^(1|true|yes)"` && SET_STRICT=1
AddSetting "strict" "${SET_STRICT}" "Perform strict test of scripts"
;;
# Define what kind of scan we are performing
test_scan_mode | test-scan-mode)
if [ "${VALUE}" = "light" ]; then SCAN_TEST_LIGHT="YES"; SCAN_TEST_MEDIUM="NO"; SCAN_TEST_HEAVY="NO"; fi

21
lynis
View File

@ -50,7 +50,12 @@
REPORT_version_major="1"; REPORT_version_minor="0"
REPORT_version="${REPORT_version_major}.${REPORT_version_minor}"
DISPLAY_LANG=$LANG # required by function Display to deal with multi-bytes characters.
DISPLAY_LANG="${LANG}" # required by function Display to deal with multi-bytes characters.
# Code quality:
# Set strict checking for development version for first part of code. After
# initialization this is checked with strict profile option.
if [ ${PROGRAM_RELEASE_TYPE} = "dev" ]; then set -u; fi
#
#################################################################################
@ -192,7 +197,6 @@ Make sure to execute ${PROGRAM_NAME} from untarred directory or check your insta
# Now include files if permissions are correct, or user decided to continue
. ${INCLUDEDIR}/consts
. ${INCLUDEDIR}/functions
#
#################################################################################
#
@ -204,10 +208,6 @@ Make sure to execute ${PROGRAM_NAME} from untarred directory or check your insta
# Use safe umask for the files we create
umask 027
# Drop out on unintialised variables / fatal errors
#set -u
#
#
#################################################################################
#
@ -518,12 +518,19 @@ ${NORMAL}
#
#################################################################################
#
# Read profile/language
# Read profile, set code checks, define language
#
#################################################################################
#
ParseProfiles
# Define if we keep working in strict mode (development)
if [ ${SET_STRICT} -eq 0 ]; then
set +u # Allow uninitialized variables
else
set -u # Do not allow unitialized variables
fi
# Import a different language when configured
if [ ! "${LANGUAGE}" = "en" ]; then
LogText "Language is set to ${LANGUAGE}"