From 073d383f76fed5b7fd3feb57866c0180b910c141 Mon Sep 17 00:00:00 2001 From: Dirk Wetter Date: Thu, 30 Jan 2020 21:49:56 +0100 Subject: [PATCH 1/2] Fix switch --ids-friendly This switch had no effect. There was probably a regression problem as it worked before. Besides fixing that the large case statement in parse_cmd_line() was simplified, in a sense that banner and help functions were moved to a separate case statement. --- testssl.sh | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/testssl.sh b/testssl.sh index f2977fd..1744dba 100755 --- a/testssl.sh +++ b/testssl.sh @@ -19364,24 +19364,25 @@ parse_cmd_line() { CMDLINE="$(create_cmd_line_string "${CMDLINE_ARRAY[@]}")" CMDLINE_PARSED=false - # Show usage if no options were specified - [[ -z "$1" ]] && help 0 - # Set defaults if only an URI was specified, maybe ToDo: use "="-option, then: ${i#*=} i.e. substring removal - [[ "$#" -eq 1 ]] && set_scanning_defaults + case $1 in + --help|"") + help 0 + ;; + -b|--banner|-v|--version) + maketempf + get_install_dir + find_openssl_binary + prepare_debug + mybanner + exit $ALLOK + ;; + esac + + # initializing + set_scanning_defaults while [[ $# -gt 0 ]]; do case $1 in - --help) - help 0 - ;; - -b|--banner|-v|--version) - maketempf - get_install_dir - find_openssl_binary - prepare_debug - mybanner - exit $ALLOK - ;; --mx) do_mx_all_ips=true PORT=25 @@ -19883,8 +19884,8 @@ parse_cmd_line() { done [[ "$DEBUG" -ge 5 ]] && debug_globals - # if we have no "do_*" set here --> query_globals: we do a standard run -- otherwise just the one specified - query_globals && set_scanning_defaults + set_scanning_defaults + query_globals CMDLINE_PARSED=true } From c4920f61e45546497d82a08090913775c7e44ce3 Mon Sep 17 00:00:00 2001 From: Dirk Wetter Date: Thu, 30 Jan 2020 22:25:10 +0100 Subject: [PATCH 2/2] rename query_globals() --> count_do_variables() .. and fix one problem instroduced with last patch (testssl.sh din't work correclty if only an URI was supplied) --- testssl.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/testssl.sh b/testssl.sh index 1744dba..215d8de 100755 --- a/testssl.sh +++ b/testssl.sh @@ -19280,7 +19280,7 @@ set_scanning_defaults() { } # returns number of $do variables set = number of run_funcs() to perform -query_globals() { +count_do_variables() { local gbl local true_nr=0 @@ -19379,7 +19379,7 @@ parse_cmd_line() { esac # initializing - set_scanning_defaults + initialize_globals while [[ $# -gt 0 ]]; do case $1 in @@ -19884,8 +19884,9 @@ parse_cmd_line() { done [[ "$DEBUG" -ge 5 ]] && debug_globals - set_scanning_defaults - query_globals + + count_do_variables + [[ $? -eq 0 ]] && set_scanning_defaults CMDLINE_PARSED=true } @@ -20128,9 +20129,10 @@ lets_roll() { #TODO: there shouldn't be the need for a special case for --mx, only the ip addresses we would need upfront and the do-parser if "$do_mx_all_ips"; then - query_globals # if we have just 1x "do_*" --> we do a standard run -- otherwise just the one specified + #FIXME: do we need this really here? + count_do_variables # if we have just 1x "do_*" --> we do a standard run -- otherwise just the one specified [[ $? -eq 1 ]] && set_scanning_defaults - run_mx_all_ips "${URI}" $PORT # we should reduce run_mx_all_ips to the stuff necessary as ~15 lines later we have similar code + run_mx_all_ips "${URI}" $PORT # we should reduce run_mx_all_ips to what's necessary as below we have similar code exit $? fi