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>2019-07-07 19:49:01 +0300
committerMichael Boelen <michael.boelen@cisofy.com>2019-07-07 19:49:01 +0300
commit5217db95b15e992b4a18d40ff3daec6987a65af9 (patch)
treeb086baeda1d31a0502c75b9ae318d720a02097c6 /include/profiles
parent7a816ece8ab503e16250946712a95657155480a8 (diff)
Add deprecation message for old format and added check for unexpected/invalid characters in profile (additional security measure)
Diffstat (limited to 'include/profiles')
-rw-r--r--include/profiles33
1 files changed, 31 insertions, 2 deletions
diff --git a/include/profiles b/include/profiles
index 2840ed3b..101a8a77 100644
--- a/include/profiles
+++ b/include/profiles
@@ -32,8 +32,37 @@
for PROFILE in ${PROFILES}; do
LogText "Reading profile/configuration ${PROFILE}"
- FIND=$(egrep "^config:|^[a-z-].*=" ${PROFILE} | sed 's/ /!space!/g')
- for CONFIGOPTION in ${FIND}; do
+
+ # Show deprecation message for old config entries
+ FOUND=0
+ #DATA=$(egrep "^config:" ${PROFILE} | od --address-radix=none -t a | sed 's/ /!space!/g')
+ #if ! IsEmpty "${DATA}"; then FOUND=1; fi
+ # Items such as 'apache:'
+ DATA=$(egrep "^[a-z-]{1,}:" ${PROFILE} | od --address-radix=none -t a | sed 's/ /!space!/g')
+ if ! IsEmpty "${DATA}"; then FOUND=1; fi
+
+ if [ ${FOUND} -eq 1 ]; then
+ DisplayWarning "Your profile contains old-style configuration entries. See log file for more details and how to convert these entries"
+ LogText "Your profile has one or more configuration items that are in an old format (lines starting with key:value). They need to be converted into the new format (key=value)."
+ LogText "Tip: Use egrep to see the relevant matches (egrep \"^[a-z-]{1,}:\" custom.prf)"
+ sleep 30
+ fi
+
+ # Security check for unexpected and possibly harmful escape characters
+ DATA=$(grep -v '^$\|^ \|^#\|^config:' ${PROFILE} | tr -d '[:alnum:]/\[\]\(\)\-_\|,\.:;= \n\r' | od --address-radix=none -t a | sed 's/ /!space!/g')
+ if ! IsEmpty "${DATA}"; then
+ DisplayWarning "Your profile '${PROFILE}' contains unexpected characters. See the log file for more information."
+ LogText "Found unexpected or possibly harmful characters in the profile. See output below."
+ for I in "${DATA}"; do
+ I=$(echo ${I} | sed 's/!space!/ /g')
+ LogText "Output: ${I}"
+ done
+ sleep 30
+ fi
+
+ # Now parse the profile and filter out unwanted characters
+ DATA=$(egrep "^config:|^[a-z-].*=" ${PROFILE} | tr -dc '[:alnum:]/\[\]\(\)\-_\|,\.:;= \n\r' | sed 's/ /!space!/g')
+ for CONFIGOPTION in ${DATA}; do
if ContainsString "config:" "${CONFIGOPTION}"; then
# Old style configuration
OPTION=$(echo ${CONFIGOPTION} | cut -d ':' -f2)