SBOMgensbomgen

Title

Introduction

This tutorial illustrates how to produce an SBOM from Webpack projects using the CycloneDX-Webpack plugin.

Requirements

Installation

Run the relevant command within your project:

Npm

npm i -D @cyclonedx/webpack-plugin

Yarn

yarn add -D @cyclonedx/webpack-plugin

Usage

In your webpack.config.json file, add the following code blocks:

const { CycloneDxWebpackPlugin } = require('@cyclonedx/webpack-plugin');

/** @type {import('@cyclonedx/webpack-plugin').CycloneDxWebpackPluginOptions} */
const cycloneDxWebpackPluginOptions = {
  specVersion: '1.6', 
  reproducibleResults: false,
  outputLocation: './bom', //can be customized
  includeWellknown: true,
  wellknownLocation: './.well-known', //generate SBOM to a well known location 
  rootComponentAutodetect: true, //set to false if you wish to set rootComponent manually.
  rootComponentType: 'application', 
  rootComponentName: undefined, //define if you wish to set rootComponent manually.
  rootComponentVersion: undefined, //define if you wish to set rootComponent manually.
  rootComponentBuildSystem: undefined, //define if you wish to set rootComponent manually.
  rootComponentVCS: undefined, //define if you wish to set rootComponent manually.
  collectEvidence: true
}

within the module.exports section, add the following plugins: section:

module.exports = {
  // other code goes here
  plugins: [
    new CycloneDxWebpackPlugin(cycloneDxWebpackPluginOptions)
  ]
}

Build the project, and a directory of the outputLocation: value (in this case, bom/) directory should appear in your build dist/ directory, containing SBOMs bom.json and bom.xml.

Further features to the SBOM root component, e.g. name, version, build system, version control can be implemented by customizing the rootComponent* variables, after setting rootComponentAutodetect: to false.

Notes

Example SBOM

This section illustrates CycloneDX JSON and XML SBOMs of the CycloneDX-Webpack plugin simple example code, created via CycloneDX-Webpack plugin.

Pretty JSON Display

Simple Example (JSON)


    

Simple Example (XML)


    

References