Added new parameters to ReportSuggestion and ReportWarning functions

This commit is contained in:
mboelen 2015-09-24 20:26:32 +02:00
parent 84821a4ed0
commit 8b5b8b4a01
1 changed files with 32 additions and 9 deletions

View File

@ -1240,26 +1240,49 @@
ReportSuggestion()
{
TOTAL_SUGGESTIONS=`expr ${TOTAL_SUGGESTIONS} + 1`
# 2 parameters
# <ID> <suggestion text>
report "suggestion[]=$1|$2|"
logtext "Suggestion: $2 [$1]"
# 4 parameters
# <ID> <Suggestion> <Details> <Solution>
# <ID> Lynis ID (use CUST-.... for your own tests)
# <Suggestion> Suggestion text to be displayed
# <Details> Specific item or details
# <Solution> Optional link for additional information:
# * url:http://site/link
# * text:Additional explanation
# * - for none
if [ "$1" = "" ]; then TEST="UNKNOWN"; else TEST="$1"; fi
if [ "$2" = "" ]; then MESSAGE="UNKNOWN"; else MESSAGE="$2"; fi
if [ "$3" = "" ]; then DETAILS="-"; else DETAILS="$3"; fi
if [ "$4" = "" ]; then SOLUTION="-"; else SOLUTION="$4"; fi
report "suggestion[]=${TEST}|${MESSAGE}|${DETAILS}|${SOLUTION}|"
logtext "Suggestion: ${MESSAGE} [test:$1] [details:${DETAILS}] [solution:${SOLUTION}]"
}
# Log warning to report file
ReportWarning()
{
TOTAL_WARNINGS=`expr ${TOTAL_WARNINGS} + 1`
# 3 parameters
# Old style
# <ID> <priority/impact> <warning text>
if [ "$2" = "L" -o "$2" = "M" -o "$2" = "H" ]; then
# old style warning
report "warning[]=$1|$3|"
logtext "Warning: $3 [$1]"
else
# new style warning
report "warning[]=$1|$2|"
logtext "Warning: $2 [test:$1]"
# New style warning format:
# <ID> <Warning> <Details> <Solution>
#
# <ID> Lynis ID (use CUST-.... for your own tests)
# <Warning> Warning text to be displayed
# <Details> Specific item or details
# <Solution> Optional link for additional information:
# * url:http://site/link
# * text:Additional explanation
# * - for none
if [ "$1" = "" ]; then TEST="UNKNOWN"; else TEST="$1"; fi
if [ "$2" = "" ]; then MESSAGE="UNKNOWN"; else MESSAGE="$2"; fi
if [ "$3" = "" ]; then DETAILS="-"; else DETAILS="$3"; fi
if [ "$4" = "" ]; then SOLUTION="-"; else SOLUTION="$4"; fi
report "warning[]=${TEST}|${MESSAGE}|${DETAILS}|${SOLUTION}|"
logtext "Warning: ${MESSAGE} [test:$1] [details:${DETAILS}] [solution:${SOLUTION}]"
fi
}