Skip to content

Commit 88f9387

Browse files
committed
models ComponentEvidence
Signed-off-by: Jan Kowalleck <[email protected]>
1 parent e83cd5b commit 88f9387

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ written in _TypeScript_ and compiled for the target.
5151
* `Attachment`
5252
* `Bom`
5353
* `BomRef`, `BomRefRepository`
54-
* `Component`, `ComponentRepository`
54+
* `Component`, `ComponentRepository`, `ComponentEvidence`
5555
* `ExternalReference`, `ExternalReferenceRepository`
5656
* `Hash`, `HashContent`, `HashDictionary`
5757
* `LicenseExpression`, `NamedLicense`, `SpdxLicense`, `LicenseRepository`

src/models/component.ts

+21-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
2020
import type { PackageURL } from 'packageurl-js'
2121

2222
import type { Comparable } from '../_helpers/sortable'
23-
import { SortableComparables } from '../_helpers/sortable'
23+
import {SortableComparables, SortableStringables} from '../_helpers/sortable'
2424
import { treeIteratorSymbol } from '../_helpers/tree'
2525
import type { ComponentScope, ComponentType } from '../enums'
2626
import type { CPE } from '../types'
@@ -52,6 +52,7 @@ export interface OptionalComponentProperties {
5252
components?: Component['components']
5353
cpe?: Component['cpe']
5454
properties?: Component['properties']
55+
evidence?: Component['evidence']
5556
}
5657

5758
export class Component implements Comparable<Component> {
@@ -73,6 +74,7 @@ export class Component implements Comparable<Component> {
7374
dependencies: BomRefRepository
7475
components: ComponentRepository
7576
properties: PropertyRepository
77+
evidence?: ComponentEvidence
7678

7779
/** @see {@link bomRef} */
7880
readonly #bomRef: BomRef
@@ -104,6 +106,7 @@ export class Component implements Comparable<Component> {
104106
this.components = op.components ?? new ComponentRepository()
105107
this.cpe = op.cpe
106108
this.properties = op.properties ?? new PropertyRepository()
109+
this.evidence = op.evidence
107110
}
108111

109112
get bomRef (): BomRef {
@@ -152,3 +155,20 @@ export class ComponentRepository extends SortableComparables<Component> {
152155
}
153156
}
154157
}
158+
159+
160+
export interface OptionalComponentEvidenceProperties {
161+
licenses?: ComponentEvidence['licenses']
162+
copyright?: ComponentEvidence['copyright']
163+
}
164+
165+
export class ComponentEvidence {
166+
licenses: LicenseRepository
167+
copyright: SortableStringables
168+
169+
constructor(op: OptionalComponentEvidenceProperties = {}) {
170+
this.licenses = op.licenses ?? new LicenseRepository()
171+
this.copyright = op.copyright ?? new SortableStringables()
172+
}
173+
}
174+

0 commit comments

Comments
 (0)