-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathtypes.ts
More file actions
330 lines (282 loc) · 8.17 KB
/
Copy pathtypes.ts
File metadata and controls
330 lines (282 loc) · 8.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
/*!
This file is part of CycloneDX JavaScript Library.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright (c) OWASP Foundation. All Rights Reserved.
*/
import type * as Enums from '../../enums'
import type { HashContent } from '../../models'
import type { SpdxId } from '../../spdx'
import type { CPE, CWE, Integer } from '../../types'
/* eslint-disable-next-line @typescript-eslint/no-namespace -- needed */
export namespace JsonSchema {
/**
* @see {@link isIriReference}
*/
export type IriReference = string
/**
* Test whether format is JSON::iri-reference - best-effort.
*
* @see {@link https://datatracker.ietf.org/doc/html/rfc3987 | RFC 3987}
*
* @TODO add more validation according to spec
*/
export function isIriReference (value: IriReference | any): value is IriReference {
// There is just no working implementation for format "iri-reference": see https://github.com/luzlab/ajv-formats-draft2019/issues/22
return typeof value === 'string' &&
value.length > 0
}
/**
* @see {@link isIdnEmail}
*/
export type IdnEmail = string
/**
* Test whether format is JSON::idn-email - best-effort.
*
* @see {@link https://datatracker.ietf.org/doc/html/rfc6531 | RFC 6531}
*
* @TODO add more validation according to spec
*/
export function isIdnEmail (value: IdnEmail | any): value is IdnEmail {
return typeof value === 'string' &&
value.length > 0
}
export type DateTime = string
}
/* eslint-disable-next-line @typescript-eslint/no-namespace -- needed */
export namespace Normalized {
export type RefType = string
export type RefLinkType = RefType
export type BomLinkDocumentType = string
export type BomLinkElementType = string
/* eslint-disable-next-line @typescript-eslint/no-duplicate-type-constituents -- as of spec */
export type BomLink = BomLinkDocumentType | BomLinkElementType
export interface Bom {
$schema?: string
bomFormat: 'CycloneDX'
specVersion: string
version: Integer
serialNumber?: string
metadata?: Metadata
components?: Component[]
services?: Service[]
externalReferences?: ExternalReference[]
dependencies?: Dependency[]
vulnerabilities?: Vulnerability[]
}
export interface Metadata {
timestamp?: JsonSchema.DateTime
lifecycles?: Lifecycle[]
tools?: ToolsType
authors?: OrganizationalContact[]
component?: Component
manufacture?: OrganizationalEntity
supplier?: OrganizationalEntity
licenses?: License[]
properties?: Property[]
}
export interface LifecyclePhase {
phase: Enums.LifecyclePhase
}
export interface NamedLifecycle {
name: string
description?: string
}
export type Lifecycle = LifecyclePhase | NamedLifecycle
export interface Tool {
vendor?: string
name?: string
version?: string
hashes?: Hash[]
externalReferences?: ExternalReference[]
}
/** since CDX 1.5 */
export interface Tools {
components?: Component[]
services?: Service[]
}
export type ToolsType = Tools | Tool[]
export interface OrganizationalContact {
name?: string
email?: JsonSchema.IdnEmail
phone?: string
}
export interface OrganizationalEntity {
name?: string
url?: JsonSchema.IriReference[]
contact?: OrganizationalContact[]
}
export interface Hash {
alg: Enums.HashAlgorithm
content: HashContent
}
export interface Component {
type: Enums.ComponentType
name: string
'mime-type'?: string
'bom-ref'?: RefType
supplier?: OrganizationalEntity
author?: string
publisher?: string
group?: string
version?: string
description?: string
scope?: Enums.ComponentScope
hashes?: Hash[]
licenses?: License[]
copyright?: string
cpe?: CPE
purl?: string
swid?: SWID
modified?: boolean
externalReferences?: ExternalReference[]
components?: Component[]
evidence?: ComponentEvidence
properties?: Property[]
}
export interface Service {
'bom-ref'?: RefType
provider?: OrganizationalEntity
group?: string
name: string
version?: string
description?: string
licenses?: License[]
externalReferences?: ExternalReference[]
services?: Service[]
properties?: Property[]
}
export interface ComponentEvidence {
licenses?: License[]
copyright?: Copyright[]
}
export interface Copyright {
text: string
}
export interface NamedLicense {
license: {
name: string
acknowledgement?: Enums.LicenseAcknowledgement
text?: Attachment
url?: string
}
}
export interface SpdxLicense {
license: {
/* see http://cyclonedx.org/schema/spdx */
id: SpdxId
acknowledgement?: Enums.LicenseAcknowledgement
text?: Attachment
url?: string
}
}
export interface LicenseExpression {
expression: string
acknowledgement?: Enums.LicenseAcknowledgement
}
export type License = NamedLicense | SpdxLicense | LicenseExpression
export interface SWID {
tagId: string
name: string
version?: string
tagVersion?: Integer
patch?: boolean
text?: Attachment
url?: JsonSchema.IriReference
}
export interface ExternalReference {
/* eslint-disable-next-line @typescript-eslint/no-duplicate-type-constituents -- as of spec */
url: JsonSchema.IriReference | BomLink
type: Enums.ExternalReferenceType
hashes?: Hash[]
comment?: string
}
export interface Attachment {
content?: string
contentType?: string
encoding?: Enums.AttachmentEncoding
}
export interface Property {
name?: string
value?: string
}
export interface Dependency {
ref: RefLinkType
dependsOn?: RefLinkType[]
}
export interface Vulnerability {
'bom-ref'?: RefType
id?: string
source?: Vulnerability.Source
references?: Vulnerability.Reference[]
ratings?: Vulnerability.Rating[]
cwes?: CWE[]
description?: string
detail?: string
recommendation?: string
advisories?: Vulnerability.Advisory[]
created?: JsonSchema.DateTime
published?: JsonSchema.DateTime
updated?: JsonSchema.DateTime
credits?: Vulnerability.Credits
tools?: ToolsType
analysis?: Vulnerability.Analysis
affects?: Vulnerability.Affect[]
properties?: Property[]
}
/* eslint-disable-next-line @typescript-eslint/no-namespace -- needed */
export namespace Vulnerability {
export interface Source {
name?: string
url?: string
}
export interface Reference {
id: string
source: Source
}
export interface Rating {
source?: Source
score?: number
severity?: Enums.Vulnerability.Severity
method?: Enums.Vulnerability.RatingMethod
vector?: string
justification?: string
}
export interface Advisory {
title?: string
url: JsonSchema.IriReference
}
export interface Credits {
organizations?: OrganizationalEntity[]
individuals?: OrganizationalContact[]
}
export interface Analysis {
state?: Enums.Vulnerability.AnalysisState
justification?: Enums.Vulnerability.AnalysisJustification
response?: Enums.Vulnerability.AnalysisResponse[]
detail?: string
}
export interface Affect {
/* eslint-disable-next-line @typescript-eslint/no-duplicate-type-constituents -- as of spec */
ref: RefLinkType | BomLinkElementType
versions?: AffectedVersion[]
}
export interface AffectedSingleVersion {
version: string
status?: Enums.Vulnerability.AffectStatus
}
export interface AffectedVersionRange {
range: string
status?: Enums.Vulnerability.AffectStatus
}
export type AffectedVersion = AffectedSingleVersion | AffectedVersionRange
}
}