@deluksic/cyclonedx-npm
v1.14.0
Published
Create CycloneDX Software Bill of Materials (SBOM) from NPM projects.
Downloads
122
Maintainers
Readme
cyclonedx-npm
Create CycloneDX Software Bill of Materials (SBOM) from npm projects.
Based on OWASP Software Component Verification Standard for Software Bill of Materials's criteria, this tool is capable of producing SBOM documents almost passing Level-2 (only signing needs to be done externally).
The resulting SBOM documents follow official specifications and standards,
and might have properties following cdx:npm
Namespace Taxonomy
.
Requirements
node
>=14
npm
in range6 - 9
Installation
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
Usage
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.
(default: false)
--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)
--validate Validate resulting BOM before outputting. Validation is skipped, if requirements not met.
(default: true)
--no-validate Disable validation of resulting BOM.
--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
Demo
For a demo of cyclonedx-npm see the demo project.
How it works
This tool utilizes npm to collect evidences of installed packages/modules. Read more in the dedicated docs.
The appropriate npm executable is detected automatically, yet can be overridden with the environment variable npm_execpath
.
Autodetect: If called from npm
/npx
context, then the current npm executable is utilized, otherwise it is managed by SHELL and PATH.
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".
Internals
This tool utilizes the CycloneDX library to generate the actual data structures, and serialize and validate them.
Validation requires transitive optional dependencies.
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.
Contributing
Feel free to open issues, bugreports or pull requests.
See the CONTRIBUTING file for details.
License
Permission to modify and redistribute is granted under the terms of the Apache 2.0 license.
See the LICENSE file for the full license.