|
8 | 8 |
|
9 | 9 | import logging |
10 | 10 | import sys |
11 | | -from typing import Any, Dict, List |
| 11 | +from typing import Any, Dict, List, Tuple |
12 | 12 |
|
13 | 13 | from cyclonedx.model import ExternalReferenceType, HashAlgorithm |
14 | 14 | from cyclonedx.model.bom import Bom |
@@ -36,14 +36,13 @@ def get_external_id(self, name: str, release_details: Dict[str, Any]) -> str: |
36 | 36 |
|
37 | 37 | return release_details["externalIds"].get(name, "") |
38 | 38 |
|
39 | | - def get_clearing_state(self, proj: Dict[str, Any], href: str) -> str: |
40 | | - """Returns the clearing state of the given component/release""" |
| 39 | + def get_linked_state(self, proj: Dict[str, Any], href: str) -> Tuple[str, str]: |
| 40 | + """Returns project mainline state and relation of the given release""" |
41 | 41 | rel = proj["linkedReleases"] |
42 | 42 | for key in rel: |
43 | 43 | if key["release"] == href: |
44 | | - return key["mainlineState"] |
45 | | - |
46 | | - return "" |
| 44 | + return (key["mainlineState"], key["relation"]) |
| 45 | + return ("", "") |
47 | 46 |
|
48 | 47 | def create_project_bom(self, project: Dict[str, Any]) -> List[Component]: |
49 | 48 | bom: List[Component] = [] |
@@ -112,9 +111,10 @@ def create_project_bom(self, project: Dict[str, Any]) -> List[Component]: |
112 | 111 | print_red(" ERROR: unable to access project:" + repr(swex)) |
113 | 112 | sys.exit(ResultCode.RESULT_ERROR_ACCESSING_SW360) |
114 | 113 |
|
115 | | - state = self.get_clearing_state(project, href) |
116 | | - if state: |
117 | | - CycloneDxSupport.set_property(rel_item, CycloneDxSupport.CDX_PROP_PROJ_STATE, state) |
| 114 | + mainline_state, relation = self.get_linked_state(project, href) |
| 115 | + if mainline_state and relation: |
| 116 | + CycloneDxSupport.set_property(rel_item, CycloneDxSupport.CDX_PROP_PROJ_STATE, mainline_state) |
| 117 | + CycloneDxSupport.set_property(rel_item, CycloneDxSupport.CDX_PROP_PROJ_RELATION, relation) |
118 | 118 |
|
119 | 119 | sw360_id = self.client.get_id_from_href(href) |
120 | 120 | CycloneDxSupport.set_property(rel_item, CycloneDxSupport.CDX_PROP_SW360ID, sw360_id) |
|
0 commit comments