From 4e39bafd7850cffc9905a1acd897b6309feadc59 Mon Sep 17 00:00:00 2001 From: Michael Boelen Date: Wed, 21 Aug 2019 14:50:32 +0200 Subject: [PATCH] New function to display exceptions --- include/functions | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/include/functions b/include/functions index 816d0cd1..9719b0ae 100644 --- a/include/functions +++ b/include/functions @@ -40,6 +40,7 @@ # DiscoverProfiles Determine available profiles on system # Display Output text to screen with colors and identation # DisplayError Show an error on screen +# DisplayException Show an exception on screen # DisplayManual Output text to screen without any layout # DisplayToolTip Show a tip for improving usage of the tool # DisplayWarning Show a clear warning on screen @@ -656,6 +657,40 @@ } + ################################################################################ + # Name : DisplayException() + # Description : Show a discovered exception on screen + # + # Parameters : $1 = function or test + # $2 = text + # Returns : + # Note : This function is usually triggered by ReportException + ################################################################################ + + DisplayException() { + ${ECHOCMD:-echo} "" + ${ECHOCMD:-echo} "=================================================================" + ${ECHOCMD:-echo} "" + ${ECHOCMD:-echo} " ${WARNING}Exception found!${NORMAL}" + ${ECHOCMD:-echo} "" + ${ECHOCMD:-echo} " Function/test: [$1]" + ${ECHOCMD:-echo} " Message: ${BOLD}$2${NORMAL}" + ${ECHOCMD:-echo} "" + ${ECHOCMD:-echo} " Help improving the Lynis community with your feedback!" + ${ECHOCMD:-echo} "" + ${ECHOCMD:-echo} " Steps:" + ${ECHOCMD:-echo} " - Ensure you are running the latest version ($0 update check)" + ${ECHOCMD:-echo} " - If so, create a GitHub issue at ${PROGRAM_SOURCE}" + ${ECHOCMD:-echo} " - Include relevant parts of the log file or configuration file" + ${ECHOCMD:-echo} "" + ${ECHOCMD:-echo} " Thanks!" + ${ECHOCMD:-echo} "" + ${ECHOCMD:-echo} "=================================================================" + ${ECHOCMD:-echo} "" + sleep 5 + } + + ################################################################################ # Name : DisplayManual() # Description : Show text on screen, without any markup @@ -1429,7 +1464,7 @@ ################################################################################ IsDeveloperVersion() { - if [ "${PROGRAM_RELEASE_TYPE}" = "dev" ]; then return 0; else return 1; fi + if [ "${PROGRAM_RELEASE_TYPE}" = "pre-release" ]; then return 0; else return 1; fi } @@ -2764,6 +2799,9 @@ ReportException() { Report "exception_event[]=$1|${2-NoInfo}|" LogText "Exception: test has an exceptional event ($1) with text ${2-NoText}" + if [ ${QUIET} -eq 0 ]; then + DisplayException "$1" "$2" + fi }