~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.
This commit is contained in:
Dirk Wetter 2019-01-21 12:19:56 +01:00
parent 7ffd46447a
commit ef6deb037e

View File

@ -431,7 +431,7 @@ set_severity_level() {
elif [[ "$severity" == CRITICAL ]]; then elif [[ "$severity" == CRITICAL ]]; then
SEVERITY_LEVEL=$CRITICAL SEVERITY_LEVEL=$CRITICAL
else 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!" echo "Supported severity levels are LOW, MEDIUM, HIGH, CRITICAL!"
help 1 help 1
fi fi
@ -446,8 +446,9 @@ show_finding() {
( [[ "$severity" == LOW ]] && [[ $SEVERITY_LEVEL -le $LOW ]] ) || ( [[ "$severity" == LOW ]] && [[ $SEVERITY_LEVEL -le $LOW ]] ) ||
( [[ "$severity" == MEDIUM ]] && [[ $SEVERITY_LEVEL -le $MEDIUM ]] ) || ( [[ "$severity" == MEDIUM ]] && [[ $SEVERITY_LEVEL -le $MEDIUM ]] ) ||
( [[ "$severity" == HIGH ]] && [[ $SEVERITY_LEVEL -le $HIGH ]] ) || ( [[ "$severity" == HIGH ]] && [[ $SEVERITY_LEVEL -le $HIGH ]] ) ||
( [[ "$severity" == CRITICAL ]] && [[ $SEVERITY_LEVEL -le $CRITICAL ]] ) ||
( [[ "$severity" == WARN ]] ) || ( [[ "$severity" == WARN ]] ) ||
( [[ "$severity" == CRITICAL ]] && [[ $SEVERITY_LEVEL -le $CRITICAL ]] ) ( [[ "$severity" == FATAL ]] )
} }
########### Output functions ########### Output functions
@ -16252,8 +16253,12 @@ child_error() {
fatal() { fatal() {
outln outln
prln_magenta "Fatal error: $1" >&2 prln_magenta "Fatal error: $1" >&2
[[ -n "$3" ]] && outln "$3" >&2 [[ -n "$LOGFILE" ]] && prln_magenta "Fatal error: $1" >>$LOGFILE
fileout "fatal_error" "ERROR" "$1" if [[ -n "$3" ]]; then
outln "$3" >&2
[[ -n "$LOGFILE" ]] && outln "$3" >>$LOGFILE
fi
fileout "scanProblem" "FATAL" "$1"
exit $2 exit $2
} }