Skip to content

bom.vulnerabilities model #163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
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: 6 additions & 0 deletions src/enums/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@ export * from './componentScope'
export * from './componentType'
export * from './externalReferenceType'
export * from './hashAlogorithm'
export * from './vulnerabilityAffectsVersionStatus'
export * from './vulnerabilityAnalysisJustification'
export * from './vulnerabilityAnalysisResponse'
export * from './vulnerabilityAnalysisState'
export * from './vulnerabilityRatingMethod'
export * from './vulnerabilityRatingSeverity'
24 changes: 24 additions & 0 deletions src/enums/vulnerabilityAffectsVersionStatus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*!
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.
*/

export enum VulnerabilityAffectsVersionStatus {
Affected = 'affected',
Unaffected = 'unaffected',
Unknown = 'unknown',
}
30 changes: 30 additions & 0 deletions src/enums/vulnerabilityAnalysisJustification.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*!
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.
*/

export enum VulnerabilityAnalysisJustification {
CodeNotPresent = 'code_not_present',
CodeNotReachable = 'code_not_reachable',
RequiresConfiguration = 'requires_configuration',
RequiresDependency = 'requires_dependency',
RequiresEnvironment = 'requires_environment',
ProtectedByCompiler = 'protected_by_compiler',
ProtectedAtRuntime = 'protected_at_runtime',
ProtectedAtPerimeter = 'protected_at_perimeter',
ProtectedByMitigatingControl = 'protected_by_mitigating_control',
}
26 changes: 26 additions & 0 deletions src/enums/vulnerabilityAnalysisResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*!
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.
*/

export enum VulnerabilityAnalysisResponse {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to ImpactAnalysisResponsesType as the XML schema defines?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I switched to ImpactAnalysisResponse as this was the most consistent with the JSON schema, even if the JSON schema doesn't give this enum a standalone definition.

Please advise if you'd prefer a different name.

CanNotFix = 'can_not_fix',
WillNotFix = 'will_not_fix',
Update = 'update',
Rollback = 'rollback',
WorkaroundAvailable = 'workaround_available',
}
27 changes: 27 additions & 0 deletions src/enums/vulnerabilityAnalysisState.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*!
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.
*/

export enum VulnerabilityAnalysisState {
Resolved = 'resolved',
ResolvedWithPedigree = 'resolved_with_pedigree',
Exploitable = 'exploitable',
InTriage = 'in_triage',
FalsePositive = 'false_positive',
NotAffacted = 'not_affected',
}
26 changes: 26 additions & 0 deletions src/enums/vulnerabilityRatingMethod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*!
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.
*/

export enum VulnerabilityRatingMethod {
CVSSv2 = 'CVSSv2',
CVSSv3 = 'CVSSv3',
CVSSv31 = 'CVSSv31',
OWASP = 'OWASP',
Other = 'other',
}
28 changes: 28 additions & 0 deletions src/enums/vulnerabilityRatingSeverity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*!
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.
*/

export enum VulnerabiltyRatingSeverity {
Critical = 'critical',
High = 'high',
Medium = 'medium',
Low = 'low',
Info = 'info',
None = 'none',
Unknown = 'unknown',
}
4 changes: 4 additions & 0 deletions src/models/bom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,20 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
import { isPositiveInteger, isUrnUuid, PositiveInteger, UrnUuid } from '../types'
import { Metadata } from './metadata'
import { ComponentRepository } from './component'
import { VulnerabilityRepository } from './vulnerability'

interface OptionalProperties {
metadata?: Bom['metadata']
components?: Bom['components']
vulnerabilities?: Bom['vulnerabilities']
version?: Bom['version']
serialNumber?: Bom['serialNumber']
}

export class Bom {
metadata: Metadata
components: ComponentRepository
vulnerabilities: VulnerabilityRepository

/** @see version */
#version: PositiveInteger = 1
Expand All @@ -51,6 +54,7 @@ export class Bom {
constructor (op: OptionalProperties = {}) {
this.metadata = op.metadata ?? new Metadata()
this.components = op.components ?? new ComponentRepository()
this.vulnerabilities = op.vulnerabilities ?? new VulnerabilityRepository()
this.version = op.version ?? this.version
this.serialNumber = op.serialNumber
}
Expand Down
8 changes: 8 additions & 0 deletions src/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,13 @@ export * from './metadata'
export * from './organizationalContact'
export * from './organizationalEntity'
export * from './property'
export * from './source'
export * from './swid'
export * from './tool'
export * from './vulnerability'
export * from './vulnerabilityAdvisory'
export * from './vulnerabilityAffects'
export * from './vulnerabilityAnalysis'
export * from './vulnerabilityCredits'
export * from './vulnerabilityRating'
export * from './vulnerabilityReference'
10 changes: 9 additions & 1 deletion src/models/organizationalEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ SPDX-License-Identifier: Apache-2.0
Copyright (c) OWASP Foundation. All Rights Reserved.
*/

import { Comparable, SortableSet } from '../helpers/sortableSet'
import { OrganizationalContactRepository } from './organizationalContact'

interface OptionalProperties {
Expand All @@ -25,7 +26,7 @@ interface OptionalProperties {
contact?: OrganizationalEntity['contact']
}

export class OrganizationalEntity {
export class OrganizationalEntity implements Comparable {
name?: string
url: Set<URL | string>
contact: OrganizationalContactRepository
Expand All @@ -35,4 +36,11 @@ export class OrganizationalEntity {
this.url = op.url ?? new Set()
this.contact = op.contact ?? new OrganizationalContactRepository()
}

compare (other: OrganizationalEntity): number {
return (this.name ?? '').localeCompare(other.name ?? '')
}
}

export class OrganizationalEntityRepository extends SortableSet<OrganizationalEntity> {
}
42 changes: 42 additions & 0 deletions src/models/source.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*!
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 { Comparable, SortableSet } from '../helpers/sortableSet'

interface OptionalProperties {
url?: URL | string
name?: string
}

export class Source implements Comparable {
url?: URL | string
name?: string

constructor (op: OptionalProperties = {}) {
this.url = op.url
this.name = op.name
}

compare (other: Source): number {
return (this.name ?? '').localeCompare(other.name ?? '')
}
}

export class SourceRepository extends SortableSet<Source> {
}
Loading