Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Release

on:
push:
tags:
- 'v*'

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies and build
run: |
npm ci
npm run build

- name: Publish to NPM
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
64 changes: 64 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Validate

on:
pull_request:
branches: [main]

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '24'
cache: 'npm'

- run: npm ci
- run: npm run lint

build:
name: Build (Node ${{ matrix.node-version }})
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22, 24]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- run: npm ci
- run: npm run build

test:
name: Test (Node ${{ matrix.node-version }})
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22, 24]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- run: npm ci
- run: npm run test

format:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '24'
cache: 'npm'

- run: npm ci
- run: npm run format:check
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
.claude
.gemini
.kiro

dist
node_modules
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24
3 changes: 3 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"plugins": ["typescript", "unicorn", "oxc", "node", "promise"]
}
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fixtures/**/*
schemas/**/*
src/types/bom/**/*
5 changes: 5 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"objectWrap": "collapse",
"overrides": [{ "files": "*.json", "options": { "objectWrap": "preserve" } }]
}
27 changes: 27 additions & 0 deletions CONTRIBUTING
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Development

### Building

```bash
npm run build
```

### Testing

```bash
npm test
```

### Linting

```bash
npm run lint
npm run lint:fix
```

### Formatting

```bash
npm run format:check
npm run format:write
```
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright (c) 2025 HeroDevs, Inc

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
88 changes: 88 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# @herodevs/eol-shared

A TypeScript utility library for End-of-Life (EOL) scanning and analysis.

## Installation

```bash
npm install @herodevs/eol-shared
```

## Requirements

- Node.js 22 or higher

## API

### [`spdxToCdxBom(spdxBom: SPDX23): CdxBom`](./src/spdx-to-cdx.mts#L61)

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.

```typescript
import { spdxToCdxBom } from '@herodevs/eol-shared';
import type { CdxBom } from '@herodevs/eol-shared';

const spdxBom = {
/* your SPDX BOM data */
};
const cdxBom: CdxBom = spdxToCdxBom(spdxBom);
```

**Parameters**: `spdxBom` - The SPDX BOM object to convert
**Returns**: A CycloneDX BOM object

### [`xmlStringToJSON(xmlString: string): CdxBom`](./src/cdx-xml-to-json.mts#L161)

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.

```typescript
import { xmlStringToJSON } from '@herodevs/eol-shared';
import type { CdxBom } from '@herodevs/eol-shared';

const xmlString = `<?xml version="1.0"?>...`;
const jsonBom: CdxBom = xmlStringToJSON(xmlString);
```

**Parameters**: `xmlString` - The XML string to parse
**Returns**: The parsed CycloneDX BOM object

### [`trimCdxBom(cdxBom: CdxBom): CdxBom`](./src/trim-cdx-bom.mts#L3)

Creates a trimmed copy of a CycloneDX BOM by removing SBOM data not necessary for EOL scanning:

- `externalReferences` from components
- `evidence` from components
- `hashes` from components
- `properties` from components

```typescript
import { trimCdxBom } from '@herodevs/eol-shared';
import type { CdxBom } from '@herodevs/eol-shared';

const originalBom: CdxBom = {
/* your CycloneDX BOM */
};
const trimmedBom: CdxBom = trimCdxBom(originalBom);
```

**Parameters**: `cdxBom` - The CycloneDX BOM to trim
**Returns**: A new trimmed CycloneDX BOM object

### Types

The package exports the following TypeScript types:

- `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)
- `Component` - Component definition
- `Dependency` - Dependency relationship
- `Hash` - Hash/checksum information
- `License` - License information
- `ExternalReference` - External reference data
- `ComponentScope` - Component scope enumeration

## Resources

This package is designed to work with:

- [CycloneDX](https://cyclonedx.org/) - Industry standard for Software Bill of Materials
- [SPDX](https://spdx.dev/) - Software Package Data Exchange standard
1 change: 1 addition & 0 deletions fixtures/cdx-bom-examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sourced from https://github.com/CycloneDX/bom-examples/tree/master/SBOM/juice-shop/via_npm/bare
Loading