33
33
from datetime import datetime
34
34
from decimal import Decimal
35
35
from enum import Enum
36
- from typing import Any , Dict , FrozenSet , Iterable , Optional , Tuple , Type , Union
36
+ from typing import Any , AnyStr , Dict , FrozenSet , Iterable , Optional , Tuple , Type , Union
37
37
38
38
import serializable
39
39
from sortedcontainers import SortedSet
42
42
from ..exception .model import MutuallyExclusivePropertiesException , NoPropertiesProvidedException
43
43
from ..schema .schema import SchemaVersion1Dot4 , SchemaVersion1Dot5 , SchemaVersion1Dot6
44
44
from ..serialization import BomRefHelper
45
- from . import Property , Tool , XsUri
45
+ from . import Property , XsUri
46
46
from .bom_ref import BomRef
47
47
from .contact import OrganizationalContact , OrganizationalEntity
48
48
from .impact_analysis import (
51
51
ImpactAnalysisResponse ,
52
52
ImpactAnalysisState ,
53
53
)
54
-
54
+ from . tool import Tool , ToolsRepository , ToolsRepositoryHelper
55
55
56
56
@serializable .serializable_class
57
57
class BomTargetVersionRange :
@@ -911,7 +911,8 @@ def __init__(self, *,
911
911
advisories : Optional [Iterable [VulnerabilityAdvisory ]] = None , created : Optional [datetime ] = None ,
912
912
published : Optional [datetime ] = None , updated : Optional [datetime ] = None ,
913
913
credits : Optional [VulnerabilityCredits ] = None ,
914
- tools : Optional [Iterable [Tool ]] = None , analysis : Optional [VulnerabilityAnalysis ] = None ,
914
+ tools : Optional [Union [Iterable [Tool ], Dict [AnyStr , Any ]]] = None ,
915
+ analysis : Optional [VulnerabilityAnalysis ] = None ,
915
916
affects : Optional [Iterable [BomTarget ]] = None ,
916
917
properties : Optional [Iterable [Property ]] = None
917
918
) -> None :
@@ -932,7 +933,7 @@ def __init__(self, *,
932
933
self .published = published
933
934
self .updated = updated
934
935
self .credits = credits
935
- self .tools = tools or [ ] # type:ignore[assignment]
936
+ self .tools = tools or ToolsRepository () # type:ignore[assignment ] # type:ignore[assignment]
936
937
self .analysis = analysis
937
938
self .affects = affects or [] # type:ignore[assignment]
938
939
self .properties = properties or [] # type:ignore[assignment]
@@ -1193,20 +1194,24 @@ def credits(self, credits: Optional[VulnerabilityCredits]) -> None:
1193
1194
self ._credits = credits
1194
1195
1195
1196
@property
1197
+ @serializable .type_mapping (ToolsRepositoryHelper )
1196
1198
@serializable .xml_array (serializable .XmlArraySerializationType .NESTED , 'tool' )
1197
1199
@serializable .xml_sequence (17 )
1198
- def tools (self ) -> 'SortedSet[Tool]' :
1200
+ def tools (self ) -> ToolsRepository :
1199
1201
"""
1200
- The tool(s) used to identify, confirm, or score the vulnerability .
1202
+ Tools used to create this BOM .
1201
1203
1202
1204
Returns:
1203
- Set of `Tool`
1205
+ `ToolsRepository` objects.
1204
1206
"""
1205
1207
return self ._tools
1206
1208
1207
1209
@tools .setter
1208
- def tools (self , tools : Iterable [Tool ]) -> None :
1209
- self ._tools = SortedSet (tools )
1210
+ def tools (self , tools : Union [Iterable [Tool ], ToolsRepository ]) -> None :
1211
+ if isinstance (tools , ToolsRepository ):
1212
+ self ._tools = tools
1213
+ else :
1214
+ self ._tools = ToolsRepository (tools = tools )
1210
1215
1211
1216
@property
1212
1217
@serializable .xml_sequence (18 )
0 commit comments