@@ -109,18 +109,21 @@ def override_policy_violaton(project_name, project_version, component_name, comp
109
109
params = {"q" :f"componentOrVersionName:{ component_name } " }
110
110
components = bd .get_resource ('components' , version , params = params )
111
111
for component in components :
112
- policy_status = bd .get_resource ('policy-status' , component , items = False )
113
- url = bd .list_resources (policy_status )['href' ]
114
- data = {
115
- "approvalStatus" : "IN_VIOLATION_OVERRIDDEN" ,
116
- "comment" : f"{ override_rationale } " ,
117
- "updatedAt" : datetime .now ().isoformat ()
118
- }
119
- headers = {"Content-Type" : "application/vnd.blackducksoftware.bill-of-materials-6+json" ,
120
- "Accept" : "application/vnd.blackducksoftware.bill-of-materials-6+json" }
121
- r = bd .session .put (url , headers = headers , json = data )
122
- # r.raise_for_status()
123
- logging .info (f"Policy status update completion code { r .status_code } " )
112
+ component_version_name = str (component ['componentVersionName' ])
113
+ if str (component_version_name ).strip () == str (component_version ).strip ():
114
+ logging .info (f"Overriding violation for { component_name } { component_version } in { project_name } { project_version } " )
115
+ policy_status = bd .get_resource ('policy-status' , component , items = False )
116
+ url = bd .list_resources (policy_status )['href' ]
117
+ data = {
118
+ "approvalStatus" : "IN_VIOLATION_OVERRIDDEN" ,
119
+ "comment" : f"{ override_rationale } " ,
120
+ "updatedAt" : datetime .now ().isoformat ()
121
+ }
122
+ headers = {"Content-Type" : "application/vnd.blackducksoftware.bill-of-materials-6+json" ,
123
+ "Accept" : "application/vnd.blackducksoftware.bill-of-materials-6+json" }
124
+ r = bd .session .put (url , headers = headers , json = data )
125
+ # r.raise_for_status()
126
+ logging .info (f"Policy status update completion code { r .status_code } " )
124
127
125
128
126
129
def parse_command_args ():
@@ -165,7 +168,7 @@ def process_excel_file(filename):
165
168
project_version = row [14 ]
166
169
if policy_violation_status == 'IN_VIOLATION' and override_rationale and not override_date :
167
170
print ("overriding" )
168
- logging .info (f"Attemting to override policy status for { component_name } { component_version } in { project_name } { project_version } with ''{ override_rationale } ''" )
171
+ logging .info (f"Processing for batch entry { component_name } { component_version } in { project_name } { project_version } with ''{ override_rationale } ''" )
169
172
override_policy_violaton (project_name , project_version , component_name , component_version , override_rationale )
170
173
if not process :
171
174
process = (row [0 ] == "Name of Software Component" )
0 commit comments