Skip to content

Commit e2e6387

Browse files
committed
replacing all yaml.load with yaml.safe_load
1 parent 6cdd4f2 commit e2e6387

File tree

9 files changed

+21
-21
lines changed

9 files changed

+21
-21
lines changed

openshift_performance/ci/scripts/increase_pods.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def print_new_yaml(num, fileName):
1919
# append to file
2020
yaml = YAML()
2121
with open(fileName, "r") as f:
22-
yaml_file = yaml.load(f)
22+
yaml_file = yaml.safe_load(f)
2323
yaml_file['projects'][0]['num'] = num
2424
with open(fileName, "w+") as f:
2525
yaml.indent(mapping=2, sequence=4, offset=2)
@@ -30,7 +30,7 @@ def print_new_yaml_temp(num, fileName):
3030
# append to file
3131
yaml = YAML()
3232
with open(fileName, "r") as f:
33-
yaml_file = yaml.load(f)
33+
yaml_file = yaml.safe_load(f)
3434
yaml_file['projects'][0]['templates'][0]['num'] = num
3535
with open(fileName, "w+") as f:
3636
yaml.indent(mapping=2, sequence=4, offset=2)

openshift_scalability/ci/scripts/get_pod_total.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
def get_pod_counts_python(file):
66
pod_list = []
77
with open(file, "r") as f:
8-
yaml_file = yaml.load(f, Loader=yaml.FullLoader)
8+
yaml_file = yaml.safe_load(f)
99
for proj in yaml_file['projects']:
1010
for pod in proj['pods']:
1111
if "total" in pod.keys():
@@ -17,7 +17,7 @@ def get_pod_counts_golang(file):
1717

1818
pod_list=[]
1919
with open(file, "r") as f:
20-
yaml_file = yaml.load(f, Loader=yaml.FullLoader)
20+
yaml_file = yaml.safe_load(f)
2121
for proj in yaml_file['ClusterLoader']['projects']:
2222
for pod in proj['pods']:
2323
if "num" in pod.keys():

openshift_scalability/cluster-loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353
testconfig = {}
5454
with open(options.cfgfile) as stream:
55-
testconfig = yaml.load(stream)
55+
testconfig = yaml.safe_load(stream)
5656

5757
globalvars = {}
5858
globalvars["cleanoption"] = options.cleanall

openshift_scalability/scripts/drainNode/drain_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
def print_new_yaml_temp(num, fileName):
55
# append to file
66
with open(fileName, "r") as f:
7-
yaml_file = yaml.load(f, Loader=yaml.FullLoader)
7+
yaml_file = yaml.safe_load(f)
88
yaml_file['projects'][0]['templates'][0]['num'] = num
99
with open(fileName, "w+") as f:
1010
str_file = yaml.dump(yaml_file)

openshift_scalability/scripts/pod_density/increase_pods.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def run(command):
1717
def print_new_yaml(num, fileName):
1818
# append to file
1919
with open(fileName, "r") as f:
20-
yaml_file = yaml.load(f, Loader=yaml.FullLoader)
20+
yaml_file = yaml.safe_load(f)
2121
print("yaml file " + str(yaml_file))
2222
yaml_file['projects'][0]['num'] = num
2323
print("new yaml file " + str(yaml_file))
@@ -30,7 +30,7 @@ def print_new_yaml(num, fileName):
3030
def print_new_yaml_temp(num, fileName):
3131
# append to file
3232
with open(fileName, "r") as f:
33-
yaml_file = yaml.load(f, Loader=yaml.FullLoader)
33+
yaml_file = yaml.safe_load(f)
3434
print("yaml file " + str(yaml_file))
3535
yaml_file['projects'][0]['templates'][0]['num'] = num
3636
print("new yaml file " + str(yaml_file))

openshift_scalability/utils.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ def single_project(testconfig, projname, globalvars):
438438
if globalvars["kubeopt"]:
439439
tmpfile=tempfile.NamedTemporaryFile(mode='w')
440440
with open("content/namespace-default.yaml") as infile:
441-
nsconfig = yaml.load(infile)
441+
nsconfig = yaml.safe_load(infile)
442442
nsconfig["metadata"]["name"] = projname
443443
with open(tmpfile.name, 'w+') as f:
444444
yaml.dump(nsconfig, f, default_flow_style=False)
@@ -568,7 +568,7 @@ def quota_handler(inputquota, globalvars):
568568
quotafile = "content/quota-default.json"
569569

570570
with open(quotafile,'r') as infile:
571-
qconfig = json.load(infile)
571+
qconfig = json.safe_load(infile)
572572
qconfig["metadata"]["namespace"] = globalvars["namespace"]
573573
qconfig["metadata"]["name"] = quota["name"]
574574
tmpfile=tempfile.NamedTemporaryFile(mode='w')
@@ -619,7 +619,7 @@ def service_handler(inputservs, globalvars):
619619

620620
service_config = {}
621621
with open(servfile) as stream:
622-
service_config = json.load(stream)
622+
service_config = json.safe_load(stream)
623623
service_config["metadata"]["namespace"] = namespace
624624
service_config["metadata"]["name"] = basename
625625

@@ -634,7 +634,7 @@ def ebs_create(globalvars):
634634
global ebsvolumeid
635635
ebsvolumeid = ec2_volume(ebsvolumesize,ebsvtype,ebstagprefix,ebsregion)
636636
with open("content/pv-default.json", "r") as pvstream:
637-
pvjson = json.load(pvstream)
637+
pvjson = json.safe_load(pvstream)
638638
pvjson["metadata"]["name"] = ebsvolumeid
639639
pvjson["spec"]["capacity"]["storage"] = str(ebsvolumesize) + "Gi" # this has to be like this till k8s 23357 is fixed
640640
pvjson["spec"]["accessModes"] = [pvpermissions]
@@ -653,7 +653,7 @@ def ebs_create(globalvars):
653653
pvtmpfile.close()
654654

655655
with open("content/pvc-default.json", "r") as pvcstream:
656-
pvcjson = json.load(pvcstream)
656+
pvcjson = json.safe_load(pvcstream)
657657
pvcjson["metadata"]["name"] = ebsvolumeid
658658
pvcjson["metadata"]["namespace"] = namespace
659659
pvcjson["spec"]["resources"]["requests"]["storage"] = str(ebsvolumesize) + "Gi"
@@ -673,7 +673,7 @@ def ebs_create(globalvars):
673673
def ceph_secret_create(cephsecret,globalvars):
674674
namespace = globalvars["namespace"]
675675
with open("content/ceph-secret.json") as cephsec:
676-
cephsecjson = json.load(cephsec)
676+
cephsecjson = json.safe_load(cephsec)
677677

678678
cephsecjson["metadata"]["name"] = cephsecretname
679679
cephsecjson["metadata"]["namespace"] = namespace
@@ -704,7 +704,7 @@ def ceph_image_create(i,globalvars):
704704
# ceph_volume function will create ceph images at ceph storage cluster side
705705
ceph_volume(cephpool,cephimagename,imagesize)
706706
with open("content/pv-ceph.json") as pvstream:
707-
pvjson = json.load(pvstream)
707+
pvjson = json.safe_load(pvstream)
708708

709709
pvjson["metadata"]["name"] = "cephvol" + str(i)
710710
pvjson["metadata"]["namespace"] = namespace
@@ -730,7 +730,7 @@ def ceph_image_create(i,globalvars):
730730
pvtmpfile.close()
731731

732732
with open("content/pvc-default.json", "r") as pvcstream:
733-
pvcjson = json.load(pvcstream)
733+
pvcjson = json.safe_load(pvcstream)
734734
pvcjson["metadata"]["name"] = "cephclaim" + str(i)
735735
pvcjson["metadata"]["namespace"] = namespace
736736
pvcjson["spec"]["resources"]["requests"]["storage"] = str(cephimagesize) + "Gi"
@@ -839,7 +839,7 @@ def pod_handler(inputpods, globalvars):
839839

840840
pod_config = {}
841841
with open(podfile) as stream:
842-
pod_config = json.load(stream)
842+
pod_config = json.safe_load(stream)
843843
pod_config["metadata"]["namespace"] = namespace
844844
pod_config["metadata"]["name"] = basename
845845

@@ -872,7 +872,7 @@ def rc_handler(inputrcs, globalvars):
872872

873873
rc_config = {}
874874
with open(rcfile) as stream:
875-
rc_config = json.load(stream)
875+
rc_config = json.safe_load(stream)
876876
rc_config["metadata"]["namespace"] = namespace
877877
rc_config["metadata"]["name"] = basename
878878
rc_config["spec"]["replicas"] = replicas

reliability/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
print("starting...")
44
stream = open("./config/simple_reliability.yaml","r")
5-
y = yaml.load(stream)
5+
y = yaml.safe_load(stream)
66
print(y['reliability']['appTemplates'][3]['template'])

shutdown/start_clouds/az_node_scenarios.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def __init__(self, az_account):
1212
credentials = DefaultAzureCredential()
1313
logging.info("credential " + str(credentials))
1414

15-
az_account_yaml = yaml.load(az_account, Loader=yaml.FullLoader)
15+
az_account_yaml = yaml.safe_load(az_account)
1616
subscription_id = az_account_yaml[0]['id']
1717
self.compute_client = ComputeManagementClient(credentials, subscription_id)
1818

storage/mongodb/rewrite_external_vars.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
def replace_value_in_file(fileName, key,value):
55
# append to file
66
with open(fileName, "r") as f:
7-
yaml_file = yaml.load(f, Loader=yaml.FullLoader)
7+
yaml_file = yaml.safe_load(f)
88
yaml_file[key] = value
99
with open(fileName, "w+") as f:
1010
f.write('---\n')

0 commit comments

Comments
 (0)