Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/CISOfy/lynis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Boelen <michael.boelen@cisofy.com>2016-07-28 12:39:10 +0300
committerMichael Boelen <michael.boelen@cisofy.com>2016-07-28 12:39:10 +0300
commitaf999d3207bf5f4490b31d82a9e732d7b3410ab9 (patch)
tree99a577c0dc982619ed9451fade05c0651873d92c
parentdb5d825701198c9e487b50ca05ec680d83176c94 (diff)
Allow strict code checking for developers
-rw-r--r--developer.prf1
-rw-r--r--include/consts5
-rw-r--r--include/parameters3
-rw-r--r--include/profiles6
-rwxr-xr-xlynis21
5 files changed, 27 insertions, 9 deletions
diff --git a/developer.prf b/developer.prf
index 17e87eeb..856596a8 100644
--- a/developer.prf
+++ b/developer.prf
@@ -4,4 +4,5 @@
debug=yes
developer-mode=yes
quick=yes
+strict=yes
verbose=yes
diff --git a/include/consts b/include/consts
index 19223a60..6cf9e4bc 100644
--- a/include/consts
+++ b/include/consts
@@ -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
diff --git a/include/parameters b/include/parameters
index 219528fa..9f193c62 100644
--- a/include/parameters
+++ b/include/parameters
@@ -122,8 +122,7 @@
SHOW_TOOL_TIPS=0
QUIET=1
SHOW_PROGRAM_DETAILS=0
- shift
- HELPER_PARAMS="$1 $2"
+ shift; HELPER_PARAMS="$@"
break
;;
diff --git a/include/profiles b/include/profiles
index 5130397b..f5c94370 100644
--- a/include/profiles
+++ b/include/profiles
@@ -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
diff --git a/lynis b/lynis
index 2cfcbdf5..567d93a2 100755
--- a/lynis
+++ b/lynis
@@ -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}"