mirror of
https://github.com/drwetter/testssl.sh.git
synced 2025-01-07 17:20:57 +01:00
Merge pull request #652 from dcooper16/html_headers_and_footers
Fix HTML headers and footers
This commit is contained in:
commit
939b6f0cb9
49
testssl.sh
49
testssl.sh
@ -160,6 +160,7 @@ LOGFILE=${LOGFILE:-""} # logfile if used
|
|||||||
JSONFILE=${JSONFILE:-""} # jsonfile if used
|
JSONFILE=${JSONFILE:-""} # jsonfile if used
|
||||||
CSVFILE=${CSVFILE:-""} # csvfile if used
|
CSVFILE=${CSVFILE:-""} # csvfile if used
|
||||||
HTMLFILE=${HTMLFILE:-""} # HTML if used
|
HTMLFILE=${HTMLFILE:-""} # HTML if used
|
||||||
|
HTMLHEADER=true # include HTML headers and footers in HTML file, if one is being created
|
||||||
APPEND=${APPEND:-false} # append to csv/json file instead of overwriting it
|
APPEND=${APPEND:-false} # append to csv/json file instead of overwriting it
|
||||||
GIVE_HINTS=false # give an addtional info to findings
|
GIVE_HINTS=false # give an addtional info to findings
|
||||||
HAS_IPv6=${HAS_IPv6:-false} # if you have OpenSSL with IPv6 support AND IPv6 networking set it to yes
|
HAS_IPv6=${HAS_IPv6:-false} # if you have OpenSSL with IPv6 support AND IPv6 networking set it to yes
|
||||||
@ -970,9 +971,30 @@ fileout() { # ID, SEVERITY, FINDING, CVE, CWE, HINT
|
|||||||
################### FILE FORMATING END #########################
|
################### FILE FORMATING END #########################
|
||||||
|
|
||||||
html_header() {
|
html_header() {
|
||||||
local fname_prefix="$1"
|
local fname_prefix
|
||||||
|
|
||||||
|
# Don't create HTML headers and footers in the following scenarios:
|
||||||
|
# * HTML output is not being created.
|
||||||
|
# * mass testing is being performed and each test will have its own HTML file.
|
||||||
|
# * this is an individual test within a mass test and all HTML output is being placed in a single file.
|
||||||
|
if ! "$do_html" || \
|
||||||
|
( "$do_mass_testing" && ( [[ -z "$HTMLFILE" ]] || [[ -d "$HTMLFILE" ]] ) ) || \
|
||||||
|
( "$APPEND" && [[ -n "$HTMLFILE" ]] && [[ ! -d "$HTMLFILE" ]] ); then
|
||||||
|
HTMLHEADER=false
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if "$do_display_only"; then
|
||||||
|
fname_prefix="local-ciphers"
|
||||||
|
elif "$do_mass_testing"; then
|
||||||
|
:
|
||||||
|
elif "$do_mx_all_ips"; then
|
||||||
|
fname_prefix="mx-$URI"
|
||||||
|
else
|
||||||
|
( [[ -z "$HTMLFILE" ]] || [[ -d "$HTMLFILE" ]] ) && parse_hn_port "${URI}" # NODE, URL_PATH, PORT, IPADDR and IP46ADDR is set now
|
||||||
|
fname_prefix="$NODE"_"$PORT"
|
||||||
|
fi
|
||||||
|
|
||||||
[[ -z "$fname_prefix" ]] && fname_prefix="$NODE"_"$PORT"
|
|
||||||
if [[ -n "$HTMLFILE" ]] && [[ ! -d "$HTMLFILE" ]]; then
|
if [[ -n "$HTMLFILE" ]] && [[ ! -d "$HTMLFILE" ]]; then
|
||||||
rm -f "$HTMLFILE"
|
rm -f "$HTMLFILE"
|
||||||
elif [[ -z "$HTMLFILE" ]]; then
|
elif [[ -z "$HTMLFILE" ]]; then
|
||||||
@ -994,16 +1016,20 @@ html_header() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
html_banner() {
|
html_banner() {
|
||||||
|
if "$APPEND" && "$HTMLHEADER"; then
|
||||||
html_out "## Scan started as: \"$PROG_NAME $CMDLINE\"\n"
|
html_out "## Scan started as: \"$PROG_NAME $CMDLINE\"\n"
|
||||||
html_out "## at $HNAME:$OPENSSL_LOCATION\n"
|
html_out "## at $HNAME:$OPENSSL_LOCATION\n"
|
||||||
html_out "## version testssl: $VERSION ${GIT_REL_SHORT:-$CVS_REL_SHORT} from $REL_DATE\n"
|
html_out "## version testssl: $VERSION ${GIT_REL_SHORT:-$CVS_REL_SHORT} from $REL_DATE\n"
|
||||||
html_out "## version openssl: \"$OSSL_VER\" from \"$OSSL_BUILD_DATE\")\n\n"
|
html_out "## version openssl: \"$OSSL_VER\" from \"$OSSL_BUILD_DATE\")\n\n"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
html_footer() {
|
html_footer() {
|
||||||
|
if "$HTMLHEADER"; then
|
||||||
html_out "</pre>\n"
|
html_out "</pre>\n"
|
||||||
html_out "</body>\n"
|
html_out "</body>\n"
|
||||||
html_out "</html>\n"
|
html_out "</html>\n"
|
||||||
|
fi
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -12519,12 +12545,10 @@ run_mass_testing_parallel() {
|
|||||||
run_mass_testing() {
|
run_mass_testing() {
|
||||||
local cmdline=""
|
local cmdline=""
|
||||||
local global_cmdline=${CMDLINE%%--file*}
|
local global_cmdline=${CMDLINE%%--file*}
|
||||||
local html_header=""
|
|
||||||
|
|
||||||
if [[ ! -r "$FNAME" ]] && "$IKNOW_FNAME"; then
|
if [[ ! -r "$FNAME" ]] && "$IKNOW_FNAME"; then
|
||||||
fatal "Can't read file \"$FNAME\"" "2"
|
fatal "Can't read file \"$FNAME\"" "2"
|
||||||
fi
|
fi
|
||||||
[[ -n "$HTMLFILE" ]] && [[ ! -d "$HTMLFILE" ]] && html_header="--no-html-header"
|
|
||||||
|
|
||||||
pr_reverse "====== Running in file batch mode with file=\"$FNAME\" ======"; outln "\n"
|
pr_reverse "====== Running in file batch mode with file=\"$FNAME\" ======"; outln "\n"
|
||||||
APPEND=false # Make sure we close out our files
|
APPEND=false # Make sure we close out our files
|
||||||
@ -12532,7 +12556,7 @@ run_mass_testing() {
|
|||||||
cmdline=$(filter_input "$cmdline")
|
cmdline=$(filter_input "$cmdline")
|
||||||
[[ -z "$cmdline" ]] && continue
|
[[ -z "$cmdline" ]] && continue
|
||||||
[[ "$cmdline" == "EOF" ]] && break
|
[[ "$cmdline" == "EOF" ]] && break
|
||||||
cmdline="$0 $global_cmdline --warnings=batch -q $html_header --append $cmdline"
|
cmdline="$0 $global_cmdline --warnings=batch -q --append $cmdline"
|
||||||
draw_line "=" $((TERM_WIDTH / 2)); outln;
|
draw_line "=" $((TERM_WIDTH / 2)); outln;
|
||||||
outln "$cmdline"
|
outln "$cmdline"
|
||||||
$cmdline
|
$cmdline
|
||||||
@ -13144,20 +13168,7 @@ lets_roll() {
|
|||||||
|
|
||||||
initialize_globals
|
initialize_globals
|
||||||
parse_cmd_line "$@"
|
parse_cmd_line "$@"
|
||||||
|
html_header
|
||||||
if ( ! "$do_mass_testing" || ( [[ -n "$HTMLFILE" ]] && [[ ! -d "$HTMLFILE" ]] ) ); then
|
|
||||||
if "$do_display_only"; then
|
|
||||||
html_header "local-ciphers"
|
|
||||||
elif "$do_mass_testing"; then
|
|
||||||
html_header
|
|
||||||
elif "$do_mx_all_ips"; then
|
|
||||||
html_header "mx-$URI"
|
|
||||||
else
|
|
||||||
( [[ -z "$HTMLFILE" ]] || [[ -d "$HTMLFILE" ]] ) && parse_hn_port "${URI}" # NODE, URL_PATH, PORT, IPADDR and IP46ADDR is set now
|
|
||||||
html_header
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
get_install_dir
|
get_install_dir
|
||||||
set_color_functions
|
set_color_functions
|
||||||
maketempf
|
maketempf
|
||||||
|
Loading…
Reference in New Issue
Block a user