Pull license IDs/names from CycloneDX license entries.
(component: dict)
| 19 | |
| 20 | |
| 21 | def extract_licenses(component: dict) -> str: |
| 22 | """Pull license IDs/names from CycloneDX license entries.""" |
| 23 | licenses = component.get("licenses", []) |
| 24 | ids = [] |
| 25 | for entry in licenses: |
| 26 | if "expression" in entry: |
| 27 | ids.append(entry["expression"]) |
| 28 | else: |
| 29 | lic = entry.get("license", {}) |
| 30 | ids.append(lic.get("id") or lic.get("name", "")) |
| 31 | return " | ".join(filter(None, ids)) |
| 32 | |
| 33 | |
| 34 | def sbom_to_csv(json_path: Path) -> Path: |