Skip to content

Commit 44a60ff

Browse files
committed
Improve banner (3.0)
... for readablity and bugs to be filed (see #2506) This PR defines a short string for the OpenSSL banner as some suppliers have makde them (unnecessarily) long so that it won't fit in the banner. The banner also now omits the built line nad bash version when scanning as for the user it is normally not important.
1 parent 6d714d6 commit 44a60ff

1 file changed

Lines changed: 38 additions & 13 deletions

File tree

testssl.sh

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ OSSL_VER="" # openssl version, will be auto-determin
332332
OSSL_VER_MAJOR=0
333333
OSSL_VER_MINOR=0
334334
OSSL_VER_APPENDIX="none"
335+
OSSL_SHORT_STR="" # short string for banner
335336
CLIENT_PROB_NO=1
336337
HAS_DH_BITS=${HAS_DH_BITS:-false} # initialize openssl variables
337338
HAS_CURVES=false
@@ -17114,7 +17115,7 @@ test_openssl_suffix() {
1711417115
find_openssl_binary() {
1711517116
local s_client_has=$TEMPDIR/s_client_has.txt
1711617117
local s_client_starttls_has=$TEMPDIR/s_client_starttls_has.txt
17117-
local openssl_location cwd=""
17118+
local openssl_location cwd="" yr=1
1711817119
local ossl_wo_dev_info
1711917120
local curve
1712017121
local -a curves_ossl=("sect163k1" "sect163r1" "sect163r2" "sect193r1" "sect193r2" "sect233k1" "sect233r1" "sect239k1" "sect283k1" "sect283r1" "sect409k1" "sect409r1" "sect571k1" "sect571r1" "secp160k1" "secp160r1" "secp160r2" "secp192k1" "prime192v1" "secp224k1" "secp224r1" "secp256k1" "prime256v1" "secp384r1" "secp521r1" "brainpoolP256r1" "brainpoolP384r1" "brainpoolP512r1" "X25519" "X448")
@@ -17163,6 +17164,21 @@ find_openssl_binary() {
1716317164
OSSL_VER_PLATFORM=$($OPENSSL version -p 2>/dev/null | sed 's/^platform: //')
1716417165
OSSL_BUILD_DATE=$($OPENSSL version -a 2>/dev/null | grep '^built' | sed -e 's/built on//' -e 's/: ... //' -e 's/: //' -e 's/ UTC//' -e 's/ +0000//' -e 's/.000000000//')
1716517166

17167+
# Determine an OpenSSL short string for the banner
17168+
# E.g MacOS' homebrew and Debian add a library string: OpenSSL 3.3.1 4 Jun 2024 (Library: OpenSSL 3.3.1 4 Jun 2024),
17169+
# so we omit the part after the round bracket as it breaks formatting and doesnt provide more useful info
17170+
OSSL_SHORT_STR=$($OPENSSL version 2>/dev/null)
17171+
OSSL_SHORT_STR=${OSSL_SHORT_STR%\(*}
17172+
# Now handle strings like this: OpenSSL 1.1.1l-fips 24 Aug 2021 SUSE release 150500.17.34.1
17173+
# we find the year, remove until first occurence, readd it
17174+
for yr in {2014..2029} ; do
17175+
if [[ $OSSL_SHORT_STR =~ \ $yr ]] ; then
17176+
OSSL_SHORT_STR=${OSSL_SHORT_STR%%$yr*}
17177+
OSSL_SHORT_STR="${OSSL_SHORT_STR}${yr}"
17178+
break
17179+
fi
17180+
done
17181+
1716617182
# see #190, reverting logic: unless otherwise proved openssl has no dh bits
1716717183
case "$OSSL_VER_MAJOR.$OSSL_VER_MINOR" in
1716817184
1.0.2|1.1.0|1.1.1|3*) HAS_DH_BITS=true ;;
@@ -17719,45 +17735,53 @@ prepare_arrays() {
1771917735

1772017736
mybanner() {
1772117737
local bb1 bb2 bb3
17738+
local spaces=" "
17739+
local full="$1"
1772217740

1772317741
"$QUIET" && return
1772417742
"$CHILD_MASS_TESTING" && return
1772517743
OPENSSL_NR_CIPHERS=$(count_ciphers "$(actually_supported_osslciphers 'ALL:COMPLEMENTOFALL:@STRENGTH' 'ALL')")
1772617744
bb1=$(cat <<EOF
1772717745

1772817746
#####################################################################
17729-
$PROG_NAME version $VERSION from
1773017747
EOF
1773117748
)
17732-
bb2=$(cat <<EOF
17749+
bb2=$(cat <<EOF
1773317750

1773417751
This program is free software. Distribution and modification under
1773517752
GPLv2 permitted. USAGE w/o ANY WARRANTY. USE IT AT YOUR OWN RISK!
1773617753

17737-
Please file bugs @
1773817754
EOF
1773917755
)
17740-
bb3=$(cat <<EOF
17756+
bb3=$(cat <<EOF
1774117757

1774217758
#####################################################################
1774317759
EOF
1774417760
)
17745-
pr_bold "$bb1 "
17761+
prln_bold "$bb1"; out "$spaces" ; pr_bold "$PROG_NAME"; out " version " ; pr_bold "$VERSION" ; out " from "
1774617762
pr_boldurl "$SWURL"; outln
1774717763
if [[ -n "$GIT_REL" ]]; then
17748-
pr_bold " ("
17764+
out "$spaces"
17765+
pr_bold "("
1774917766
pr_litegrey "$GIT_REL"
1775017767
prln_bold ")"
1775117768
fi
17752-
pr_bold "$bb2 "
17769+
prln_bold "$bb2"
17770+
out "\n${spaces}" ; out "Please file bugs @ "
1775317771
pr_boldurl "https://testssl.sh/bugs/"; outln
1775417772
pr_bold "$bb3"
1775517773
outln "\n"
17756-
out " Using "; pr_italic "bash ${BASH_VERSINFO[0]}.${BASH_VERSINFO[1]}.${BASH_VERSINFO[2]}"; out ". "
17757-
pr_italic "$($OPENSSL version 2>/dev/null)"; outln " [~$OPENSSL_NR_CIPHERS ciphers]"
17758-
out " on $HNAME:"
17774+
out "${spaces}Using "
17775+
pr_italic "$OSSL_SHORT_STR"
17776+
outln " [~$OPENSSL_NR_CIPHERS ciphers]"
17777+
out "${spaces}on $HNAME:"
1775917778
outln "$OPENSSL_LOCATION"
17760-
out " (built: "; pr_italic "$OSSL_BUILD_DATE"; out ", platform: "; pr_italic "$OSSL_VER_PLATFORM"; outln ")"
17779+
if [[ -n $full ]] || [[ $DEBUG -ge 1 ]]; then
17780+
out "${spaces}built: "; pr_italic "$OSSL_BUILD_DATE"; out ", platform: "; prln_italic "$OSSL_VER_PLATFORM"
17781+
out "${spaces}Using "
17782+
pr_italic "bash ${BASH_VERSINFO[0]}.${BASH_VERSINFO[1]}.${BASH_VERSINFO[2]}"
17783+
fi
17784+
outln
1776117785
}
1776217786

1776317787
calc_scantime() {
@@ -19698,7 +19722,8 @@ parse_cmd_line() {
1969819722
get_install_dir
1969919723
find_openssl_binary
1970019724
prepare_debug
19701-
mybanner
19725+
# full banner
19726+
mybanner true
1970219727
exit $ALLOK
1970319728
;;
1970419729
esac

0 commit comments

Comments
 (0)