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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ npm install github:herodevs/eol-shared

## API

### [`spdxToCdxBom(spdxBom: SPDX23): CdxBom`](./src/spdx-to-cdx.mts#L61)
### [`spdxToCdxBom(spdxBom: SPDX23): CdxBom`](./src/spdx-to-cdx.ts#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.

Expand All @@ -31,7 +31,7 @@ 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)
### [`xmlStringToJSON(xmlString: string): CdxBom`](./src/cdx-xml-to-json.ts#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.

Expand All @@ -46,7 +46,7 @@ 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)
### [`trimCdxBom(cdxBom: CdxBom): CdxBom`](./src/trim-cdx-bom.ts#L3)

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

Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
],
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.mjs",
"types": "./dist/index.d.mts"
"import": "./dist/index.js",
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
}
},
"main": "./dist/index.mjs",
"types": "./dist/index.d.mts",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"repository": {
"type": "git",
"url": "git+https://github.com/herodevs/eol-shared.git"
Expand Down
2 changes: 1 addition & 1 deletion src/bom/validation.mts → src/bom/validation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { SPDX23 } from '../types/bom/spdx-2.3.schema.ts';
import type { CdxBom, SupportedBom } from '../types/index.mjs';
import type { CdxBom, SupportedBom } from '../types/index.js';

function parseBomOrString(bomOrString: string | object): SupportedBom | null {
if (typeof bomOrString === 'string') {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, describe } from 'node:test';
import { strict as assert } from 'node:assert';
import { readFile } from 'node:fs/promises';
import { xmlStringToJSON } from './cdx-xml-to-json.mts';
import { xmlStringToJSON } from './cdx-xml-to-json.ts';

describe('CycloneDX XML to JSON Converter', () => {
test('should convert CycloneDX 1.4 XML to JSON with correct structure', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/cdx-xml-to-json.mts → src/cdx-xml-to-json.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { XMLParser } from 'fast-xml-parser';
import type { CdxBom } from './index.mts';
import type { CdxBom } from './index.ts';

const COLLECTION_KEYS = [
'tools',
Expand Down
4 changes: 2 additions & 2 deletions src/eol/utils.test.mts → src/eol/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, describe } from 'node:test';
import { strict as assert } from 'node:assert';
import { deriveComponentStatus } from './utils.mts';
import type { EolScanComponentMetadata } from '../types/eol-scan.mts';
import { deriveComponentStatus } from './utils.ts';
import type { EolScanComponentMetadata } from '../types/eol-scan.ts';

describe('deriveComponentStatus', () => {
test('should return UNKNOWN when there is no metadata', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/eol/utils.mts → src/eol/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { PackageURL } from 'packageurl-js';
import type { CdxBom } from '../types/index.mjs';
import type { CdxBom } from '../types/index.js';
import type {
ComponentStatus,
EolScanComponentMetadata,
} from '../types/eol-scan.mjs';
} from '../types/eol-scan.js';

export function deriveComponentStatus(
metadata: EolScanComponentMetadata | null,
Expand Down
16 changes: 8 additions & 8 deletions src/index.mts → src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export { xmlStringToJSON } from './cdx-xml-to-json.mjs';
export { trimCdxBom } from './trim-cdx-bom.mjs';
export { spdxToCdxBom } from './spdx-to-cdx.mjs';
export { deriveComponentStatus, extractPurlsFromCdxBom } from './eol/utils.mjs';
export { xmlStringToJSON } from './cdx-xml-to-json.js';
export { trimCdxBom } from './trim-cdx-bom.js';
export { spdxToCdxBom } from './spdx-to-cdx.js';
export { deriveComponentStatus, extractPurlsFromCdxBom } from './eol/utils.js';

export type {
ComponentStatus,
Expand All @@ -14,7 +14,7 @@ export type {
EolReportQueryResponse,
EolReportMutationResponse,
NesRemediation,
} from './types/eol-scan.mjs';
} from './types/eol-scan.js';

export type {
CdxBom,
Expand All @@ -25,7 +25,7 @@ export type {
License,
SPDX23,
SupportedBom,
} from './types/index.mjs';
} from './types/index.js';

export { ComponentScope } from './types/index.mjs';
export { isCdxBom, isSpdxBom, isSupportedBom } from './bom/validation.mjs';
export { ComponentScope } from './types/index.js';
export { isCdxBom, isSpdxBom, isSupportedBom } from './bom/validation.js';
4 changes: 2 additions & 2 deletions src/spdx-to-cdx.test.mts → src/spdx-to-cdx.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { test, describe } from 'node:test';
import { strict as assert } from 'node:assert';
import { spdxToCdxBom } from './spdx-to-cdx.mts';
import { spdxToCdxBom } from './spdx-to-cdx.ts';
import type { SPDX23 } from './types/bom/spdx-2.3.schema.js';
import type { Component, Dependency } from './types/index.mts';
import type { Component, Dependency } from './types/index.ts';

function buildSpdxAndConvert(spdx: Partial<SPDX23>) {
const baseSpdx: SPDX23 = {
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/trim-cdx-bom.test.mts → src/trim-cdx-bom.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, describe } from 'node:test';
import { strict as assert } from 'node:assert';
import { trimCdxBom } from './trim-cdx-bom.mts';
import type { CdxBom } from './types/index.mts';
import { trimCdxBom } from './trim-cdx-bom.ts';
import type { CdxBom } from './types/index.ts';
import { Enums } from '@cyclonedx/cyclonedx-library';

describe('trimCdxBom', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/trim-cdx-bom.mts → src/trim-cdx-bom.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CdxBom } from './types/index.mts';
import type { CdxBom } from './types/index.ts';

/**
* Creates a trimmed copy of a CycloneDX BOM by removing SBOM data not necessary for EOL scanning.
Expand Down
2 changes: 1 addition & 1 deletion src/types/eol-scan.mts → src/types/eol-scan.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CdxBom } from './index.mjs';
import type { CdxBom } from './index.js';

export interface CveStats {
cveId: string;
Expand Down
File renamed without changes.