|
48 | 48 | from ..serialization import PackageUrl as PackageUrlSH |
49 | 49 | from . import ( |
50 | 50 | AttachedText, |
51 | | - Copyright, |
52 | 51 | ExternalReference, |
53 | 52 | HashAlgorithm, |
54 | 53 | HashType, |
|
58 | 57 | _HashTypeRepositorySerializationHelper, |
59 | 58 | ) |
60 | 59 | from .bom_ref import BomRef |
| 60 | +from .component_evidence import ComponentEvidence, _ComponentEvidenceSerializationHelper |
61 | 61 | from .contact import OrganizationalContact, OrganizationalEntity |
62 | 62 | from .crypto import CryptoProperties |
63 | 63 | from .dependency import Dependable |
@@ -191,108 +191,6 @@ def __repr__(self) -> str: |
191 | 191 | return f'<Commit uid={self.uid}, url={self.url}, message={self.message}>' |
192 | 192 |
|
193 | 193 |
|
194 | | -@serializable.serializable_class |
195 | | -class ComponentEvidence: |
196 | | - """ |
197 | | - Our internal representation of the `componentEvidenceType` complex type. |
198 | | -
|
199 | | - Provides the ability to document evidence collected through various forms of extraction or analysis. |
200 | | -
|
201 | | - .. note:: |
202 | | - See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.6/xml/#type_componentEvidenceType |
203 | | - """ |
204 | | - |
205 | | - def __init__( |
206 | | - self, *, |
207 | | - licenses: Optional[Iterable[License]] = None, |
208 | | - copyright: Optional[Iterable[Copyright]] = None, |
209 | | - ) -> None: |
210 | | - self.licenses = licenses or [] |
211 | | - self.copyright = copyright or [] |
212 | | - |
213 | | - # @property |
214 | | - # ... |
215 | | - # @serializable.view(SchemaVersion1Dot5) |
216 | | - # @serializable.xml_sequence(1) |
217 | | - # def identity(self) -> ...: |
218 | | - # ... # TODO since CDX1.5 |
219 | | - # |
220 | | - # @identity.setter |
221 | | - # def identity(self, ...) -> None: |
222 | | - # ... # TODO since CDX1.5 |
223 | | - |
224 | | - # @property |
225 | | - # ... |
226 | | - # @serializable.view(SchemaVersion1Dot5) |
227 | | - # @serializable.xml_sequence(2) |
228 | | - # def occurrences(self) -> ...: |
229 | | - # ... # TODO since CDX1.5 |
230 | | - # |
231 | | - # @occurrences.setter |
232 | | - # def occurrences(self, ...) -> None: |
233 | | - # ... # TODO since CDX1.5 |
234 | | - |
235 | | - # @property |
236 | | - # ... |
237 | | - # @serializable.view(SchemaVersion1Dot5) |
238 | | - # @serializable.xml_sequence(3) |
239 | | - # def callstack(self) -> ...: |
240 | | - # ... # TODO since CDX1.5 |
241 | | - # |
242 | | - # @callstack.setter |
243 | | - # def callstack(self, ...) -> None: |
244 | | - # ... # TODO since CDX1.5 |
245 | | - |
246 | | - @property |
247 | | - @serializable.type_mapping(_LicenseRepositorySerializationHelper) |
248 | | - @serializable.xml_sequence(4) |
249 | | - def licenses(self) -> LicenseRepository: |
250 | | - """ |
251 | | - Optional list of licenses obtained during analysis. |
252 | | -
|
253 | | - Returns: |
254 | | - Set of `LicenseChoice` |
255 | | - """ |
256 | | - return self._licenses |
257 | | - |
258 | | - @licenses.setter |
259 | | - def licenses(self, licenses: Iterable[License]) -> None: |
260 | | - self._licenses = LicenseRepository(licenses) |
261 | | - |
262 | | - @property |
263 | | - @serializable.xml_array(serializable.XmlArraySerializationType.NESTED, 'text') |
264 | | - @serializable.xml_sequence(5) |
265 | | - def copyright(self) -> 'SortedSet[Copyright]': |
266 | | - """ |
267 | | - Optional list of copyright statements. |
268 | | -
|
269 | | - Returns: |
270 | | - Set of `Copyright` |
271 | | - """ |
272 | | - return self._copyright |
273 | | - |
274 | | - @copyright.setter |
275 | | - def copyright(self, copyright: Iterable[Copyright]) -> None: |
276 | | - self._copyright = SortedSet(copyright) |
277 | | - |
278 | | - def __comparable_tuple(self) -> _ComparableTuple: |
279 | | - return _ComparableTuple(( |
280 | | - _ComparableTuple(self.licenses), |
281 | | - _ComparableTuple(self.copyright), |
282 | | - )) |
283 | | - |
284 | | - def __eq__(self, other: object) -> bool: |
285 | | - if isinstance(other, ComponentEvidence): |
286 | | - return self.__comparable_tuple() == other.__comparable_tuple() |
287 | | - return False |
288 | | - |
289 | | - def __hash__(self) -> int: |
290 | | - return hash(self.__comparable_tuple()) |
291 | | - |
292 | | - def __repr__(self) -> str: |
293 | | - return f'<ComponentEvidence id={id(self)}>' |
294 | | - |
295 | | - |
296 | 194 | @serializable.serializable_enum |
297 | 195 | class ComponentScope(str, Enum): |
298 | 196 | """ |
@@ -1644,6 +1542,7 @@ def components(self, components: Iterable['Component']) -> None: |
1644 | 1542 | @serializable.view(SchemaVersion1Dot5) |
1645 | 1543 | @serializable.view(SchemaVersion1Dot6) |
1646 | 1544 | @serializable.xml_sequence(24) |
| 1545 | + @serializable.type_mapping(_ComponentEvidenceSerializationHelper) |
1647 | 1546 | def evidence(self) -> Optional[ComponentEvidence]: |
1648 | 1547 | """ |
1649 | 1548 | Provides the ability to document evidence collected through various forms of extraction or analysis. |
|
0 commit comments