Skip to content

Nested cyclonedx.model.dependency.Dependency not serialized to JSON #941

@stefan6419846

Description

@stefan6419846

The Dependency class currently allows arbitrary nesting, at least according to the type hints:

def __init__(self, ref: BomRef, dependencies: Optional[Iterable['Dependency']] = None) -> None:
self.ref = ref
self.dependencies = dependencies or []
Serializing such a BOM to JSON will ignore everything except the top-level entry.

Example usage:

bom.dependencies.add(
    Dependency(
        root_component.bom_ref,
        dependencies=[
            Dependency(
                dependency1.bom_ref,
                dependencies=[
                    Dependency(dependency2.bom_ref)
                ]
            )
        ]
    )
)

I stumbled upon this when trying to process external BOMs for further analysis with only looking at the type hints, while I have not been able to build a BOM myself which would actually trigger this after serialization.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions