Skip to content

Commit 6c204f7

Browse files
authored
Feat: prevent unknwon enums from rendering (#496)
- fixes #490 - BC: Component serialization may throw `cyclonedx.exception.serialization.SerializationOfUnsupportedComponentTypeException` - feat: serialization have own exceptions of `cyclonedx.exception.serialization.*` - tests: lots of (functional) tests related to enums and serialization - misc: bump `py-serializable@^0.15` -> `@^0.16` details & progress: - [x] `DataFlow` - [x] `Encoding` - [x] `HashAlgorithm` - [x] `ExternalReferenceType` convert "unknown" to `other` - [x] `component.ComponentScope` - [x] `component.ComponentType`. > tests done, migrator open Unclear how to proceed. dropping the info is a bad idea here. Best would be to throw an exception and abort the rendering. - [x] `component.PatchClassification` - [x] `impact_analysis.ImpactAnalysisAffectedStatus` - [x] `impact_analysis.ImpactAnalysisJustification` - [x] `impact_analysis.ImpactAnalysisResponse` - [x] `impact_analysis.ImpactAnalysisState` - [x] `issue.IssueClassification` - [x] `vulnerability.VulnerabilityScoreSource` convert "unknown" to `other` - [x] `vulnerability.VulnerabilitySeverity` --------- Signed-off-by: Jan Kowalleck <[email protected]>
1 parent ac1f48a commit 6c204f7

File tree

156 files changed

+8526
-85
lines changed

Some content is hidden

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

156 files changed

+8526
-85
lines changed

cyclonedx/exception/model.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ class NoPropertiesProvidedException(CycloneDxModelException):
6363
"""
6464
Raised when attempting to construct a model class and providing NO values (where all properites are defined as
6565
Optional, but at least one is required).
66-
6766
"""
6867
pass
6968

cyclonedx/exception/serialization.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License");
2+
# you may not use this file except in compliance with the License.
3+
# You may obtain a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS,
9+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
# See the License for the specific language governing permissions and
11+
# limitations under the License.
12+
#
13+
# SPDX-License-Identifier: Apache-2.0
14+
# Copyright (c) OWASP Foundation. All Rights Reserved.
15+
16+
17+
"""
18+
Exceptions relating to specific conditions that occur when (de)serializing/(de)normalizing CycloneDX BOM.
19+
"""
20+
21+
from . import CycloneDxException
22+
23+
24+
class CycloneDxSerializationException(CycloneDxException):
25+
"""
26+
Base exception that covers all exceptions that may be thrown during model serializing/normalizing.
27+
"""
28+
pass
29+
30+
31+
class CycloneDxDeserializationException(CycloneDxException):
32+
"""
33+
Base exception that covers all exceptions that may be thrown during model deserializing/denormalizing.
34+
"""
35+
pass
36+
37+
38+
class SerializationOfUnsupportedComponentTypeException(CycloneDxSerializationException):
39+
"""
40+
Raised when attempting serializing/normalizing a :py:class:`cyclonedx.model.component.Component`
41+
to a :py:class:`cyclonedx.schema.schema.BaseSchemaVersion`
42+
which does not support that :py:class:`cyclonedx.model.component.ComponentType`
43+
.
44+
"""
45+
46+
47+
class SerializationOfUnexpectedValueException(CycloneDxSerializationException, ValueError):
48+
"""
49+
Raised when attempting serializing/normalizing a type that is not expected there.
50+
"""

0 commit comments

Comments
 (0)