Skip to content

Conversation

@mws180000
Copy link
Collaborator

Latest working draft of the CycloneDX input SBOM hook.

  • This includes adding any vulnerabilities from the CycloneDX SBOM into the observations section of the CyTRICS SBOM

  • Change in mapping requirements: It turns out that a CycloneDX component can have nested subcomponents. Mapping these subcomponents to the components section of the CyTRICS software entry format would fit better than mapping the CycloneDX services section to the CyTRICS components section since CycloneDX services are it's won section in the SBOM (rather than being part of individual CycloneDX component entries)

  • Some CycloneDX-exclusive component data is currently added to the metadata section of the corresponding CyTRICS software entry, while the rest needs to be transformed into formats that are JSON-serializable

@mws180000 mws180000 requested a review from nightlark June 18, 2024 17:47
@nightlark
Copy link
Collaborator

nightlark commented Aug 20, 2024

In the CyTRICS schema working group I was thinking that it would be nice to be able to track what CycloneDX/SPDX identifier is associated with software entries, which would enable SBOM conversion to preserve a stable identifier for a roundtrip conversion from CycloneDX -> CyTRICS/internal -> CycloneDX. https://cyclonedx.org/capabilities/bomlink/ has an example of what a full ref looks like.

@nightlark nightlark added the enhancement New feature or request label Apr 29, 2025
@nightlark nightlark changed the title Cyt 615 add spdx and cyclone dx read SBOM hook implementations Cyt 615 add cyclone dx read SBOM hook implementation Aug 26, 2025
@nightlark nightlark changed the title Cyt 615 add cyclone dx read SBOM hook implementation Add CycloneDX read SBOM hook implementation Aug 26, 2025
@github-actions
Copy link

github-actions bot commented Aug 26, 2025

🧪 SBOM Results (15/15)

❗️ mach_o_dylib_test_no1 (Link)

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 127, in generate_sbom_string
    ctx.invoke(
  File "/opt/hostedtoolcache/Python/3.10.18/x64/lib/python3.10/site-packages/click/core.py", line 814, in invoke
    return callback(*args, **kwargs)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/cmd/generate.py", line 303, in sbom
    new_sbom = input_reader.read_sbom(input_sbom)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/input_readers/cytrics_reader.py", line 14, in read_sbom
    return SBOM.from_json(infile.read())
AttributeError: 'Sentinel' object has no attribute 'read'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 251, in test_gha
    new_data["sbom"] = generate_sbom_string(
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 133, in generate_sbom_string
    raise RuntimeError(f"Failed to invoke SBOM generation: {e}") from e
RuntimeError: Failed to invoke SBOM generation: 'Sentinel' object has no attribute 'read'

❗️ sample_sboms (Link)

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 127, in generate_sbom_string
    ctx.invoke(
  File "/opt/hostedtoolcache/Python/3.10.18/x64/lib/python3.10/site-packages/click/core.py", line 814, in invoke
    return callback(*args, **kwargs)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/cmd/generate.py", line 303, in sbom
    new_sbom = input_reader.read_sbom(input_sbom)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/input_readers/cytrics_reader.py", line 14, in read_sbom
    return SBOM.from_json(infile.read())
AttributeError: 'Sentinel' object has no attribute 'read'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 251, in test_gha
    new_data["sbom"] = generate_sbom_string(
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 133, in generate_sbom_string
    raise RuntimeError(f"Failed to invoke SBOM generation: {e}") from e
RuntimeError: Failed to invoke SBOM generation: 'Sentinel' object has no attribute 'read'

❗️ Windows_dll_test_no1 (Link)

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 127, in generate_sbom_string
    ctx.invoke(
  File "/opt/hostedtoolcache/Python/3.10.18/x64/lib/python3.10/site-packages/click/core.py", line 814, in invoke
    return callback(*args, **kwargs)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/cmd/generate.py", line 303, in sbom
    new_sbom = input_reader.read_sbom(input_sbom)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/input_readers/cytrics_reader.py", line 14, in read_sbom
    return SBOM.from_json(infile.read())
AttributeError: 'Sentinel' object has no attribute 'read'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 251, in test_gha
    new_data["sbom"] = generate_sbom_string(
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 133, in generate_sbom_string
    raise RuntimeError(f"Failed to invoke SBOM generation: {e}") from e
RuntimeError: Failed to invoke SBOM generation: 'Sentinel' object has no attribute 'read'

❗️ uimage_files (Link)

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 127, in generate_sbom_string
    ctx.invoke(
  File "/opt/hostedtoolcache/Python/3.10.18/x64/lib/python3.10/site-packages/click/core.py", line 814, in invoke
    return callback(*args, **kwargs)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/cmd/generate.py", line 303, in sbom
    new_sbom = input_reader.read_sbom(input_sbom)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/input_readers/cytrics_reader.py", line 14, in read_sbom
    return SBOM.from_json(infile.read())
AttributeError: 'Sentinel' object has no attribute 'read'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 251, in test_gha
    new_data["sbom"] = generate_sbom_string(
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 133, in generate_sbom_string
    raise RuntimeError(f"Failed to invoke SBOM generation: {e}") from e
RuntimeError: Failed to invoke SBOM generation: 'Sentinel' object has no attribute 'read'

❗️ NET_app_config_test_no1 (Link)

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 127, in generate_sbom_string
    ctx.invoke(
  File "/opt/hostedtoolcache/Python/3.10.18/x64/lib/python3.10/site-packages/click/core.py", line 814, in invoke
    return callback(*args, **kwargs)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/cmd/generate.py", line 303, in sbom
    new_sbom = input_reader.read_sbom(input_sbom)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/input_readers/cytrics_reader.py", line 14, in read_sbom
    return SBOM.from_json(infile.read())
AttributeError: 'Sentinel' object has no attribute 'read'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 251, in test_gha
    new_data["sbom"] = generate_sbom_string(
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 133, in generate_sbom_string
    raise RuntimeError(f"Failed to invoke SBOM generation: {e}") from e
RuntimeError: Failed to invoke SBOM generation: 'Sentinel' object has no attribute 'read'

❗️ java_class_no1 (Link)

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 127, in generate_sbom_string
    ctx.invoke(
  File "/opt/hostedtoolcache/Python/3.10.18/x64/lib/python3.10/site-packages/click/core.py", line 814, in invoke
    return callback(*args, **kwargs)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/cmd/generate.py", line 303, in sbom
    new_sbom = input_reader.read_sbom(input_sbom)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/input_readers/cytrics_reader.py", line 14, in read_sbom
    return SBOM.from_json(infile.read())
AttributeError: 'Sentinel' object has no attribute 'read'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 251, in test_gha
    new_data["sbom"] = generate_sbom_string(
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 133, in generate_sbom_string
    raise RuntimeError(f"Failed to invoke SBOM generation: {e}") from e
RuntimeError: Failed to invoke SBOM generation: 'Sentinel' object has no attribute 'read'

❗️ mac_os_dmg (Link)

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 127, in generate_sbom_string
    ctx.invoke(
  File "/opt/hostedtoolcache/Python/3.10.18/x64/lib/python3.10/site-packages/click/core.py", line 814, in invoke
    return callback(*args, **kwargs)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/cmd/generate.py", line 303, in sbom
    new_sbom = input_reader.read_sbom(input_sbom)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/input_readers/cytrics_reader.py", line 14, in read_sbom
    return SBOM.from_json(infile.read())
AttributeError: 'Sentinel' object has no attribute 'read'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 251, in test_gha
    new_data["sbom"] = generate_sbom_string(
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 133, in generate_sbom_string
    raise RuntimeError(f"Failed to invoke SBOM generation: {e}") from e
RuntimeError: Failed to invoke SBOM generation: 'Sentinel' object has no attribute 'read'

❗️ cd_iso_files (Link)

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 127, in generate_sbom_string
    ctx.invoke(
  File "/opt/hostedtoolcache/Python/3.10.18/x64/lib/python3.10/site-packages/click/core.py", line 814, in invoke
    return callback(*args, **kwargs)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/cmd/generate.py", line 303, in sbom
    new_sbom = input_reader.read_sbom(input_sbom)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/input_readers/cytrics_reader.py", line 14, in read_sbom
    return SBOM.from_json(infile.read())
AttributeError: 'Sentinel' object has no attribute 'read'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 251, in test_gha
    new_data["sbom"] = generate_sbom_string(
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 133, in generate_sbom_string
    raise RuntimeError(f"Failed to invoke SBOM generation: {e}") from e
RuntimeError: Failed to invoke SBOM generation: 'Sentinel' object has no attribute 'read'

❗️ ELF_shared_obj_test_no1 (Link)

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 127, in generate_sbom_string
    ctx.invoke(
  File "/opt/hostedtoolcache/Python/3.10.18/x64/lib/python3.10/site-packages/click/core.py", line 814, in invoke
    return callback(*args, **kwargs)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/cmd/generate.py", line 303, in sbom
    new_sbom = input_reader.read_sbom(input_sbom)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/input_readers/cytrics_reader.py", line 14, in read_sbom
    return SBOM.from_json(infile.read())
AttributeError: 'Sentinel' object has no attribute 'read'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 251, in test_gha
    new_data["sbom"] = generate_sbom_string(
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 133, in generate_sbom_string
    raise RuntimeError(f"Failed to invoke SBOM generation: {e}") from e
RuntimeError: Failed to invoke SBOM generation: 'Sentinel' object has no attribute 'read'

❗️ msitest_no1 (Link)

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 127, in generate_sbom_string
    ctx.invoke(
  File "/opt/hostedtoolcache/Python/3.10.18/x64/lib/python3.10/site-packages/click/core.py", line 814, in invoke
    return callback(*args, **kwargs)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/cmd/generate.py", line 303, in sbom
    new_sbom = input_reader.read_sbom(input_sbom)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/input_readers/cytrics_reader.py", line 14, in read_sbom
    return SBOM.from_json(infile.read())
AttributeError: 'Sentinel' object has no attribute 'read'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 251, in test_gha
    new_data["sbom"] = generate_sbom_string(
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 133, in generate_sbom_string
    raise RuntimeError(f"Failed to invoke SBOM generation: {e}") from e
RuntimeError: Failed to invoke SBOM generation: 'Sentinel' object has no attribute 'read'

❗️ srectest_no1 (Link)

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 127, in generate_sbom_string
    ctx.invoke(
  File "/opt/hostedtoolcache/Python/3.10.18/x64/lib/python3.10/site-packages/click/core.py", line 814, in invoke
    return callback(*args, **kwargs)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/cmd/generate.py", line 303, in sbom
    new_sbom = input_reader.read_sbom(input_sbom)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/input_readers/cytrics_reader.py", line 14, in read_sbom
    return SBOM.from_json(infile.read())
AttributeError: 'Sentinel' object has no attribute 'read'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 251, in test_gha
    new_data["sbom"] = generate_sbom_string(
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 133, in generate_sbom_string
    raise RuntimeError(f"Failed to invoke SBOM generation: {e}") from e
RuntimeError: Failed to invoke SBOM generation: 'Sentinel' object has no attribute 'read'

❗️ a_out_files (Link)

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 127, in generate_sbom_string
    ctx.invoke(
  File "/opt/hostedtoolcache/Python/3.10.18/x64/lib/python3.10/site-packages/click/core.py", line 814, in invoke
    return callback(*args, **kwargs)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/cmd/generate.py", line 303, in sbom
    new_sbom = input_reader.read_sbom(input_sbom)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/input_readers/cytrics_reader.py", line 14, in read_sbom
    return SBOM.from_json(infile.read())
AttributeError: 'Sentinel' object has no attribute 'read'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 251, in test_gha
    new_data["sbom"] = generate_sbom_string(
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 133, in generate_sbom_string
    raise RuntimeError(f"Failed to invoke SBOM generation: {e}") from e
RuntimeError: Failed to invoke SBOM generation: 'Sentinel' object has no attribute 'read'

❗️ zstandard (Link)

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 127, in generate_sbom_string
    ctx.invoke(
  File "/opt/hostedtoolcache/Python/3.10.18/x64/lib/python3.10/site-packages/click/core.py", line 814, in invoke
    return callback(*args, **kwargs)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/cmd/generate.py", line 303, in sbom
    new_sbom = input_reader.read_sbom(input_sbom)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/input_readers/cytrics_reader.py", line 14, in read_sbom
    return SBOM.from_json(infile.read())
AttributeError: 'Sentinel' object has no attribute 'read'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 251, in test_gha
    new_data["sbom"] = generate_sbom_string(
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 133, in generate_sbom_string
    raise RuntimeError(f"Failed to invoke SBOM generation: {e}") from e
RuntimeError: Failed to invoke SBOM generation: 'Sentinel' object has no attribute 'read'

❗️ coff_files (Link)

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 127, in generate_sbom_string
    ctx.invoke(
  File "/opt/hostedtoolcache/Python/3.10.18/x64/lib/python3.10/site-packages/click/core.py", line 814, in invoke
    return callback(*args, **kwargs)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/cmd/generate.py", line 303, in sbom
    new_sbom = input_reader.read_sbom(input_sbom)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/input_readers/cytrics_reader.py", line 14, in read_sbom
    return SBOM.from_json(infile.read())
AttributeError: 'Sentinel' object has no attribute 'read'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 251, in test_gha
    new_data["sbom"] = generate_sbom_string(
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 133, in generate_sbom_string
    raise RuntimeError(f"Failed to invoke SBOM generation: {e}") from e
RuntimeError: Failed to invoke SBOM generation: 'Sentinel' object has no attribute 'read'

❗️ cpio_files (Link)

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 127, in generate_sbom_string
    ctx.invoke(
  File "/opt/hostedtoolcache/Python/3.10.18/x64/lib/python3.10/site-packages/click/core.py", line 814, in invoke
    return callback(*args, **kwargs)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/cmd/generate.py", line 303, in sbom
    new_sbom = input_reader.read_sbom(input_sbom)
  File "/home/runner/work/Surfactant/Surfactant/surfactant/input_readers/cytrics_reader.py", line 14, in read_sbom
    return SBOM.from_json(infile.read())
AttributeError: 'Sentinel' object has no attribute 'read'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 251, in test_gha
    new_data["sbom"] = generate_sbom_string(
  File "/home/runner/work/Surfactant/Surfactant/scripts/regressions.py", line 133, in generate_sbom_string
    raise RuntimeError(f"Failed to invoke SBOM generation: {e}") from e
RuntimeError: Failed to invoke SBOM generation: 'Sentinel' object has no attribute 'read'

For commit bd2893e (Run 18302866834)
Compared against commit bb99f5d (Run 18290057572)
⚠️ Requested SHA f2e17da did not have a matching run. Used bb99f5d instead.

@wangmot
Copy link
Collaborator

wangmot commented Oct 7, 2025

cyclonedx_reader.py script is not finished yet and is still a bit rough. Most cyclonedx fields in the components section are mapped out with comments and some example extraction code. Cyclonedx's services section and vulnerabilities section still need mapping. There are some obscure fields in the cyclonedx format that may not be completely necessary to be mapped so up to the dev's discretion.

Some notes:
-Ran into some serialization issues with objects
-script needs more testing with sample cyclonedx SBOMs with as many fields as possible
-code could be refactored for readability and reusability (ex. helper functions)

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants