|
| 1 | +# @herodevs/eol-shared |
| 2 | + |
| 3 | +A TypeScript utility library for End-of-Life (EOL) scanning and analysis. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +```bash |
| 8 | +npm install @herodevs/eol-shared |
| 9 | +``` |
| 10 | + |
| 11 | +## Requirements |
| 12 | + |
| 13 | +- Node.js 22 or higher |
| 14 | + |
| 15 | +## API |
| 16 | + |
| 17 | +### [`spdxToCdxBom(spdxBom: SPDX23): CdxBom`](./src/spdx-to-cdx.mts#L61) |
| 18 | + |
| 19 | +Converts an SPDX BOM to CycloneDX format. This conversion takes the most important package and relationship data from SPDX and translates them into CycloneDX components and dependencies as closely as possible. |
| 20 | + |
| 21 | +```typescript |
| 22 | +import { spdxToCdxBom } from '@herodevs/eol-shared'; |
| 23 | +import type { CdxBom } from '@herodevs/eol-shared'; |
| 24 | + |
| 25 | +const spdxBom = { |
| 26 | + /* your SPDX BOM data */ |
| 27 | +}; |
| 28 | +const cdxBom: CdxBom = spdxToCdxBom(spdxBom); |
| 29 | +``` |
| 30 | + |
| 31 | +**Parameters**: `spdxBom` - The SPDX BOM object to convert |
| 32 | +**Returns**: A CycloneDX BOM object |
| 33 | + |
| 34 | +### [`xmlStringToJSON(xmlString: string): CdxBom`](./src/cdx-xml-to-json.mts#L161) |
| 35 | + |
| 36 | +Converts a CycloneDX XML string to a JSON object. The CycloneDX spec does not change between formats, so conversion from XML to JSON is lossless. |
| 37 | + |
| 38 | +```typescript |
| 39 | +import { xmlStringToJSON } from '@herodevs/eol-shared'; |
| 40 | +import type { CdxBom } from '@herodevs/eol-shared'; |
| 41 | + |
| 42 | +const xmlString = `<?xml version="1.0"?>...`; |
| 43 | +const jsonBom: CdxBom = xmlStringToJSON(xmlString); |
| 44 | +``` |
| 45 | + |
| 46 | +**Parameters**: `xmlString` - The XML string to parse |
| 47 | +**Returns**: The parsed CycloneDX BOM object |
| 48 | + |
| 49 | +### [`trimCdxBom(cdxBom: CdxBom): CdxBom`](./src/trim-cdx-bom.mts#L3) |
| 50 | + |
| 51 | +Creates a trimmed copy of a CycloneDX BOM by removing SBOM data not necessary for EOL scanning: |
| 52 | + |
| 53 | +- `externalReferences` from components |
| 54 | +- `evidence` from components |
| 55 | +- `hashes` from components |
| 56 | +- `properties` from components |
| 57 | + |
| 58 | +```typescript |
| 59 | +import { trimCdxBom } from '@herodevs/eol-shared'; |
| 60 | +import type { CdxBom } from '@herodevs/eol-shared'; |
| 61 | + |
| 62 | +const originalBom: CdxBom = { |
| 63 | + /* your CycloneDX BOM */ |
| 64 | +}; |
| 65 | +const trimmedBom: CdxBom = trimCdxBom(originalBom); |
| 66 | +``` |
| 67 | + |
| 68 | +**Parameters**: `cdxBom` - The CycloneDX BOM to trim |
| 69 | +**Returns**: A new trimmed CycloneDX BOM object |
| 70 | + |
| 71 | +### Types |
| 72 | + |
| 73 | +The package exports the following TypeScript types: |
| 74 | + |
| 75 | +- `CdxBom` - CycloneDX BOM structure as exported from [`@cyclonedx/cyclonedx-library`](https://github.com/CycloneDX/cyclonedx-javascript-library/blob/447db28f47ffd03b6f9c2f4a450bef0f0392c6bb/src/serialize/json/types.ts#L76) |
| 76 | +- `Component` - Component definition |
| 77 | +- `Dependency` - Dependency relationship |
| 78 | +- `Hash` - Hash/checksum information |
| 79 | +- `License` - License information |
| 80 | +- `ExternalReference` - External reference data |
| 81 | +- `ComponentScope` - Component scope enumeration |
| 82 | + |
| 83 | +## Resources |
| 84 | + |
| 85 | +This package is designed to work with: |
| 86 | + |
| 87 | +- [CycloneDX](https://cyclonedx.org/) - Industry standard for Software Bill of Materials |
| 88 | +- [SPDX](https://spdx.dev/) - Software Package Data Exchange standard |
0 commit comments