Create CycloneDX Software Bill of Materials (SBOM) from npm projects.
The resulting SBOM documents follow official specifications and standards,
and might have properties following cdx:npm
Namespace Taxonomy
.
node
>=14
npm
in range6 - 9
There are multiple methods for installing this tool:
-
As a global tool ala
npm
:npm install --global @cyclonedx/cyclonedx-npm
-
As a global tool ala
npx
:npx --package @cyclonedx/cyclonedx-npm --call exit
-
As a development dependency of the current projects:
npm install --save-dev @cyclonedx/cyclonedx-npm
Depending on the installation method, the following describes the proper usage:
-
If installed as a global tool ala
npm
:cyclonedx-npm --help
-
If installed as a global tool ala
npx
:
— or —
If installed as a development dependency of the current projects:npx @cyclonedx/cyclonedx-npm --help
The help page:
Usage: cyclonedx-npm [options] [--] [<package-manifest>]
Create CycloneDX Software Bill of Materials (SBOM) from Node.js NPM projects.
Arguments:
<package-manifest> Path to project's manifest file.
(default: "package.json" file in current working directory)
Options:
--ignore-npm-errors Whether to ignore errors of NPM.
This might be used, if "npm install" was run with "--force" or "--legacy-peer-deps".
(default: false)
--package-lock-only Whether to only use the lock file, ignoring "node_modules".
This means the output will be based only on the few details in and the tree described by the "npm-shrinkwrap.json" or "package-lock.json", rather than the contents of "node_modules" directory.
(default: false)
--omit <type...> Dependency types to omit from the installation tree.
(can be set multiple times)
(choices: "dev", "optional", "peer", default: "dev" if the NODE_ENV environment variable is set to "production", otherwise empty)
--flatten-components Whether to flatten the components.
This means the actual nesting of node packages is not represented in the SBOM result.
--short-PURLs Omit all qualifiers from PackageURLs.
This causes information loss in trade of shorter PURLs, which might improve digesting these strings.
(default: false)
--spec-version <version> Which version of CycloneDX spec to use.
(choices: "1.2", "1.3", "1.4", default: "1.4")
--output-reproducible Whether to go the extra mile and make the output reproducible.
This requires more resources, and might result in loss of time- and random-based-values.
(env: BOM_REPRODUCIBLE)
--output-format <format> Which output format to use.
(choices: "JSON", "XML", default: "JSON")
--output-file <file> Path to the output file.
Set to "-" to write to STDOUT.
(default: write to STDOUT)
--mc-type <type> Type of the main component.
(choices: "application", "firmware", "library", default: "application")
-V, --version output the version number
-h, --help display help for command
For a demo of cyclonedx-npm see the demo project.
This tool utilizes npm
to collect evidences of installed packages/modules.
Read more in the dedicated docs.
This tool does not do artificial deduplication. Therefore, if a component is installed multiple times, it appears multiple times in the SBOM result. Read more on the topic in the dedicated docs "Component Deduplication".
This tool utilizes the CycloneDX library to generate the actual data structures.
This tool does not expose any additional public API or classes - all code is intended to be internal and might change without any notice during version upgrades.
Feel free to open issues, bugreports or pull requests.
See the CONTRIBUTING file for details.
Permission to modify and redistribute is granted under the terms of the Apache 2.0 license.
See the LICENSE file for the full license.