Skip to content

Commit 8392a4a

Browse files
committed
Squash some shellcheck *errors*
and some warnings. Five errors of type [SC2145](https://www.shellcheck.net/wiki/SC2145) are left as I am not sure whether it'll be safe to follow the recommendation
1 parent df100d9 commit 8392a4a

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

testssl.sh

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ declare -r ALLOK=0 # All is fine
8989

9090

9191
[ -z "${BASH_VERSINFO[0]}" ] && printf "\n\033[1;35m Please make sure you're using \"bash\"! Bye...\033[m\n\n" >&2 && exit $ERR_BASH
92-
[ $(kill -l | grep -c SIG) -eq 0 ] && printf "\n\033[1;35m Please make sure you're calling me without leading \"sh\"! Bye...\033[m\n\n" >&2 && exit $ERR_BASH
92+
kill -l | grep -q SIG || printf "\n\033[1;35m Please make sure you're calling me not as \"/bin/sh\"! Bye...\033[m\n\n" >&2 && exit $ERR_BASH
9393
[ ${BASH_VERSINFO[0]} -lt 3 ] && printf "\n\033[1;35m Minimum requirement is bash 3.2. You have $BASH_VERSION \033[m\n\n" >&2 && exit $ERR_BASH
9494
[ ${BASH_VERSINFO[0]} -le 3 ] && [ ${BASH_VERSINFO[1]} -le 1 ] && printf "\n\033[1;35m Minimum requirement is bash 3.2. You have $BASH_VERSION \033[m\n\n" >&2 && exit $ERR_BASH
9595

@@ -3638,7 +3638,7 @@ normalize_ciphercode() {
36383638

36393639
prettyprint_local() {
36403640
local arg line
3641-
local hexc hexcode dash ciph sslvers kx auth enc mac export
3641+
local hexc hexcode dash ciph sslvers kx auth enc mac exprt
36423642
local re='^[0-9A-Fa-f]+$'
36433643

36443644
if [[ "$1" == 0x* ]] || [[ "$1" == 0X* ]]; then
@@ -3658,19 +3658,19 @@ prettyprint_local() {
36583658
neat_header
36593659

36603660
if [[ -z "$1" ]]; then
3661-
while read -r hexcode dash ciph sslvers kx auth enc mac export ; do
3661+
while read -r hexcode dash ciph sslvers kx auth enc mac exprt ; do
36623662
hexc="$(normalize_ciphercode $hexcode)"
3663-
outln "$(neat_list "$hexc" "$ciph" "$kx" "$enc" "$export")"
3663+
outln "$(neat_list "$hexc" "$ciph" "$kx" "$enc" "$exprt")"
36643664
done < <(actually_supported_osslciphers 'ALL:COMPLEMENTOFALL:@STRENGTH' 'ALL' "-V") # -V doesn't work with openssl < 1.0
36653665
else
36663666
#for arg in $(echo $@ | sed 's/,/ /g'); do
36673667
for arg in ${*//,/ /}; do
3668-
while read -r hexcode dash ciph sslvers kx auth enc mac export ; do
3668+
while read -r hexcode dash ciph sslvers kx auth enc mac exprt ; do
36693669
hexc="$(normalize_ciphercode $hexcode)"
36703670
# for numbers we don't do word matching:
36713671
[[ $arg =~ $re ]] && \
3672-
line="$(neat_list "$hexc" "$ciph" "$kx" "$enc" "$export" | grep -ai "$arg")" || \
3673-
line="$(neat_list "$hexc" "$ciph" "$kx" "$enc" "$export" | grep -wai "$arg")"
3672+
line="$(neat_list "$hexc" "$ciph" "$kx" "$enc" "$exprt" | grep -ai "$arg")" || \
3673+
line="$(neat_list "$hexc" "$ciph" "$kx" "$enc" "$exprt" | grep -wai "$arg")"
36743674
[[ -n "$line" ]] && outln "$line"
36753675
done < <(actually_supported_osslciphers 'ALL:COMPLEMENTOFALL:@STRENGTH' 'ALL' "-V") # -V doesn't work with openssl < 1.0
36763676
done
@@ -3831,7 +3831,7 @@ neat_header(){
38313831

38323832
neat_list(){
38333833
local hexcode="$1"
3834-
local ossl_cipher="$2" export="$5" tls_cipher=""
3834+
local ossl_cipher="$2" exprt="$5" tls_cipher=""
38353835
local kx enc strength line what_dh bits
38363836
local -i i len
38373837
local how2show="$6"
@@ -3856,7 +3856,7 @@ neat_list(){
38563856
set_ciph_str_score $strength
38573857
fi
38583858

3859-
[[ "$export" =~ export ]] && strength="$strength,exp"
3859+
[[ "$exprt" =~ export ]] && strength="$strength,exp"
38603860

38613861
[[ "$DISPLAY_CIPHERNAMES" != openssl-only ]] && tls_cipher="$(show_rfc_style "$hexcode")"
38623862

@@ -10925,7 +10925,7 @@ run_fs() {
1092510925
local -i sclient_success
1092610926
local fs_offered=false ecdhe_offered=false ffdhe_offered=false
1092710927
local fs_tls13_offered=false fs_tls12_offered=false
10928-
local protos_to_try proto hexc dash fs_cipher sslvers auth mac export curve dhlen
10928+
local protos_to_try proto hexc dash fs_cipher sslvers auth mac exprt curve dhlen
1092910929
local -a hexcode normalized_hexcode ciph rfc_ciph kx enc ciphers_found sigalg ossl_supported
1093010930
# generated from 'kEECDH:kEDH:!aNULL:!eNULL:!DES:!3DES:!RC4' with openssl 1.0.2i and openssl 1.1.0
1093110931
local fs_cipher_list="DHE-DSS-AES128-GCM-SHA256:DHE-DSS-AES128-SHA256:DHE-DSS-AES128-SHA:DHE-DSS-AES256-GCM-SHA384:DHE-DSS-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-DSS-CAMELLIA128-SHA256:DHE-DSS-CAMELLIA128-SHA:DHE-DSS-CAMELLIA256-SHA256:DHE-DSS-CAMELLIA256-SHA:DHE-DSS-SEED-SHA:DHE-RSA-AES128-CCM8:DHE-RSA-AES128-CCM:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-CCM8:DHE-RSA-AES256-CCM:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-CAMELLIA128-SHA256:DHE-RSA-CAMELLIA128-SHA:DHE-RSA-CAMELLIA256-SHA256:DHE-RSA-CAMELLIA256-SHA:DHE-RSA-CHACHA20-POLY1305-OLD:DHE-RSA-CHACHA20-POLY1305:DHE-RSA-SEED-SHA:ECDHE-ECDSA-AES128-CCM8:ECDHE-ECDSA-AES128-CCM:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-ECDSA-AES256-CCM8:ECDHE-ECDSA-AES256-CCM:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-ECDSA-CAMELLIA128-SHA256:ECDHE-ECDSA-CAMELLIA256-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305-OLD:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-RSA-CAMELLIA128-SHA256:ECDHE-RSA-CAMELLIA256-SHA384:ECDHE-RSA-CHACHA20-POLY1305-OLD:ECDHE-RSA-CHACHA20-POLY1305"
@@ -10998,7 +10998,7 @@ run_fs() {
1099810998
fi
1099910999
done
1100011000
else
11001-
while read -r hexc dash ciph[nr_supported_ciphers] sslvers kx[nr_supported_ciphers] auth enc[nr_supported_ciphers] mac export; do
11001+
while read -r hexc dash ciph[nr_supported_ciphers] sslvers kx[nr_supported_ciphers] auth enc[nr_supported_ciphers] mac exprt; do
1100211002
ciphers_found[nr_supported_ciphers]=false
1100311003
if [[ "${hexc:2:2}" == 00 ]]; then
1100411004
normalized_hexcode[nr_supported_ciphers]="x${hexc:7:2}"
@@ -18360,9 +18360,9 @@ run_breach() {
1836018360

1836118361
# Final verdict (if not happened preemptively before). We reuse $detected_compression here
1836218362
detected_compression=""
18363-
if [[ ${has_compression[@]} =~ warn ]]; then
18363+
if [[ ${has_compression[*]} =~ warn ]]; then
1836418364
# warn_empty / warn_stalled
18365-
if [[ ${has_compression[@]} =~ warn_empty ]]; then
18365+
if [[ ${has_compression[*]} =~ warn_empty ]]; then
1836618366
pr_warning "At least 1/4 checks failed (HTTP header request was empty, debug: ${has_compression[@]}"
1836718367
outln ", debug: ${has_compression[@]})"
1836818368
fileout "$jsonID" "WARN" "Test failed as HTTP response was empty, debug: ${has_compression[@]}" "$cve" "$cwe"
@@ -19778,7 +19778,7 @@ run_winshock() {
1977819778
# Check whether there are any TLS extension which should not be available under <= Windows 2012 R2
1977919779
for tls_ext in "${TLS_EXTENSIONS[@]}"; do
1978019780
# We use the whole array, got to be careful when the array becomes bigger (unintended match)
19781-
if [[ ${forbidden_tls_ext[@]} =~ $tls_ext ]]; then
19781+
if [[ ${forbidden_tls_ext[*]} =~ $tls_ext ]]; then
1978219782
pr_svrty_best "not vulnerable (OK)"; outln " - TLS extension $tls_ext detected"
1978319783
fileout "$jsonID" "OK" "not vulnerable - TLS extension $tls_ext detected" "$cve" "$cwe"
1978419784
return 0
@@ -24671,7 +24671,7 @@ parse_cmd_line() {
2467124671
# then we need to make sure we catch --ids-friendly. Normally we do not,
2467224672
# see #1717. The following statement makes sure. In the do-while + case-esac
2467324673
# loop it will be execute again, but it does not hurt
24674-
if [[ "${CMDLINE_ARRAY[@]}" =~ --ids-friendly ]]; then
24674+
if [[ "${CMDLINE_ARRAY[*]}" =~ --ids-friendly ]]; then
2467524675
OFFENSIVE=false
2467624676
fi
2467724677
do_vulnerabilities=true
@@ -25204,7 +25204,7 @@ parse_cmd_line() {
2520425204

2520525205
# Unless explicit disabled, check if rating can or should be enabled.
2520625206
# Should be called after set_scanning_defaults() and set_skip_tests()
25207-
if [[ ! ${SKIP_TESTS[@]} =~ rating ]] ; then
25207+
if [[ ! ${SKIP_TESTS[*]} =~ rating ]] ; then
2520825208
set_rating_state
2520925209
fi
2521025210

0 commit comments

Comments
 (0)