From 8b5b8b4a0129b0b317ba8a476566dcc55e4e025f Mon Sep 17 00:00:00 2001 From: mboelen Date: Thu, 24 Sep 2015 20:26:32 +0200 Subject: [PATCH] Added new parameters to ReportSuggestion and ReportWarning functions --- include/functions | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/include/functions b/include/functions index dac54cc2..a2cc73d8 100644 --- a/include/functions +++ b/include/functions @@ -1240,26 +1240,49 @@ ReportSuggestion() { TOTAL_SUGGESTIONS=`expr ${TOTAL_SUGGESTIONS} + 1` - # 2 parameters - # - report "suggestion[]=$1|$2|" - logtext "Suggestion: $2 [$1]" + # 4 parameters + #
+ # Lynis ID (use CUST-.... for your own tests) + # Suggestion text to be displayed + #
Specific item or details + # 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 # 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: + #
+ # + # Lynis ID (use CUST-.... for your own tests) + # Warning text to be displayed + #
Specific item or details + # 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 }