Skip to content

Commit adf95ce

Browse files
committed
feat(project createbom): store release relation data
1 parent 99b2402 commit adf95ce

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
# CaPyCli - Clearing Automation Python Command Line Tool for SW360
77

8+
## UNRELEASED
9+
10+
* `project createbom` stores release relations (`CONTAINED`, `SIDE_BY_SIDE` etc.) as capycli:projectRelation
11+
812
## 2.7.0
913

1014
* fix for `bom findsources` for some JavaScript SBOMs.

capycli/common/capycli_bom_support.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class CycloneDxSupport():
6666
CDX_PROP_CLEARING_STATE = "capycli:clearingState"
6767
CDX_PROP_CATEGORIES = "capycli:categories"
6868
CDX_PROP_PROJ_STATE = "capycli:projectClearingState"
69+
CDX_PROP_PROJ_RELATION = "capycli:projectRelation"
6970
CDX_PROP_PROFILE = "siemens:profile"
7071

7172
@staticmethod

capycli/project/create_bom.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,12 @@ def get_external_id(self, name: str, release_details: Dict[str, Any]) -> str:
3636

3737
return release_details["externalIds"].get(name, "")
3838

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) -> str:
40+
"""Returns project mainline state and relation of the given release"""
4141
rel = proj["linkedReleases"]
4242
for key in rel:
4343
if key["release"] == href:
44-
return key["mainlineState"]
45-
44+
return (key["mainlineState"], key["relation"])
4645
return ""
4746

4847
def create_project_bom(self, project: Dict[str, Any]) -> List[Component]:
@@ -112,9 +111,10 @@ def create_project_bom(self, project: Dict[str, Any]) -> List[Component]:
112111
print_red(" ERROR: unable to access project:" + repr(swex))
113112
sys.exit(ResultCode.RESULT_ERROR_ACCESSING_SW360)
114113

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)
118118

119119
sw360_id = self.client.get_id_from_href(href)
120120
CycloneDxSupport.set_property(rel_item, CycloneDxSupport.CDX_PROP_SW360ID, sw360_id)

0 commit comments

Comments
 (0)