Skip to content

Commit 3cd027e

Browse files
authored
Merge pull request #2551 from drwetter/banner
Improve banner (3.2)
2 parents e59a0f2 + dbb8fc8 commit 3cd027e

File tree

3 files changed

+50
-22
lines changed

3 files changed

+50
-22
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ assignees: ''
88
---
99
<!---
1010
11-
_Feel free to remove this line but please stick to the template. We would like to reproduce the bug and therefore need concise information. Depending on the completeness of your information provided we might close your issue otherwise right away. _
11+
_Feel free to remove this line but please stick to the template. We would like to reproduce the bug and therefore need concise information. Depending on the lack of information provided we might close your issue otherwise right away. _
1212
-->
1313

1414
**Before you open an issue please check which version you are running and whether it is the latest in stable / dev branch**
1515

16-
I am running version ( ``git log | head -1`` if running from the git repo. Otherwise ``testssl.sh -v | grep from``)
16+
I am running version (``git log | head -1`` if running from the git repo. Otherwise ``testssl.sh -v | grep from``)
1717

1818

1919
**Before you open an issue please whether this is a known problem by searching the issues**
2020

21-
Is related to / couldn't find anything
21+
Is related to / couldn't find anything
2222

2323

2424
**Command line / docker command to reproduce**
@@ -33,9 +33,8 @@ A clear and concise description of what you would expect to happen.
3333

3434
**Your system (please complete the following information):**
3535
- OS: ``awk -F\" '/PRETTY_NAME/ { print $2 }' /etc/os-release``
36-
- Platform: ``uname -srm``
37-
- OpenSSL: ``testssl.sh -b 2>/dev/null | grep Using '``
38-
- Bash: ``bash --version``
36+
- Platform: ``uname -srm``
37+
- OpenSSL + bash: ``testssl.sh -b 2>/dev/null | grep Using '``
3938

4039
**Additional context**
4140

t/32_isHTML_valid.t

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ $debughtml =~ s/ Pre-test: .*\n//g;
7575
$debughtml =~ s/.*OK: below 825 days.*\n//g;
7676
$debughtml =~ s/.*DEBUG:.*\n//g;
7777
$debughtml =~ s/No engine or GOST support via engine with your.*\n//g;
78+
$debughtml =~ s/.*built: .*\n//g;
79+
$debughtml =~ s/.*Using bash .*\n//g;
80+
# is whole line: s/.*<pattern> .*\n//g;
7881

7982
cmp_ok($debughtml, "eq", $html, "HTML file created with --debug 4 matches HTML file created without --debug");
8083
$tests++;

testssl.sh

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ OSSL_VER="" # openssl version, will be auto-determin
317317
OSSL_VER_MAJOR=0
318318
OSSL_VER_MINOR=0
319319
OSSL_VER_APPENDIX="none"
320+
OSSL_SHORT_STR="" # short string for banner
320321
CLIENT_PROB_NO=1
321322

322323
GOOD_CA_BUNDLE="" # A bundle of CA certificates that can be used to validate the server's certificate
@@ -20127,6 +20128,21 @@ find_openssl_binary() {
2012720128
OSSL_VER_PLATFORM=$($OPENSSL version -p 2>/dev/null | sed 's/^platform: //')
2012820129
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//')
2012920130

20131+
# Determine an OpenSSL short string for the banner
20132+
# 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),
20133+
# so we omit the part after the round bracket as it breaks formatting and doesn't provide more useful info
20134+
OSSL_SHORT_STR=$($OPENSSL version 2>/dev/null)
20135+
OSSL_SHORT_STR=${OSSL_SHORT_STR%\(*}
20136+
# Now handle strings like this: OpenSSL 1.1.1l-fips 24 Aug 2021 SUSE release 150500.17.34.1
20137+
# we find the year, remove until first occurrence, re-add it
20138+
for yr in {2014..2029} ; do
20139+
if [[ $OSSL_SHORT_STR =~ \ $yr ]] ; then
20140+
OSSL_SHORT_STR=${OSSL_SHORT_STR%%$yr*}
20141+
OSSL_SHORT_STR="${OSSL_SHORT_STR}${yr}"
20142+
break
20143+
fi
20144+
done
20145+
2013020146
# see #190, reverting logic: unless otherwise proved openssl has no dh bits
2013120147
case "$OSSL_VER_MAJOR.$OSSL_VER_MINOR" in
2013220148
1.0.2|1.1.0|1.1.1|3.*) HAS_DH_BITS=true ;;
@@ -20765,47 +20781,56 @@ prepare_arrays() {
2076520781

2076620782
mybanner() {
2076720783
local bb1 bb2 bb3
20784+
local spaces=" "
20785+
local full="$1"
2076820786

2076920787
"$QUIET" && return
2077020788
"$CHILD_MASS_TESTING" && return
2077120789
OPENSSL_NR_CIPHERS=$(count_ciphers "$(actually_supported_osslciphers 'ALL:COMPLEMENTOFALL:@STRENGTH' 'ALL')")
2077220790
bb1=$(cat <<EOF
2077320791

20774-
###########################################################
20775-
$PROG_NAME $VERSION from
20792+
#####################################################################
2077620793
EOF
2077720794
)
20778-
bb2=$(cat <<EOF
20795+
bb2=$(cat <<EOF
2077920796

20780-
This program is free software. Distribution and
20781-
modification under GPLv2 permitted.
20782-
USAGE w/o ANY WARRANTY. USE IT AT YOUR OWN RISK!
20797+
This program is free software. Distribution and modification under
20798+
GPLv2 permitted. USAGE w/o ANY WARRANTY. USE IT AT YOUR OWN RISK!
2078320799

20784-
Please file bugs @
2078520800
EOF
2078620801
)
20787-
bb3=$(cat <<EOF
20802+
bb3=$(cat <<EOF
2078820803

20789-
###########################################################
20804+
#####################################################################
2079020805
EOF
2079120806
)
20792-
pr_bold "$bb1 "
20807+
prln_bold "$bb1"; out "$spaces" ; pr_bold "$PROG_NAME"; out " version " ; pr_bold "$VERSION" ; out " from "
2079320808
pr_boldurl "$SWURL"; outln
2079420809
if [[ -n "$GIT_REL" ]]; then
20795-
pr_bold " ("
20810+
out "$spaces"
20811+
pr_bold "("
2079620812
pr_litegrey "$GIT_REL"
2079720813
prln_bold ")"
2079820814
fi
20799-
pr_bold "$bb2 "
20815+
prln_bold "$bb2"
20816+
out "\n${spaces}" ; out "Please file bugs @ "
2080020817
pr_boldurl "https://testssl.sh/bugs/"; outln
2080120818
pr_bold "$bb3"
2080220819
outln "\n"
20803-
outln " Using \"$($OPENSSL version 2>/dev/null)\" [~$OPENSSL_NR_CIPHERS ciphers]"
20804-
out " on $HNAME:"
20820+
out "${spaces}Using "
20821+
pr_italic "$OSSL_SHORT_STR"
20822+
outln " [~$OPENSSL_NR_CIPHERS ciphers]"
20823+
out "${spaces}on $HNAME:"
2080520824
outln "$OPENSSL_LOCATION"
20806-
outln " (built: \"$OSSL_BUILD_DATE\", platform: \"$OSSL_VER_PLATFORM\")\n"
20825+
if [[ -n $full ]] || [[ $DEBUG -ge 1 ]]; then
20826+
out "${spaces}built: "; pr_italic "$OSSL_BUILD_DATE"; out ", platform: "; prln_italic "$OSSL_VER_PLATFORM"
20827+
out "${spaces}Using "
20828+
pr_italic "bash ${BASH_VERSINFO[0]}.${BASH_VERSINFO[1]}.${BASH_VERSINFO[2]}"
20829+
outln
20830+
fi
2080720831
}
2080820832

20833+
2080920834
calc_scantime() {
2081020835
END_TIME=$(date +%s)
2081120836
SCAN_TIME=$(( END_TIME - START_TIME ))
@@ -23318,7 +23343,8 @@ parse_cmd_line() {
2331823343
get_install_dir
2331923344
find_openssl_binary
2332023345
prepare_debug
23321-
mybanner
23346+
# full banner
23347+
mybanner true
2332223348
exit $ALLOK
2332323349
;;
2332423350
esac

0 commit comments

Comments
 (0)