Skip to content

Commit d1fd01e

Browse files
committed
wip
Signed-off-by: Jan Kowalleck <[email protected]>
1 parent dd3d5fb commit d1fd01e

File tree

68 files changed

+278
-209
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+278
-209
lines changed

src/_optPlug.node/__jsonValidators/ajv.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20+
import { readFile } from 'node:fs/promises'
21+
2022
import Ajv, { type Options as AjvOptions } from 'ajv'
2123
import addFormats from 'ajv-formats'
2224
/* @ts-expect-error TS7016 */
2325
import addFormats2019 from 'ajv-formats-draft2019'
24-
import { readFile } from 'fs/promises'
2526

2627
import type { ValidationError } from '../../validation/types'
2728
import type { Functionality, Validator } from '../jsonValidator'

src/_optPlug.node/__xmlValidators/libxmljs2.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
import { readFile } from 'fs/promises'
20+
import { readFile } from 'node:fs/promises'
21+
import { pathToFileURL } from 'node:url'
22+
2123
import { type ParserOptions, parseXml } from 'libxmljs2'
22-
import { pathToFileURL } from 'url'
2324

2425
import type { ValidationError } from '../../validation/types'
2526
import type { Functionality, Validator } from '../xmlValidator'

src/models/externalReference.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import type { ExternalReferenceType } from '../enums/externalReferenceType'
2323
import type { BomLink } from './bomLink'
2424
import { HashDictionary } from './hash'
2525

26+
2627
export interface OptionalExternalReferenceProperties {
2728
hashes?: ExternalReference['hashes']
2829
comment?: ExternalReference['comment']

src/resources.node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
import { resolve } from 'path'
20+
import { resolve } from 'node:path'
2121

2222
import { Version } from './spec/enums'
2323

src/types/cwe.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

2020
import { SortableNumbers } from '../_helpers/sortable'
21-
import type { PositiveInteger } from './integer'
22-
import { isPositiveInteger } from './integer'
21+
import { isPositiveInteger, type PositiveInteger} from './integer'
2322

2423
/**
2524
* Integer representation of a Common Weaknesses Enumerations (CWE).

tests/_data/models.js

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,63 @@ const { Enums, Models, Types } = require('../../')
2424
/**
2525
* @returns {Models.Bom}
2626
*/
27+
module.exports.createAllTools = function () {
28+
const bomSerialNumberRaw = '8fd9e244-73b6-4cd3-ab3a-a0fefdee5c9e'
29+
const bom = new Models.Bom({
30+
version: 7,
31+
serialNumber: `urn:uuid:${bomSerialNumberRaw}`,
32+
})
33+
bom.metadata.tools.components.add(
34+
new Models.Component(
35+
Enums.ComponentType.Application,
36+
'Component tool name', {
37+
group: 'Component tool group',
38+
version: '0.8.15',
39+
hashes: new Models.HashDictionary([
40+
[Enums.HashAlgorithm.MD5, '974e5cc07da6e4536bffd935fd4ddc61'],
41+
[Enums.HashAlgorithm['SHA-1'], '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed']
42+
])
43+
}))
44+
bom.metadata.tools.services.add(
45+
new Models.Service('sbom-generator-service', {
46+
group: 'Service tool group',
47+
version: '1',
48+
externalReferences: new Models.ExternalReferenceRepository([
49+
new Models.ExternalReference(
50+
'https://example.com/sbom-generator-service/',
51+
Enums.ExternalReferenceType.Website,
52+
{ comment: 'the service that made this' }
53+
)
54+
])
55+
})
56+
)
57+
bom.metadata.tools.tools.add(
58+
new Models.Tool({
59+
vendor: 'Tool tool vendor',
60+
name: 'Tool tool name',
61+
version: '0.8.15',
62+
hashes: new Models.HashDictionary([
63+
[Enums.HashAlgorithm.MD5, 'f32a26e2a3a8aa338cd77b6e1263c535'],
64+
[Enums.HashAlgorithm['SHA-1'], '829c3804401b0727f70f73d4415e162400cbe57b']
65+
])
66+
})
67+
)
68+
bom.metadata.tools.tools.add(
69+
new Models.Tool({
70+
vendor: 'Tool tool vendor',
71+
name: 'Tool other tool',
72+
version: '', // empty string, not undefined
73+
externalReferences: new Models.ExternalReferenceRepository([
74+
new Models.ExternalReference(
75+
'https://cyclonedx.org/tool-center/',
76+
Enums.ExternalReferenceType.Website,
77+
{ comment: 'the tools that made this' }
78+
)
79+
])
80+
})
81+
)
82+
return bom
83+
}
2784
module.exports.createComplexStructure = function () {
2885
const bomSerialNumberRaw = 'ac35b126-ef3a-11ed-a05b-0242ac120003'
2986
const bom = new Models.Bom({
@@ -613,60 +670,3 @@ module.exports.createComplexStructure = function () {
613670
/**
614671
* @returns {Models.Bom}
615672
*/
616-
module.exports.createAllTools = function () {
617-
const bomSerialNumberRaw = '8fd9e244-73b6-4cd3-ab3a-a0fefdee5c9e'
618-
const bom = new Models.Bom({
619-
version: 7,
620-
serialNumber: `urn:uuid:${bomSerialNumberRaw}`,
621-
})
622-
bom.metadata.tools.components.add(
623-
new Models.Component(
624-
Enums.ComponentType.Application,
625-
'Component tool name', {
626-
group: 'Component tool group',
627-
version: '0.8.15',
628-
hashes: new Models.HashDictionary([
629-
[Enums.HashAlgorithm.MD5, '974e5cc07da6e4536bffd935fd4ddc61'],
630-
[Enums.HashAlgorithm['SHA-1'], '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed']
631-
])
632-
}))
633-
bom.metadata.tools.services.add(
634-
new Models.Service('sbom-generator-service', {
635-
group: 'Service tool group',
636-
version: '1',
637-
externalReferences: new Models.ExternalReferenceRepository([
638-
new Models.ExternalReference(
639-
'https://example.com/sbom-generator-service/',
640-
Enums.ExternalReferenceType.Website,
641-
{ comment: 'the service that made this' }
642-
)
643-
])
644-
})
645-
)
646-
bom.metadata.tools.tools.add(
647-
new Models.Tool({
648-
vendor: 'Tool tool vendor',
649-
name: 'Tool tool name',
650-
version: '0.8.15',
651-
hashes: new Models.HashDictionary([
652-
[Enums.HashAlgorithm.MD5, 'f32a26e2a3a8aa338cd77b6e1263c535'],
653-
[Enums.HashAlgorithm['SHA-1'], '829c3804401b0727f70f73d4415e162400cbe57b']
654-
])
655-
})
656-
)
657-
bom.metadata.tools.tools.add(
658-
new Models.Tool({
659-
vendor: 'Tool tool vendor',
660-
name: 'Tool other tool',
661-
version: '', // empty string, not undefined
662-
externalReferences: new Models.ExternalReferenceRepository([
663-
new Models.ExternalReference(
664-
'https://cyclonedx.org/tool-center/',
665-
Enums.ExternalReferenceType.Website,
666-
{ comment: 'the tools that made this' }
667-
)
668-
])
669-
})
670-
)
671-
return bom
672-
}

tests/_data/spdx.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
const fs = require('node:fs')
2120
const assert = require('node:assert')
21+
const fs = require('node:fs')
2222

2323
const { _Resources: { FILES: { SPDX: { JSON_SCHEMA: SPDX_JSON_SCHEMA } } } } = require('../../')
2424

tests/_data/specLoader.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
const fs = require('nodeLfs')
20+
const fs = require('node:fs')
2121
const path = require('node:path')
2222

2323
const resPath = path.resolve(__dirname, '..', '..', 'res', 'schema')
@@ -72,7 +72,7 @@ function getSpecEnum (resourceFile, ...path) {
7272
}
7373

7474
module.exports = {
75-
loadSpec,
7675
getSpecElement,
77-
getSpecEnum
76+
getSpecEnum,
77+
loadSpec
7878
}

tests/_data/specLoader.spec.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
const assert = require('assert')
20+
const assert = require('node:assert')
21+
2122
const { suite, test } = require('mocha')
2223

23-
const { loadSpec, getSpecElement, getSpecEnum } = require('./specLoader')
24+
const { getSpecElement, getSpecEnum, loadSpec } = require('./specLoader')
2425

2526
suite('test helpers: specLoader', () => {
2627

tests/_helpers/stringFunctions.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
const assert = require('assert')
20+
const assert = require('node:assert')
21+
2122
const { suite, test } = require('mocha')
2223

2324
const stringFunctions = require('./stringFunctions')

0 commit comments

Comments
 (0)