MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / sbom_to_csv

Function sbom_to_csv

deploy/sbom/sbom_to_csv.py:34–58  ·  view source on GitHub ↗

Read a CycloneDX JSON SBOM and write a CSV beside it.

(json_path: Path)

Source from the content-addressed store, hash-verified

32
33
34def sbom_to_csv(json_path: Path) -> Path:
35 """Read a CycloneDX JSON SBOM and write a CSV beside it."""
36 with json_path.open() as f:
37 sbom = json.load(f)
38
39 csv_path = json_path.with_suffix(".csv")
40 components = sbom.get("components", [])
41
42 with csv_path.open("w", newline="") as f:
43 writer = csv.writer(f)
44 writer.writerow(["name", "version", "type", "purl", "licenses", "bom-ref"])
45
46 for comp in components:
47 writer.writerow(
48 [
49 comp.get("name", ""),
50 comp.get("version", ""),
51 comp.get("type", ""),
52 comp.get("purl", ""),
53 extract_licenses(comp),
54 comp.get("bom-ref", ""),
55 ]
56 )
57
58 return csv_path
59
60
61def _find_sbom_files() -> list[Path]:

Callers 1

mainFunction · 0.85

Calls 3

extract_licensesFunction · 0.85
loadMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected