From 708cc672a208ab20b74ab25a95fd5ebc62cf5be8 Mon Sep 17 00:00:00 2001 From: David Cooper Date: Mon, 29 Nov 2021 14:36:29 -0500 Subject: [PATCH] Fix #2049 This commit fixes #2049 by converting newline characters to spaces in JSON and CSV findings. fileout() calls newline_to_spaces() on the $findings that are to be written to JSON and CSV files. However, this only affects actual newline characters in the string, not escaped newline characters (i.e., "\n"). Escaped newline characters pass through this function unchanged, but then get converted to newline characters when they are written to the JSON and/or CSV files. This commit fixes the problem by also converting escaped newline characters ("\n") to spaces. --- testssl.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/testssl.sh b/testssl.sh index 2d544c6..7542761 100755 --- a/testssl.sh +++ b/testssl.sh @@ -1331,6 +1331,7 @@ fileout() { if ( "$do_pretty_json" && [[ "$1" == service ]] ) || show_finding "$severity"; then local finding=$(strip_lf "$(newline_to_spaces "$(strip_quote "$3")")") # additional quotes will mess up screen output + finding="${finding//\\n/ }" [[ -e "$JSONFILE" ]] && [[ ! -d "$JSONFILE" ]] && fileout_json_finding "$1" "$severity" "$finding" "$cve" "$cwe" "$hint" "$do_csv" && [[ -n "$CSVFILE" ]] && [[ ! -d "$CSVFILE" ]] && \ fileout_csv_finding "$1" "$NODE/$NODEIP" "$PORT" "$severity" "$finding" "$cve" "$cwe" "$hint"