From ef6deb037e875f21087501ad010597b7d795e173 Mon Sep 17 00:00:00 2001 From: Dirk Wetter Date: Mon, 21 Jan 2019 12:19:56 +0100 Subject: [PATCH] ~Empty files when scan problems encountered This commit addresses #934. It adds a line in the log/csv output and a json object named "scanProblem" when either the function fatal() is being called and it logs the reason of the fatal error. --- testssl.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/testssl.sh b/testssl.sh index 8dbd5b0..bd74d77 100755 --- a/testssl.sh +++ b/testssl.sh @@ -431,7 +431,7 @@ set_severity_level() { elif [[ "$severity" == CRITICAL ]]; then SEVERITY_LEVEL=$CRITICAL else - # WARN will always be logged + # WARN and FATAL will always be logged as the represent scanning problems echo "Supported severity levels are LOW, MEDIUM, HIGH, CRITICAL!" help 1 fi @@ -446,8 +446,9 @@ show_finding() { ( [[ "$severity" == LOW ]] && [[ $SEVERITY_LEVEL -le $LOW ]] ) || ( [[ "$severity" == MEDIUM ]] && [[ $SEVERITY_LEVEL -le $MEDIUM ]] ) || ( [[ "$severity" == HIGH ]] && [[ $SEVERITY_LEVEL -le $HIGH ]] ) || + ( [[ "$severity" == CRITICAL ]] && [[ $SEVERITY_LEVEL -le $CRITICAL ]] ) || ( [[ "$severity" == WARN ]] ) || - ( [[ "$severity" == CRITICAL ]] && [[ $SEVERITY_LEVEL -le $CRITICAL ]] ) + ( [[ "$severity" == FATAL ]] ) } ########### Output functions @@ -16252,8 +16253,12 @@ child_error() { fatal() { outln prln_magenta "Fatal error: $1" >&2 - [[ -n "$3" ]] && outln "$3" >&2 - fileout "fatal_error" "ERROR" "$1" + [[ -n "$LOGFILE" ]] && prln_magenta "Fatal error: $1" >>$LOGFILE + if [[ -n "$3" ]]; then + outln "$3" >&2 + [[ -n "$LOGFILE" ]] && outln "$3" >>$LOGFILE + fi + fileout "scanProblem" "FATAL" "$1" exit $2 }