3333from datetime import datetime
3434from decimal import Decimal
3535from 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
3737
3838import serializable
3939from sortedcontainers import SortedSet
4242from ..exception .model import MutuallyExclusivePropertiesException , NoPropertiesProvidedException
4343from ..schema .schema import SchemaVersion1Dot4 , SchemaVersion1Dot5 , SchemaVersion1Dot6
4444from ..serialization import BomRefHelper
45- from . import Property , Tool , XsUri
45+ from . import Property , XsUri
4646from .bom_ref import BomRef
4747from .contact import OrganizationalContact , OrganizationalEntity
4848from .impact_analysis import (
5151 ImpactAnalysisResponse ,
5252 ImpactAnalysisState ,
5353)
54-
54+ from . tool import Tool , ToolsRepository , ToolsRepositoryHelper
5555
5656@serializable .serializable_class
5757class BomTargetVersionRange :
@@ -911,7 +911,8 @@ def __init__(self, *,
911911 advisories : Optional [Iterable [VulnerabilityAdvisory ]] = None , created : Optional [datetime ] = None ,
912912 published : Optional [datetime ] = None , updated : Optional [datetime ] = None ,
913913 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 ,
915916 affects : Optional [Iterable [BomTarget ]] = None ,
916917 properties : Optional [Iterable [Property ]] = None
917918 ) -> None :
@@ -932,7 +933,7 @@ def __init__(self, *,
932933 self .published = published
933934 self .updated = updated
934935 self .credits = credits
935- self .tools = tools or [ ] # type:ignore[assignment]
936+ self .tools = tools or ToolsRepository () # type:ignore[assignment ] # type:ignore[assignment]
936937 self .analysis = analysis
937938 self .affects = affects or [] # type:ignore[assignment]
938939 self .properties = properties or [] # type:ignore[assignment]
@@ -1193,20 +1194,24 @@ def credits(self, credits: Optional[VulnerabilityCredits]) -> None:
11931194 self ._credits = credits
11941195
11951196 @property
1197+ @serializable .type_mapping (ToolsRepositoryHelper )
11961198 @serializable .xml_array (serializable .XmlArraySerializationType .NESTED , 'tool' )
11971199 @serializable .xml_sequence (17 )
1198- def tools (self ) -> 'SortedSet[Tool]' :
1200+ def tools (self ) -> ToolsRepository :
11991201 """
1200- The tool(s) used to identify, confirm, or score the vulnerability .
1202+ Tools used to create this BOM .
12011203
12021204 Returns:
1203- Set of `Tool`
1205+ `ToolsRepository` objects.
12041206 """
12051207 return self ._tools
12061208
12071209 @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 )
12101215
12111216 @property
12121217 @serializable .xml_sequence (18 )
0 commit comments