| import json
|
| import copy
|
| from typing import Dict, Any
|
|
|
| def export_aibom(aibom: Dict[str, Any], bom_type: str = "cyclonedx", spec_version: str = "1.6") -> str:
|
| """
|
| Exports the internal AIBOM object into a specified format and specification version.
|
| Returns the generated SBOM as a formatted JSON string.
|
| """
|
|
|
| output = copy.deepcopy(aibom)
|
|
|
| if bom_type.lower() == "cyclonedx":
|
| output["bomFormat"] = "CycloneDX"
|
| output["specVersion"] = spec_version
|
|
|
|
|
| elif bom_type.lower() == "spdx":
|
|
|
| output["bomFormat"] = "SPDX"
|
| output["specVersion"] = spec_version
|
|
|
| pass
|
|
|
| return json.dumps(output, indent=2)
|
|
|