[PATCH] D68104: [LNT] Python 3 support: adapt secret computation

Thomas Preud'homme via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 7 03:09:49 PDT 2019


thopre updated this revision to Diff 223468.
thopre added a comment.

Use approach suggested by Hubert to adapt the existing code rather than use a new way of generating random bits to not change the security strength of the code.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68104/new/

https://reviews.llvm.org/D68104

Files:
  lnt/lnttool/create.py


Index: lnt/lnttool/create.py
===================================================================
--- lnt/lnttool/create.py
+++ lnt/lnttool/create.py
@@ -113,6 +113,7 @@
 * INSTANCE_PATH should point to a directory that will keep
 LNT configuration.
     """
+    from builtins import bytes
     from .common import init_logger
     import hashlib
     import lnt.server.db.migrate
@@ -137,8 +138,12 @@
     tmp_path = os.path.join(basepath, tmp_dir)
     wsgi_path = os.path.join(basepath, wsgi)
     schemas_path = os.path.join(basepath, "schemas")
-    secret_key = (secret_key or
-                  hashlib.sha1(str(random.getrandbits(256))).hexdigest())
+    secret_key = (
+        secret_key
+        or hashlib.sha1(
+            bytes(str(random.getrandbits(256)), encoding="ascii")
+        ).hexdigest()
+    )
 
     os.mkdir(instance_path)
     os.mkdir(tmp_path)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68104.223468.patch
Type: text/x-patch
Size: 876 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191007/a6de33f2/attachment.bin>


More information about the llvm-commits mailing list