Skip to content

Commit 2422cd8

Browse files
author
Power Cloud Robot
authored
Merge pull request #53 from SurajGudaji/check_sensitive
Added function to check if sensitive information is exposed
2 parents 2a21cb4 + 4a60a22 commit 2422cd8

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

monitor.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,23 @@ def check_if_gather_libvirt_dir_exists(spy_link,job_type):
331331
except requests.RequestException:
332332
return "Error while sending request to url"
333333

334+
#This is a fix to check for sensitive information expose error.
335+
def check_if_sensitive_info_exposed(spy_link):
336+
337+
build_log_url = PROW_VIEW_URL + spy_link[8:] + '/build-log.txt'
338+
try:
339+
response = requests.get(build_log_url, verify=False, timeout=15)
340+
senstive_info_re = re.compile('This file contained potentially sensitive information and has been removed.')
341+
senstive_info_re_match = senstive_info_re.search(response.text)
342+
if senstive_info_re_match is not None:
343+
return True
344+
else:
345+
return False
346+
except requests.Timeout:
347+
return "Request timed out"
348+
except requests.RequestException:
349+
return "Error while sending request to url"
350+
334351
def get_node_status(spy_link):
335352

336353
'''
@@ -1111,12 +1128,16 @@ def get_brief_job_info(prow_ci_name,prow_ci_link,start_date=None,end_date=None,z
11111128
continue
11121129
job_status = check_job_status(job)
11131130
cluster_status=cluster_deploy_status(job)
1131+
sensitive_info_expose_status=check_if_sensitive_info_exposed(job)
11141132
i=i+1
11151133
job_dict = {}
11161134
job_dict["Build"] = prow_ci_name
11171135
job_dict["Prow Job ID"] = job_id
11181136
job_dict["Install Status"] = cluster_status
1119-
job_dict["Lease"]=lease
1137+
if sensitive_info_expose_status == True:
1138+
job_dict["Lease"]="Build log removed"
1139+
else:
1140+
job_dict["Lease"]=lease
11201141
if job_status == 'SUCCESS' and "sno" not in prow_ci_link:
11211142
job_dict["Test result"] = "PASS"
11221143
elif job_status == 'FAILURE' and "sno" not in prow_ci_link:
@@ -1172,11 +1193,22 @@ def get_detailed_job_info(prow_ci_name,prow_ci_link,start_date=None,end_date=Non
11721193
continue
11731194
i=i+1
11741195
print(i,"Job link: https://prow.ci.openshift.org/"+job)
1175-
print("Nightly info-", nightly)
1196+
11761197
job_status = check_job_status(job)
1198+
sensitive_info_expose_status=check_if_sensitive_info_exposed(job)
1199+
1200+
if sensitive_info_expose_status == True:
1201+
print("*********************************")
1202+
print("Build log removed")
1203+
print("*********************************")
1204+
1205+
print("Nightly info-", nightly)
1206+
11771207
if job_status == 'SUCCESS':
11781208
deploy_count += 1
11791209
e2e_count=e2e_count+1
1210+
if "sno" not in job:
1211+
print("Lease Quota-", lease)
11801212
check_node_crash(job)
11811213
print("This is a Green build")
11821214
elif job_status == 'FAILURE':

0 commit comments

Comments
 (0)