Coverity CWE 330: Use of Insufficiently Random Values
[osm/RO.git] / RO-plugin / osm_ro_plugin / vim_dummy.py
index fbc6bfe..dc0e00e 100644 (file)
@@ -22,7 +22,7 @@ Implements a Dummy vim plugin.
 
 from copy import deepcopy
 import logging
-from random import randrange
+from random import SystemRandom
 from uuid import uuid4
 
 from osm_ro_plugin import vimconn
@@ -379,8 +379,10 @@ class VimDummyConnector(vimconn.VimConnector):
             if iface.get("type") in ("SR-IOV", "PCI-PASSTHROUGH") and self.config.get(
                 "sdn-port-mapping"
             ):
-                compute_index = randrange(len(self.config["sdn-port-mapping"]))
-                port_index = randrange(
+                compute_index = SystemRandom().randrange(
+                    len(self.config["sdn-port-mapping"])
+                )
+                port_index = SystemRandom().randrange(
                     len(self.config["sdn-port-mapping"][compute_index]["ports"])
                 )
                 interface["compute_node"] = self.config["sdn-port-mapping"][