changeset 8240:1189c742e4b3

fix: crash roundup-admin perftest password without rounds= argument. If the rounds value is taken from the config file, it doesn't need to be parsed into an int.
author John Rouillard <rouilj@ieee.org>
date Mon, 30 Dec 2024 02:59:27 -0500
parents 6bd11a73f2ed
children 741ea8a86012
files CHANGES.txt roundup/admin.py
diffstat 2 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES.txt	Mon Dec 30 02:57:46 2024 -0500
+++ b/CHANGES.txt	Mon Dec 30 02:59:27 2024 -0500
@@ -56,6 +56,8 @@
   manually if it is at 2 million. PBKDF2-SHA512 (PBKDF2S5) has been
   available since release 2.3, but it required a manual step to make
   it the default. (John Rouillard)
+- fixed a crash with roundup-admin perftest password when rounds not set
+  on command line. (John Rouillard)
 
 Features:
 
--- a/roundup/admin.py	Mon Dec 30 02:57:46 2024 -0500
+++ b/roundup/admin.py	Mon Dec 30 02:59:27 2024 -0500
@@ -1633,6 +1633,7 @@
         """
         from roundup.anypy.time_ import perf_counter
 
+        # default rounds from db.config is an int not str
         props = {"rounds": self.db.config.PASSWORD_PBKDF2_DEFAULT_ROUNDS,
                  "scheme": password.Password.default_scheme}
 
@@ -1649,7 +1650,9 @@
         if args[0] == "password":
             try:
                 # convert 10,000,000 or 10.000.000 to 10000000
-                r = int(re.sub('[,.]', '', props['rounds']))
+                r = int(re.sub('[,.]', '', props['rounds'])) \
+                    if  not isinstance(props['rounds'], int) \
+                        else props['rounds']
                 if r < 1000:
                     print(_("Invalid 'rounds'. Must be larger than 999."))
                     return

Roundup Issue Tracker: http://roundup-tracker.org/