From b2e4df60ca82c313a332418ba9be4a208fd24d83 Mon Sep 17 00:00:00 2001 From: Sietse van der Molen Date: Fri, 12 Feb 2016 11:05:36 +0100 Subject: [PATCH 1/2] fix json output use double quotes instead of single quotes delete newlines from strings --- testssl.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/testssl.sh b/testssl.sh index f61b88d..e3fc68b 100755 --- a/testssl.sh +++ b/testssl.sh @@ -457,14 +457,14 @@ fileout() { # ID, SEVERITY, FINDING if "$do_json"; then "$FIRST_FINDING" || echo "," >> $JSONFILE - finding=$(strip_quote "$3") + finding=$(newline_to_spaces "$(strip_quote "$3")") echo -e " { - 'id' : '$1', - 'ip' : '$NODE/$NODEIP', - 'port' : '$PORT', - 'severity' : '$2', - 'finding' : '$finding' + \"id\" : \"$1\", + \"ip\" : \"$NODE/$NODEIP\", + \"port\" : \"$PORT\", + \"severity\" : \"$2\", + \"finding\" : \"$finding\" }" >> $JSONFILE fi # does the following do any sanitization? From 394f1860008cd76480c15f19451d4803ebbd7fd0 Mon Sep 17 00:00:00 2001 From: Sietse van der Molen Date: Fri, 12 Feb 2016 12:40:31 +0100 Subject: [PATCH 2/2] also remove carriage returns, fix for csv --- testssl.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/testssl.sh b/testssl.sh index e3fc68b..6c487b2 100755 --- a/testssl.sh +++ b/testssl.sh @@ -453,11 +453,10 @@ fileout_footer() { } fileout() { # ID, SEVERITY, FINDING - local finding="$5" + local finding=$(strip_lf "$(newline_to_spaces "$(strip_quote "$3")")") if "$do_json"; then "$FIRST_FINDING" || echo "," >> $JSONFILE - finding=$(newline_to_spaces "$(strip_quote "$3")") echo -e " { \"id\" : \"$1\", @@ -469,7 +468,7 @@ fileout() { # ID, SEVERITY, FINDING fi # does the following do any sanitization? if "$do_csv"; then - echo -e \""$1\"",\"$NODE/$NODEIP\",\"$PORT"\",\""$2"\",\"$(strip_quote "$3")\"" >>$CSVFILE + echo -e \""$1\"",\"$NODE/$NODEIP\",\"$PORT"\",\""$2"\",\""$finding"\"" >>$CSVFILE fi "$FIRST_FINDING" && FIRST_FINDING=false }