Skip to content

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

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions