8000 Fix: cyclonedx SBOM author field by ErniGH · Pull Request #18014 · conan-io/conan · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix: cyclonedx SBOM author field #18014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions conan/tools/sbom/cyclonedx.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ def cyclonedx_1_4(conanfile, name=None, add_build=False, add_tests=False, **kwar

name_default = getattr(graph.root.ref, "name", False) or "conan-sbom"
name_default += f"/{graph.root.ref.version}" if bool(getattr(graph.root.ref, "version", False)) else ""
components = [node for node in graph.nodes if (node.context == "host" or add_build) and (not node.test or add_tests)]
nodes = [node for node in graph.nodes if (node.context == "host" or add_build) and (not node.test or add_tests)]
if has_special_root_node:
components = components[1:]
nodes = nodes[1:]

dependencies = []
if has_special_root_node:
deps = {"ref": special_id,
"dependsOn": [f"pkg:conan/{d.dst.name}@{d.dst.ref.version}?rref={d.dst.ref.revision}"
for d in graph.root.dependencies]}
dependencies.append(deps)
for c in components:
for c in nodes:
deps = {"ref": f"pkg:conan/{c.name}@{c.ref.version}?rref={c.ref.revision}"}
dep = [d for d in c.dependencies if (d.dst.context == "host" or add_build) and (not d.dst.test or add_tests)]

Expand All @@ -63,23 +63,23 @@ def _calculate_licenses(component):

sbom_cyclonedx_1_4 = {
**({"components": [{
"author": "Conan",
"bom-ref": special_id if has_special_root_node else f"pkg:conan/{c.name}@{c.ref.version}?rref={c.ref.revision}",
"description": c.conanfile.description,
"author": node.conanfile.author or "Unknown",
"bom-ref": special_id if has_special_root_node else f"pkg:conan/{node.name}@{node.ref.version}?rref={node.ref.revision}",
"description": node.conanfile.description,
**({"externalReferences": [{
"type": "website",
"url": c.conanfile.homepage
}]} if c.conanfile.homepage else {}),
**({"licenses": _calculate_licenses(c)} if c.conanfile.license else {}),
"name": c.name,
"purl": f"pkg:conan/{c.name}@{c.ref.version}",
"url": node.conanfile.homepage
}]} if node.conanfile.homepage else {}),
**({"licenses": _calculate_licenses(node)} if node.conanfile.license else {}),
"name": node.name,
"purl": f"pkg:conan/{node.name}@{node.ref.version}",
"type": "library",
"version": str(c.ref.version),
} for c in components]} if components else {}),
"version": str(node.ref.version),
} for node in nodes]} if nodes else {}),
**({"dependencies": dependencies} if dependencies else {}),
"metadata": {
"component": {
"author": "Conan",
"author": conanfile.author or "Unknown",
"bom-ref": special_id if has_special_root_node else f"pkg:conan/{conanfile.name}@{conanfile.ref.version}?rref={conanfile.ref.revision}",
"name": name if name else name_default,
"type": "library"
Expand Down
Loading
0