Skip to content

Commit 85805ba

Browse files
committed
Fix not working --disable-rating switch (3.3dev)
The logic was wrong when calling set_rating_state() in parse_cmd_line() as do_rating was set before to true through set_scanning_defaults(). This PR fixes #2825 by querying ${SKIP_TESTS[@]} instead and then calling set_rating_state() when no --disable-rating was supplied .
1 parent a4d6f9a commit 85805ba

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

testssl.sh

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,7 @@ f5_port_decode() {
11281128
# Sets the grade cap to ARG1
11291129
# arg1: A grade to set ("A", "B", "C", "D", "E", "F", "M", or "T")
11301130
# arg2: A reason why (e.g. "Vulnerable to CRIME")
1131+
#
11311132
set_grade_cap() {
11321133
"$do_rating" || return 0
11331134
GRADE_CAP_REASONS+=("Grade capped to $1. $2")
@@ -1144,6 +1145,7 @@ set_grade_cap() {
11441145

11451146
# Sets a grade warning, as specified by the grade specification
11461147
# arg1: A warning message
1148+
#
11471149
set_grade_warning() {
11481150
"$do_rating" || return 0
11491151
GRADE_WARNINGS+=("$1")
@@ -1153,6 +1155,7 @@ set_grade_warning() {
11531155
# Sets the score for Category 2 (Key Exchange Strength)
11541156
# arg1: Short key algorithm ("EC", "DH", "RSA", ...), or "DHE" for ephemeral key size
11551157
# arg2: key size (number of bits)
1158+
#
11561159
set_key_str_score() {
11571160
local type=$1
11581161
local size=$2
@@ -1190,6 +1193,7 @@ set_key_str_score() {
11901193
# Sets the best and worst bit size key, used to grade Category 3 (Cipher Strength)
11911194
# This function itself doesn't actually set a score; its just in the name to keep it logical (score == rating function)
11921195
# arg1: a bit size
1196+
#
11931197
set_ciph_str_score() {
11941198
local size=$1
11951199

@@ -23935,6 +23939,7 @@ run_rating() {
2393523939
# Rating needs a mix of certificate and vulnerabilities checks, in order to give out proper grades.
2393623940
# This function disables rating, if not all required checks are enabled
2393723941
# Returns "0" if rating is enabled, and "1" if rating is disabled
23942+
#
2393823943
set_rating_state() {
2393923944
local gbl
2394023945
local -i nr_enabled=0
@@ -23960,9 +23965,9 @@ set_rating_state() {
2396023965
return 0
2396123966
}
2396223967

23963-
2396423968
# This initializes boolean global do_* variables. They keep track of what to do
2396523969
# -- as the name insinuates
23970+
#
2396623971
initialize_globals() {
2396723972
do_allciphers=false
2396823973
do_vulnerabilities=false
@@ -24009,6 +24014,7 @@ initialize_globals() {
2400924014

2401024015

2401124016
# Set default scanning options for the boolean global do_* variables.
24017+
#
2401224018
set_scanning_defaults() {
2401324019
do_allciphers=false
2401424020
do_vulnerabilities=true
@@ -24376,9 +24382,9 @@ parse_cmd_line() {
2437624382
do_grease=true
2437724383
;;
2437824384
--disable-rating|--no-rating)
24379-
SKIP_TESTS+=("rating")
2438024385
# TODO: a generic thing would be --disable-* / --no-* ,
2438124386
# catch $1 and add it to the array ( #1502 )
24387+
SKIP_TESTS+=("rating")
2438224388
;;
2438324389
-9|--full)
2438424390
set_scanning_defaults
@@ -24791,9 +24797,11 @@ parse_cmd_line() {
2479124797
set_skip_tests
2479224798
[[ "$DEBUG" -ge 5 ]] && debug_globals
2479324799

24794-
# Unless explicit disabled, check if rating can be enabled
24795-
# Should be called after set_scanning_defaults
24796-
! "$do_rating" && set_rating_state
24800+
# Unless explicit disabled, check if rating can or should be enabled.
24801+
# Should be called after set_scanning_defaults() and set_skip_tests()
24802+
if [[ ! ${SKIP_TESTS[@]} =~ rating ]] ; then
24803+
set_rating_state
24804+
fi
2479724805

2479824806
CMDLINE_PARSED=true
2479924807
}

0 commit comments

Comments
 (0)