@@ -30,46 +30,47 @@ def get_findings(self, filename, test):
30
30
items = list ()
31
31
try :
32
32
for image in data :
33
- for result in image ["detail" ]:
34
- try :
35
- gate = result ["gate" ]
36
- description = result ["description" ]
37
- policy_id = result ["policyId" ]
38
- status = result ["status" ]
39
- image_name = result ["tag" ]
40
- trigger_id = result ["triggerId" ]
41
- repo , tag = image_name .split (":" , 2 )
42
- severity = map_gate_action_to_severity (status )
43
- vulnerability_id = extract_vulnerability_id (trigger_id )
44
- title = (
45
- policy_id
46
- + " - gate|"
47
- + gate
48
- + " - trigger|"
49
- + trigger_id
50
- )
51
- find = Finding (
52
- title = title ,
53
- test = test ,
54
- description = description ,
55
- severity = severity ,
56
- references = "Policy ID: {}\n Trigger ID: {}" .format (
57
- policy_id , trigger_id
58
- ),
59
- file_path = search_filepath (description ),
60
- component_name = repo ,
61
- component_version = tag ,
62
- date = find_date ,
63
- static_finding = True ,
64
- dynamic_finding = False ,
65
- )
66
- if vulnerability_id :
67
- find .unsaved_vulnerability_ids = [vulnerability_id ]
68
- items .append (find )
69
- except (KeyError , IndexError ) as err :
70
- raise ValueError (
71
- "Invalid format: {} key not found" .format (err )
72
- )
33
+ if image ['detail' ] is not None :
34
+ for result in image ["detail" ]:
35
+ try :
36
+ gate = result ["gate" ]
37
+ description = result ["description" ]
38
+ policy_id = result ["policyId" ]
39
+ status = result ["status" ]
40
+ image_name = result ["tag" ]
41
+ trigger_id = result ["triggerId" ]
42
+ repo , tag = image_name .split (":" , 2 )
43
+ severity = map_gate_action_to_severity (status )
44
+ vulnerability_id = extract_vulnerability_id (trigger_id )
45
+ title = (
46
+ policy_id
47
+ + " - gate|"
48
+ + gate
49
+ + " - trigger|"
50
+ + trigger_id
51
+ )
52
+ find = Finding (
53
+ title = title ,
54
+ test = test ,
55
+ description = description ,
56
+ severity = severity ,
57
+ references = "Policy ID: {}\n Trigger ID: {}" .format (
58
+ policy_id , trigger_id
59
+ ),
60
+ file_path = search_filepath (description ),
61
+ component_name = repo ,
62
+ component_version = tag ,
63
+ date = find_date ,
64
+ static_finding = True ,
65
+ dynamic_finding = False ,
66
+ )
67
+ if vulnerability_id :
68
+ find .unsaved_vulnerability_ids = [vulnerability_id ]
69
+ items .append (find )
70
+ except (KeyError , IndexError ) as err :
71
+ raise ValueError (
72
+ "Invalid format: {} key not found" .format (err )
73
+ )
73
74
except AttributeError as err :
74
75
# import empty policies without error (e.g. policies or images
75
76
# objects are not a dictionary)
0 commit comments