Skip to contentSkip to conversation

Add a SBOM template in CycloneDX format

PATCH New Richard Hughes 3 participants 8 messages Dec 9, 2024

lore
Share & tools
lore
#0 lore raw

cover Add a SBOM template in CycloneDX format

Hi,

My name is Richard Hughes and I'm a developer at Red Hat. I'm the maintainer of fwupd and LVFS, and am trying to improve software supply chain security by encouraging OEMs, ODMs and IBVs to ship Software Bill of Materials with each firmware binary blob (SBOMs).

I'm working alongside lots of other companies proactively trying to do the right thing. The reason I've opened this pull request is because your project is either used in the build process of a firmware we care about (e.g. EDK II, or coreboot) or is built into the firmware binary itself. Although my personal focus is on firmware, the SBOM file is in CycloneDX format (one of the most popular industry standards) which makes it also useful when building containers or OS images too.

I would like to contribute this template SBOM file into your project that gets included into source control with substituted values that get populated automatically. I'm not super familiar with OpenSBI, and so I've done my best populating the project values -- but please point out any that are incorrect and I'll fix them up. I've also put the sbom.cdx.json file in what I feel is the right place, but please say if you want me to put it somewhere different or name it a different thing; the directory and sbom prefix are unimportant.

I couldn?t find any existing CVEs that reference your project, so I?ve created a CPE reference that seems plausible. Please let me know if you know of a better CPE to use.

The various firmware build tools will take these incomplete SBOM files and then build them into a complete composite SBOM to represent the firmware. Having an upstream reference to what the PURL and CPE values should be means we have something we can trust; I could quite easily spin up a web-service that we say "what CPE do we use for X" -> cpe:2.3:a:Y:Z:::::::: but we don't actually know if that's still true, up to date, or what the supplier actually wants them to be. Putting the template upstream means we can trust the values we find in the checked out code during the build process.

I've written a bit more about this proposal here https://blogs.gnome.org/hughsie/2024/11/14/firmware-sboms-for-open-source-projects/ and there's also lot more information about firmware SBOMs here: https://lvfs.readthedocs.io/en/latest/sbom.html ? many thanks for your time.

Richard Hughes (1):
Add a SBOM template in CycloneDX format

 docs/sbom.cdx.json | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 docs/sbom.cdx.json
Signature · 1 line
2.47.1
#1 lore raw

PATCH 1/1 Add a SBOM template in CycloneDX format

Improve supply chain security by including a SBOM file with substituted values.

This will be used to construct a composite platform SBOM.

---
 docs/sbom.cdx.json | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 docs/sbom.cdx.json
docs/sbom.cdx.json new file +43 -0
new file mode 100644
index 0000000..d300807
@@ -0,0 +1,43 @@
+{
+  "bomFormat": "CycloneDX",
+  "specVersion": "1.6",
+  "version": 1,
+  "metadata": {
+    "authors": [
+      {
+        "name": "@VCS_SBOM_AUTHORS@"
+      }
+    ]
+  },
+  "components": [
+    {
+      "type": "library",
+      "bom-ref": "pkg:github/riscv-software-src/opensbi@@VCS_TAG@",
+      "cpe": "cpe:2.3:a:riscv:opensbi:@VCS_TAG@:*:*:*:*:*:*:*",
+      "name": "OpenSBI",
+      "version": "@VCS_VERSION@",
+      "description": "Open Source Supervisor Binary Interface for RISC-V",
+      "authors": [
+        {
+          "name": "@VCS_AUTHORS@"
+        }
+      ],
+      "supplier": {
+        "name": "RISC-V Foundation"
+      },
+      "licenses": [
+        {
+          "license": {
+            "id": "BSD-2-Clause"
+          }
+        }
+      ],
+      "externalReferences": [
+        {
+          "type": "vcs",
+          "url": "https://github.com/riscv-software-src/opensbi"
+        }
+      ]
+    }
+  ]
+}
Signature · 1 line
2.47.1
#2 lore raw

PATCH 1/1 Add a SBOM template in CycloneDX format

Quoted 17 lines · Richard Hughes

Improve supply chain security by including a SBOM file with substituted values.

This will be used to construct a composite platform SBOM.

---
docs/sbom.cdx.json | 43 +++++++++++++++++++++++++++++++++++++++++++

1 file changed, 43 insertions(+)

create mode 100644 docs/sbom.cdx.json

docs/sbom.cdx.json new file +0 -0
new file mode 100644
index 0000000..d300807

docs/sbom.cdx.json line 8

Quoted 8 lines
docs/sbom.cdx.json new file +8 -0
@@ -0,0 +1,43 @@
+{
+  "bomFormat": "CycloneDX",
+  "specVersion": "1.6",
+  "version": 1,
+  "metadata": {
+    "authors": [
+      {
+        "name": "@VCS_SBOM_AUTHORS@"

What turns this template into the actual file? And surely this isn?t the right templating for a list here? A set of authors is not a singular author?s name.

Jess

Quoted 43 lines
docs/sbom.cdx.json new file +35 -0
+      }
+    ]
+  },
+  "components": [
+    {
+      "type": "library",
+      "bom-ref": "pkg:github/riscv-software-src/opensbi@@VCS_TAG@",
+      "cpe": "cpe:2.3:a:riscv:opensbi:@VCS_TAG@:*:*:*:*:*:*:*",
+      "name": "OpenSBI",
+      "version": "@VCS_VERSION@",
+      "description": "Open Source Supervisor Binary Interface for RISC-V",
+      "authors": [
+        {
+          "name": "@VCS_AUTHORS@"
+        }
+      ],
+      "supplier": {
+        "name": "RISC-V Foundation"
+      },
+      "licenses": [
+        {
+          "license": {
+            "id": "BSD-2-Clause"
+          }
+        }
+      ],
+      "externalReferences": [
+        {
+          "type": "vcs",
+          "url": "https://github.com/riscv-software-src/opensbi"
+        }
+      ]
+    }
+  ]
+}
Signature · 7 lines
2.47.1


-- 
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
#3 lore raw

PATCH 1/1 Add a SBOM template in CycloneDX format

Quoted 3 lines · Jessica Clarke

What turns this template into the actual file? And surely this isn?t the right templating for a list here? A set of authors is not a singular author?s name.

Right, agreed. The way this works now is that we do a recursive clone of all the firmware components when building either EDK II or coreboot, and then we use a tool called uswid to "find" all the SBOM components and populate the tokenized values automatically. I've written a bit about it here: https://blogs.gnome.org/hughsie/2024/11/14/firmware-sboms-for-open-source-projects/

In the case of OpenSBI the finished component looks like this:

    {
      "type": "library",
      "cpe": "cpe:2.3:a:riscv:opensbi:1.5.1:*:*:*:*:*:*:*",
      "name": "OpenSBI",
      "version": "1.5.1",
      "description": "Open Source Supervisor Binary Interface for RISC-V",
      "bom-ref": "pkg:github/riscv-software-src/opensbi at 1.5.1",
      "externalReferences": [
        {
          "type": "vcs",
          "url": "https://github.com/riscv-software-src/opensbi"
        }
      ],
      "licenses": [
        {
          "license": {
            "url": "https://spdx.org/licenses/BSD-2-Clause.html",
            "id": "BSD-2-Clause"
          }
        }
      ],
      "supplier": {
        "name": "RISC-V Foundation"
      },
      "authors": [
        {
          "name": "Anup Patel, Atish Patra, Bin Meng, Samuel Holland, Xiang W, Damien Le Moal, Heinrich Schuchardt, Yu Chien Peter Lin, Himanshu Chauhan, Inochi Amaoto, Alistair Francis, Andrew Jones, Cl?ment L?ger, Mayuresh Chitale, Nikita Shubin, Vivian Wang, Rahul Pathak, Ivan Orlov, Lad Prabhakar, Jessica Clarke, Xiang Wang, Abner Chang, Ben Zong-You Xie, Guo Ren, Liu Yibin, Nylon Chen, Bo Gan, Dong Du, Olof Johansson, Daniel Schaefer, Jan Remes, Nam Cao, Nick Kossifidis"
        }
      ]
    }

Richard

#4 lore raw

PATCH 1/1 Add a SBOM template in CycloneDX format

Quoted 7 lines · Richard Hughes
Quoted 3 lines · Jessica Clarke

What turns this template into the actual file? And surely this isn?t the right templating for a list here? A set of authors is not a singular author?s name.

Right, agreed. The way this works now is that we do a recursive clone of all the firmware components when building either EDK II or coreboot, and then we use a tool called uswid to "find" all the SBOM components and populate the tokenized values automatically. I've written a bit about it here: https://blogs.gnome.org/hughsie/2024/11/14/firmware-sboms-for-open-source-projects/

Should that not be part of the upstream build process for each project?

Quoted 23 lines

In the case of OpenSBI the finished component looks like this:

   {
     "type": "library",
     "cpe": "cpe:2.3:a:riscv:opensbi:1.5.1:*:*:*:*:*:*:*",
     "name": "OpenSBI",
     "version": "1.5.1",
     "description": "Open Source Supervisor Binary Interface for RISC-V",
     "bom-ref": "pkg:github/riscv-software-src/opensbi at 1.5.1",
     "externalReferences": [
       {
         "type": "vcs",
         "url": "https://github.com/riscv-software-src/opensbi"
       }
     ],
     "licenses": [
       {
         "license": {
           "url": "https://spdx.org/licenses/BSD-2-Clause.html",
           "id": "BSD-2-Clause"
         }
       }
     ],
Quoted 8 lines
     "supplier": {
       "name": "RISC-V Foundation"
     },
     "authors": [
       {
         "name": "Anup Patel, Atish Patra, Bin Meng, Samuel Holland, Xiang W, Damien Le Moal, Heinrich Schuchardt, Yu Chien Peter Lin, Himanshu Chauhan, Inochi Amaoto, Alistair Francis, Andrew Jones, Cl?ment L?ger, Mayuresh Chitale, Nikita Shubin, Vivian Wang, Rahul Pathak, Ivan Orlov, Lad Prabhakar, Jessica Clarke, Xiang Wang, Abner Chang, Ben Zong-You Xie, Guo Ren, Liu Yibin, Nylon Chen, Bo Gan, Dong Du, Olof Johansson, Daniel Schaefer, Jan Remes, Nam Cao, Nick Kossifidis"
       }
     ]

Should this not be:

"authors:" [
{ "name": "Anup Patel" },
{ "name": "Atish Patra" },
...
]

?

Otherwise why is there the outer list? (But just having JSON that?s a comma-separated string wouldn?t exactly be great, so removing the outer list isn?t a real solution).

Jess

Quoted 4 lines
   }

Richard

#5 lore raw

PATCH 1/1 Add a SBOM template in CycloneDX format

Quoted 2 lines · Jessica Clarke
Quoted 1 line

then we use a tool called uswid to "find" all the SBOM components and populate the tokenized values automatically

Should that not be part of the upstream build process for each project?

For coreboot, we could do that -- i.e. we'd build libpng, libhwbase (and any other deps) *then* coreboot -- and so it's perfectly fine to do this in the upstream build system. There's an example using meson in fwupd: https://github.com/fwupd/fwupd/blob/main/contrib/meson.build#L15 -- although I'd advise not doing this at this point.

For EDK II the upstream submodule build system typically isn't used at all, and so we can't rely on the subproject cmake/scons/whatever generating the post-processed file which we can absorb as part of the firmware build. Shipping the template seems a pragmatic first step, and means the open source software appears accurately on the SBOM HTML page of the OEM "binary" firmware.

Quoted 11 lines
Quoted 5 lines

"authors": [
{
"name": "Anup Patel, Atish Patra, Bin Meng, Samuel Holland, Xiang W, Damien Le Moal, Heinrich Schuchardt, Yu Chien Peter Lin, Himanshu Chauhan, Inochi Amaoto, Alistair Francis, Andrew Jones, Cl?ment L?ger, Mayuresh Chitale, Nikita Shubin, Vivian Wang, Rahul Pathak, Ivan Orlov, Lad Prabhakar, Jessica Clarke, Xiang Wang, Abner Chang, Ben Zong-You Xie, Guo Ren, Liu Yibin, Nylon Chen, Bo Gan, Dong Du, Olof Johansson, Daniel Schaefer, Jan Remes, Nam Cao, Nick Kossifidis" }
]

Should this not be:
"authors:" [
{ "name": "Anup Patel" },
{ "name": "Atish Patra" },
...
]

It certainly *could* be. We didn't do it like this as CycloneDX < v1.6 had just a single string field for the author (and SPDX is just the same), and we wanted to maintain compatibility between the different formats. If this is a blocker for inclusion let me know and I'll write some code in uswid to accept either style.

Richard.

#6 lore raw

PATCH 1/1 Add a SBOM template in CycloneDX format

Quoted 7 lines · Richard Hughes
Quoted 2 lines · Jessica Clarke
Quoted 1 line

then we use a tool called uswid to "find" all the SBOM components and populate the tokenized values automatically

Should that not be part of the upstream build process for each project?

For coreboot, we could do that -- i.e. we'd build libpng, libhwbase (and any other deps) *then* coreboot -- and so it's perfectly fine to do this in the upstream build system. There's an example using meson in fwupd: https://github.com/fwupd/fwupd/blob/main/contrib/meson.build#L15 -- although I'd advise not doing this at this point.

For EDK II the upstream submodule build system typically isn't used at all, and so we can't rely on the subproject cmake/scons/whatever generating the post-processed file which we can absorb as part of the firmware build. Shipping the template seems a pragmatic first step, and means the open source software appears accurately on the SBOM HTML page of the OEM "binary" firmware.

I don?t mean you *have* to use it that way in consumers. Just that if you?re adding the file to upstream projects you should do the work to integrate it into their build systems so others can benefit. You wouldn?t add a C source file that wasn?t built by the Makefile even if your project wasn?t using the upstream Makefiles, so don?t do the same for other resources.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

"authors": [
{
"name": "Anup Patel, Atish Patra, Bin Meng, Samuel Holland, Xiang W, Damien Le Moal, Heinrich Schuchardt, Yu Chien Peter Lin, Himanshu Chauhan, Inochi Amaoto, Alistair Francis, Andrew Jones, Cl?ment L?ger, Mayuresh Chitale, Nikita Shubin, Vivian Wang, Rahul Pathak, Ivan Orlov, Lad Prabhakar, Jessica Clarke, Xiang Wang, Abner Chang, Ben Zong-You Xie, Guo Ren, Liu Yibin, Nylon Chen, Bo Gan, Dong Du, Olof Johansson, Daniel Schaefer, Jan Remes, Nam Cao, Nick Kossifidis" }
]

Quoted 8 lines
Quoted 6 lines

Should this not be:
"authors:" [
{ "name": "Anup Patel" },
{ "name": "Atish Patra" },
...
]

It certainly *could* be. We didn't do it like this as CycloneDX < v1.6 had just a single string field for the author (and SPDX is just the same), and we wanted to maintain compatibility between the different formats. If this is a blocker for inclusion let me know and I'll write some code in uswid to accept either style.

IMO the single string field is better than this nonsense format that claims to be a list of authors but is a list of a single author (what happens when you have SBOMs that really do have lists of authors and you now interpret this as being an author called ?Anup ? Kossifidis??). But better still would be doing the proper thing and having a list of author objects, so ideally extend your tooling to support the new format rather than pretend it doesn?t exist, and if you can?t do that then adopt the old format fully.

Jess

#7 lore raw

PATCH 1/1 Add a SBOM template in CycloneDX format

Quoted 3 lines · Jessica Clarke

I don?t mean you have to use it that way in consumers. Just that if you?re adding the file to upstream projects you should do the work to integrate it into their build systems so others can benefit.

Adding it to the upstream build system is pointless without installing or embedding the artifact somewhere. There was a murmuring of a proposal that we could install the dist'd post-processed file in something like /usr/share/sbom but the details are still being worked on and I don't think opensbi would be terribly useful in a docker image or as an rpm anyway.

Quoted 1 line

IMO the single string field is better than this nonsense format

Okay...

Quoted 4 lines

But better still would be doing the proper thing and having a list of author objects, so ideally extend your tooling to support the new format rather than pretend it doesn?t exist, and if you can?t do that then adopt the old format fully.

We do support multiple authors in the uSWID project, but only the SWID format and CycloneDX format >= 1.6 support it. I've attached a new patch without the authors sections, and uswid --fixup will auto-add the sections as required in the specific format.

Richard
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-a-SBOM-template-in-CycloneDX-format.patch
Type: text/x-patch
Size: 1459 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/opensbi/attachments/20241209/13d1f7f4/attachment-0001.bin>