Skip to content

Add better support for cyclonedx format#117

Merged
mateuszdyminski merged 3 commits intomainfrom
better-cyclonedx-support
Dec 20, 2023
Merged

Add better support for cyclonedx format#117
mateuszdyminski merged 3 commits intomainfrom
better-cyclonedx-support

Conversation

@mateuszdyminski
Copy link
Contributor

We had an issue with purl found by @kevinlinglesas -> https://github.com/ksoclabs/kbom/issues/112

was: pkg:docker.io/istio/operator:1.19.0@sha256:b385e1873b071d6effa468114717846ee38db1b4524fa7fb59335f65d8c49735

now: pkg:oci/operator@sha256%3Ab385e1873b071d6effa468114717846ee38db1b4524fa7fb59335f65d8c49735?repository_url=docker.io%2Fistio%2Foperator&tag=1.19.0

Also root component and dependencies were missing, now it should be aligned with CycloneDX v1.5 specification for the 'purl'

I used following python snippet to validate the schema:

import json
from cyclonedx.model.bom import Bom
from cyclonedx.output.json import JsonV1Dot5
from cyclonedx.output.json import Json as JsonOutputter

def read_bom_from_json(json_file_path):
    with open(json_file_path, 'r') as file:
        bom_data = json.load(file)
        return Bom.from_json(bom_data)

def print_bom_to_stdout(bom):
    print(bom.to_xml_string(pretty_print=True))

if __name__ == "__main__":
    json_file_path = "<path_to_kbom_file>"
    bom = read_bom_from_json(json_file_path)
    my_json_outputter: 'JsonOutputter' = JsonV1Dot5(bom)
    serialized_json = my_json_outputter.output_as_string(indent=2)
    print(serialized_json)

pancernik
pancernik previously approved these changes Dec 14, 2023
Signed-off-by: Mateusz Dymiński <dyminski@gmail.com>
pancernik
pancernik previously approved these changes Dec 19, 2023
Signed-off-by: Mateusz Dymiński <dyminski@gmail.com>
@mateuszdyminski mateuszdyminski merged commit 1528798 into main Dec 20, 2023
@mateuszdyminski mateuszdyminski deleted the better-cyclonedx-support branch December 20, 2023 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants