Coverity-CWE 330: Use of Insufficiently Random Values 95/13295/2
authorselvi.j <selvi.j@tataelxsi.co.in>
Thu, 27 Apr 2023 06:53:45 +0000 (06:53 +0000)
committercalvinosanc1 <guillermo.calvino@canonical.com>
Tue, 13 Jun 2023 13:25:00 +0000 (15:25 +0200)
Added fix for CWE 330: Use of Insufficiently Random Value (Cryptographically weak PRNG)

Change-Id: I927c9d22ca42b01f6ec1fe9fc41e4b962167b72f
Signed-off-by: selvi.j <selvi.j@tataelxsi.co.in>
n2vc/k8s_helm_base_conn.py

index 2a588b4..a897e0e 100644 (file)
@@ -1962,7 +1962,7 @@ class K8sHelmBaseConnector(K8sConnector):
             self._init_paths_env(cluster_name=cluster_id, create_if_not_exist=True)
 
             def get_random_number():
-                r = random.randrange(start=1, stop=99999999)
+                r = random.SystemRandom().randint(1, 99999999)
                 s = str(r)
                 while len(s) < 10:
                     s = "0" + s
@@ -2028,7 +2028,7 @@ class K8sHelmBaseConnector(K8sConnector):
         name += "-"
 
         def get_random_number():
-            r = random.randrange(start=1, stop=99999999)
+            r = random.SystemRandom().randint(1, 99999999)
             s = str(r)
             s = s.rjust(10, "0")
             return s