This project provides a library for working with CPE strings in JavaScript. Currently, it supports interpreting CPE 2.3 URI formatted CPE strings, but the grammar for WFN is already implemented.
The primary functions are creating a CPE object by CPE string, and returning the various component parts.
It also supports providing a dictionary of supported values and returning a valid CPE URI string.
To install this library into your project, you'll need to manually reference the github repository.
npm install https://github.com/cbarnard-r7/cpe-js
npm install
Run tests with the following command
npm test
For code coverage run
npm run coverage
const { CPE2_3_URI } = require('cpe');
// Prints "cpe:/a:foo"
console.log(
CPE2_3_URI.generateCpeStringFromAttributes(
{
part: "a",
vendor: "foo"
}
));
// Returns "bar"
CPE2_3_URI("cpe:/a:bar").getAttributeValues("vendor")