mirror of
https://github.com/drwetter/testssl.sh.git
synced 2025-01-07 17:20:57 +01:00
Need to deal with the comma correctly if we are appending to a file
This commit is contained in:
parent
701545dbb6
commit
3b1d8b6253
11
testssl.sh
11
testssl.sh
@ -455,7 +455,11 @@ strip_quote() {
|
|||||||
|
|
||||||
fileout_header() {
|
fileout_header() {
|
||||||
if [[ $APPEND ]]; then
|
if [[ $APPEND ]]; then
|
||||||
"$do_json" && [[ ! -f "$JSONFILE" ]] && printf "[\n" > "$JSONFILE"
|
if [[ -f "$JSONFILE" ]]; then
|
||||||
|
FIRST_FINDING=false # We need to insert a comma, because there is file content already
|
||||||
|
else
|
||||||
|
"$do_json" && printf "[\n" > "$JSONFILE"
|
||||||
|
fi
|
||||||
"$do_csv" && [[ ! -f "CSVFILE" ]] && echo "\"id\",\"fqdn/ip\",\"port\",\"severity\",\"finding\"" > "$CSVFILE"
|
"$do_csv" && [[ ! -f "CSVFILE" ]] && echo "\"id\",\"fqdn/ip\",\"port\",\"severity\",\"finding\"" > "$CSVFILE"
|
||||||
else
|
else
|
||||||
"$do_json" && printf "[\n" > "$JSONFILE"
|
"$do_json" && printf "[\n" > "$JSONFILE"
|
||||||
@ -471,9 +475,8 @@ fileout() { # ID, SEVERITY, FINDING
|
|||||||
local finding=$(strip_lf "$(newline_to_spaces "$(strip_quote "$3")")")
|
local finding=$(strip_lf "$(newline_to_spaces "$(strip_quote "$3")")")
|
||||||
|
|
||||||
if "$do_json"; then
|
if "$do_json"; then
|
||||||
"$FIRST_FINDING" || echo "," >> $JSONFILE
|
"$FIRST_FINDING" || echo -n "," >> $JSONFILE
|
||||||
echo -e "
|
echo -e " {
|
||||||
{
|
|
||||||
\"id\" : \"$1\",
|
\"id\" : \"$1\",
|
||||||
\"ip\" : \"$NODE/$NODEIP\",
|
\"ip\" : \"$NODE/$NODEIP\",
|
||||||
\"port\" : \"$PORT\",
|
\"port\" : \"$PORT\",
|
||||||
|
Loading…
Reference in New Issue
Block a user