Skip to content

Commit

Permalink
feat(project createbom): store release relation data
Browse files Browse the repository at this point in the history
  • Loading branch information
gernot-h committed Feb 5, 2025
1 parent 99b2402 commit adf95ce
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

# CaPyCli - Clearing Automation Python Command Line Tool for SW360

## UNRELEASED

* `project createbom` stores release relations (`CONTAINED`, `SIDE_BY_SIDE` etc.) as capycli:projectRelation

## 2.7.0

* fix for `bom findsources` for some JavaScript SBOMs.
Expand Down
1 change: 1 addition & 0 deletions capycli/common/capycli_bom_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class CycloneDxSupport():
CDX_PROP_CLEARING_STATE = "capycli:clearingState"
CDX_PROP_CATEGORIES = "capycli:categories"
CDX_PROP_PROJ_STATE = "capycli:projectClearingState"
CDX_PROP_PROJ_RELATION = "capycli:projectRelation"
CDX_PROP_PROFILE = "siemens:profile"

@staticmethod
Expand Down
14 changes: 7 additions & 7 deletions capycli/project/create_bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,12 @@ def get_external_id(self, name: str, release_details: Dict[str, Any]) -> str:

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

def get_clearing_state(self, proj: Dict[str, Any], href: str) -> str:
"""Returns the clearing state of the given component/release"""
def get_linked_state(self, proj: Dict[str, Any], href: str) -> str:
"""Returns project mainline state and relation of the given release"""
rel = proj["linkedReleases"]
for key in rel:
if key["release"] == href:
return key["mainlineState"]

return (key["mainlineState"], key["relation"])
return ""

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

state = self.get_clearing_state(project, href)
if state:
CycloneDxSupport.set_property(rel_item, CycloneDxSupport.CDX_PROP_PROJ_STATE, state)
mainline_state, relation = self.get_linked_state(project, href)
if mainline_state and relation:
CycloneDxSupport.set_property(rel_item, CycloneDxSupport.CDX_PROP_PROJ_STATE, mainline_state)
CycloneDxSupport.set_property(rel_item, CycloneDxSupport.CDX_PROP_PROJ_RELATION, relation)

sw360_id = self.client.get_id_from_href(href)
CycloneDxSupport.set_property(rel_item, CycloneDxSupport.CDX_PROP_SW360ID, sw360_id)
Expand Down

0 comments on commit adf95ce

Please sign in to comment.