|
28 | 28 | from ..model.bom import Bom |
29 | 29 |
|
30 | 30 |
|
| 31 | +ComponentDict = Dict[str, Union[ |
| 32 | + str, |
| 33 | + List[Dict[str, str]], |
| 34 | + List[Dict[str, Dict[str, str]]], |
| 35 | + List[Dict[str, Union[str, List[Dict[str, str]]]]]]] |
| 36 | + |
| 37 | + |
31 | 38 | class Json(BaseOutput, BaseSchemaVersion): |
32 | 39 |
|
33 | 40 | def __init__(self, bom: Bom) -> None: |
@@ -73,15 +80,19 @@ def _specialise_output_for_schema_version(self, bom_json: Dict[Any, Any]) -> str |
73 | 80 | del bom_json['metadata']['tools'][i]['externalReferences'] |
74 | 81 |
|
75 | 82 | # Iterate Components |
76 | | - for i in range(len(bom_json['components'])): |
77 | | - if not self.component_supports_author() and 'author' in bom_json['components'][i].keys(): |
78 | | - del bom_json['components'][i]['author'] |
| 83 | + if 'components' in bom_json.keys(): |
| 84 | + for i in range(len(bom_json['components'])): |
| 85 | + if not self.component_supports_author() and 'author' in bom_json['components'][i].keys(): |
| 86 | + del bom_json['components'][i]['author'] |
79 | 87 |
|
80 | | - if not self.component_supports_mime_type_attribute() and 'mime-type' in bom_json['components'][i].keys(): |
81 | | - del bom_json['components'][i]['mime-type'] |
| 88 | + if not self.component_supports_mime_type_attribute() \ |
| 89 | + and 'mime-type' in bom_json['components'][i].keys(): |
| 90 | + del bom_json['components'][i]['mime-type'] |
82 | 91 |
|
83 | | - if not self.component_supports_release_notes() and 'releaseNotes' in bom_json['components'][i].keys(): |
84 | | - del bom_json['components'][i]['releaseNotes'] |
| 92 | + if not self.component_supports_release_notes() and 'releaseNotes' in bom_json['components'][i].keys(): |
| 93 | + del bom_json['components'][i]['releaseNotes'] |
| 94 | + else: |
| 95 | + bom_json['components'] = [] |
85 | 96 |
|
86 | 97 | # Iterate Vulnerabilities |
87 | 98 | if 'vulnerabilities' in bom_json.keys(): |
|
0 commit comments