mirror of
https://github.com/drwetter/testssl.sh.git
synced 2025-01-07 09:10:57 +01:00
Reset APPEND var if the file doesn't exist
...as otherwise it won't be created, fixes #1210.
This commit is contained in:
parent
a0d51611d2
commit
ee72e9deae
30
testssl.sh
30
testssl.sh
@ -927,7 +927,6 @@ json_header() {
|
|||||||
local filename_provided=false
|
local filename_provided=false
|
||||||
|
|
||||||
[[ -n "$JSONFILE" ]] && [[ ! -d "$JSONFILE" ]] && filename_provided=true
|
[[ -n "$JSONFILE" ]] && [[ ! -d "$JSONFILE" ]] && filename_provided=true
|
||||||
|
|
||||||
# Similar to HTML: Don't create headers and footers in the following scenarios:
|
# Similar to HTML: Don't create headers and footers in the following scenarios:
|
||||||
# * no JSON/CSV output is being created.
|
# * no JSON/CSV output is being created.
|
||||||
# * mass testing is being performed and each test will have its own file.
|
# * mass testing is being performed and each test will have its own file.
|
||||||
@ -943,8 +942,8 @@ json_header() {
|
|||||||
elif "$do_mx_all_ips"; then
|
elif "$do_mx_all_ips"; then
|
||||||
fname_prefix="${FNAME_PREFIX}mx-${URI}"
|
fname_prefix="${FNAME_PREFIX}mx-${URI}"
|
||||||
else
|
else
|
||||||
|
# ensure NODE, URL_PATH, PORT, IPADDR and IP46ADDR are set
|
||||||
! "$filename_provided" && [[ -z "$NODE" ]] && parse_hn_port "${URI}"
|
! "$filename_provided" && [[ -z "$NODE" ]] && parse_hn_port "${URI}"
|
||||||
# NODE, URL_PATH, PORT, IPADDR and IP46ADDR is set now --> wrong place
|
|
||||||
fname_prefix="${FNAME_PREFIX}${NODE}_p${PORT}"
|
fname_prefix="${FNAME_PREFIX}${NODE}_p${PORT}"
|
||||||
fi
|
fi
|
||||||
if [[ -z "$JSONFILE" ]]; then
|
if [[ -z "$JSONFILE" ]]; then
|
||||||
@ -952,6 +951,10 @@ json_header() {
|
|||||||
elif [[ -d "$JSONFILE" ]]; then
|
elif [[ -d "$JSONFILE" ]]; then
|
||||||
JSONFILE="$JSONFILE/${fname_prefix}-$(date +"%Y%m%d-%H%M".json)"
|
JSONFILE="$JSONFILE/${fname_prefix}-$(date +"%Y%m%d-%H%M".json)"
|
||||||
fi
|
fi
|
||||||
|
# Silently reset APPEND var if the file doesn't exist as otherwise it won't be created
|
||||||
|
if "$APPEND" && [[ ! -s "$JSONFILE" ]]; then
|
||||||
|
APPEND=false
|
||||||
|
fi
|
||||||
if "$APPEND"; then
|
if "$APPEND"; then
|
||||||
JSONHEADER=false
|
JSONHEADER=false
|
||||||
else
|
else
|
||||||
@ -959,7 +962,6 @@ json_header() {
|
|||||||
"$do_json" && echo "[" > "$JSONFILE"
|
"$do_json" && echo "[" > "$JSONFILE"
|
||||||
"$do_pretty_json" && echo "{" > "$JSONFILE"
|
"$do_pretty_json" && echo "{" > "$JSONFILE"
|
||||||
fi
|
fi
|
||||||
#FIRST_FINDING=false
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -969,8 +971,7 @@ csv_header() {
|
|||||||
local filename_provided=false
|
local filename_provided=false
|
||||||
|
|
||||||
[[ -n "$CSVFILE" ]] && [[ ! -d "$CSVFILE" ]] && filename_provided=true
|
[[ -n "$CSVFILE" ]] && [[ ! -d "$CSVFILE" ]] && filename_provided=true
|
||||||
|
# CSV similar to JSON
|
||||||
# CSV similar:
|
|
||||||
! "$do_csv" && CSVHEADER=false && return 0
|
! "$do_csv" && CSVHEADER=false && return 0
|
||||||
"$do_mass_testing" && ! "$filename_provided" && CSVHEADER=false && return 0
|
"$do_mass_testing" && ! "$filename_provided" && CSVHEADER=false && return 0
|
||||||
"$CHILD_MASS_TESTING" && "$filename_provided" && CSVHEADER=false && return 0
|
"$CHILD_MASS_TESTING" && "$filename_provided" && CSVHEADER=false && return 0
|
||||||
@ -980,18 +981,21 @@ csv_header() {
|
|||||||
elif "$do_mass_testing"; then
|
elif "$do_mass_testing"; then
|
||||||
:
|
:
|
||||||
elif "$do_mx_all_ips"; then
|
elif "$do_mx_all_ips"; then
|
||||||
fname_prefix="${FNAME_PREFIX}mx-$URI"
|
fname_prefix="${FNAME_PREFIX}mx-${URI}"
|
||||||
else
|
else
|
||||||
|
# ensure NODE, URL_PATH, PORT, IPADDR and IP46ADDR are set
|
||||||
! "$filename_provided" && [[ -z "$NODE" ]] && parse_hn_port "${URI}"
|
! "$filename_provided" && [[ -z "$NODE" ]] && parse_hn_port "${URI}"
|
||||||
# NODE, URL_PATH, PORT, IPADDR and IP46ADDR is set now --> wrong place
|
|
||||||
fname_prefix="${FNAME_PREFIX}${NODE}_p${PORT}"
|
fname_prefix="${FNAME_PREFIX}${NODE}_p${PORT}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$CSVFILE" ]]; then
|
if [[ -z "$CSVFILE" ]]; then
|
||||||
CSVFILE="${fname_prefix}-$(date +"%Y%m%d-%H%M".csv)"
|
CSVFILE="${fname_prefix}-$(date +"%Y%m%d-%H%M".csv)"
|
||||||
elif [[ -d "$CSVFILE" ]]; then
|
elif [[ -d "$CSVFILE" ]]; then
|
||||||
CSVFILE="$CSVFILE/${fname_prefix}-$(date +"%Y%m%d-%H%M".csv)"
|
CSVFILE="$CSVFILE/${fname_prefix}-$(date +"%Y%m%d-%H%M".csv)"
|
||||||
fi
|
fi
|
||||||
|
# Silently reset APPEND var if the file doesn't exist as otherwise it won't be created
|
||||||
|
if "$APPEND" && [[ ! -s "$CSVFILE" ]]; then
|
||||||
|
APPEND=false
|
||||||
|
fi
|
||||||
if "$APPEND"; then
|
if "$APPEND"; then
|
||||||
CSVHEADER=false
|
CSVHEADER=false
|
||||||
else
|
else
|
||||||
@ -1013,7 +1017,6 @@ html_header() {
|
|||||||
local filename_provided=false
|
local filename_provided=false
|
||||||
|
|
||||||
[[ -n "$HTMLFILE" ]] && [[ ! -d "$HTMLFILE" ]] && filename_provided=true
|
[[ -n "$HTMLFILE" ]] && [[ ! -d "$HTMLFILE" ]] && filename_provided=true
|
||||||
|
|
||||||
# Don't create HTML headers and footers in the following scenarios:
|
# Don't create HTML headers and footers in the following scenarios:
|
||||||
# * HTML output is not being created.
|
# * HTML output is not being created.
|
||||||
# * mass testing is being performed and each test will have its own HTML file.
|
# * mass testing is being performed and each test will have its own HTML file.
|
||||||
@ -1027,18 +1030,21 @@ html_header() {
|
|||||||
elif "$do_mass_testing"; then
|
elif "$do_mass_testing"; then
|
||||||
:
|
:
|
||||||
elif "$do_mx_all_ips"; then
|
elif "$do_mx_all_ips"; then
|
||||||
fname_prefix="${FNAME_PREFIX}mx-$URI"
|
fname_prefix="${FNAME_PREFIX}mx-${URI}"
|
||||||
else
|
else
|
||||||
|
# ensure NODE, URL_PATH, PORT, IPADDR and IP46ADDR are set
|
||||||
! "$filename_provided" && [[ -z "$NODE" ]] && parse_hn_port "${URI}"
|
! "$filename_provided" && [[ -z "$NODE" ]] && parse_hn_port "${URI}"
|
||||||
# NODE, URL_PATH, PORT, IPADDR and IP46ADDR is set now --> wrong place
|
|
||||||
fname_prefix="${FNAME_PREFIX}${NODE}_p${PORT}"
|
fname_prefix="${FNAME_PREFIX}${NODE}_p${PORT}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$HTMLFILE" ]]; then
|
if [[ -z "$HTMLFILE" ]]; then
|
||||||
HTMLFILE="$fname_prefix-$(date +"%Y%m%d-%H%M".html)"
|
HTMLFILE="$fname_prefix-$(date +"%Y%m%d-%H%M".html)"
|
||||||
elif [[ -d "$HTMLFILE" ]]; then
|
elif [[ -d "$HTMLFILE" ]]; then
|
||||||
HTMLFILE="$HTMLFILE/$fname_prefix-$(date +"%Y%m%d-%H%M".html)"
|
HTMLFILE="$HTMLFILE/$fname_prefix-$(date +"%Y%m%d-%H%M".html)"
|
||||||
fi
|
fi
|
||||||
|
# Silently reset APPEND var if the file doesn't exist as otherwise it won't be created
|
||||||
|
if "$APPEND" && [[ ! -s "$HTMLFILE" ]]; then
|
||||||
|
APPEND=false
|
||||||
|
fi
|
||||||
if "$APPEND"; then
|
if "$APPEND"; then
|
||||||
HTMLHEADER=false
|
HTMLHEADER=false
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user