Coverity CWE 330: Use of Insufficiently Random Values
Added support to fix CWE 330: Use of Insufficiently Random Values
Coverity issue
Change-Id: Ib12ebeeb9b0cc10af9980fe8661eb6230c2f6d6d
Signed-off-by: elumalai <deepika.e@tataelxsi.co.in>
diff --git a/RO-plugin/osm_ro_plugin/vim_dummy.py b/RO-plugin/osm_ro_plugin/vim_dummy.py
index fbc6bfe..dc0e00e 100644
--- a/RO-plugin/osm_ro_plugin/vim_dummy.py
+++ b/RO-plugin/osm_ro_plugin/vim_dummy.py
@@ -22,7 +22,7 @@
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 @@
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"][