-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
feat: add cyclonedx.model.crypto.ProtocolProperties.crypto_ref_array
#767
base: main
Are you sure you want to change the base?
Conversation
300ad09
to
59f49cc
Compare
cyclonedx.model.crypto.ProtocolProperties.crypto_ref_array
Thanks for donating this feature. The provided tests - they need rework. please remove the ones you've added. Instead, add a new data model to https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/tests/_data/models.py
after that, the tests should pick up the new method automatically, and run a serialization-validation-deserialization roundtrip with it and create snapshots. |
59f49cc
to
2be5db0
Compare
I'll clean up the commit message and squash as well with signoff I needed some direction/feedback on how to resolve issues i am facing in tests (if i added them correctly) in 2be5db0, commit message has been documented with issues i faced |
That's fantastic. Somehow, the sign-off was not quite right. |
It looks like you are facing the situation, that your data model's properties are not properly serializing to a certain version of CycloneDX.
in case you still run into issue, for example a enum value that is available in one vetrsion, but not in the pother, let me know. it basically comes down to something like this cyclonedx-python-lib/cyclonedx/model/component.py Lines 376 to 428 in 472bded
|
I saw thos but couldn't figure out the fix :')
for second issue the test failure seems to valid given the dictionary mapping currently __CASES: Dict[Type[serializable.ViewType], FrozenSet[ComponentType]] = dict()
__CASES[SchemaVersion1Dot0] = frozenset({
ComponentType.APPLICATION,
ComponentType.DEVICE,
ComponentType.FRAMEWORK,
ComponentType.LIBRARY,
ComponentType.OPERATING_SYSTEM,
})
__CASES[SchemaVersion1Dot1] = __CASES[SchemaVersion1Dot0] | {
ComponentType.FILE,
}
__CASES[SchemaVersion1Dot2] = __CASES[SchemaVersion1Dot1] | {
ComponentType.CONTAINER,
ComponentType.FIRMWARE,
}
__CASES[SchemaVersion1Dot3] = __CASES[SchemaVersion1Dot2]
__CASES[SchemaVersion1Dot4] = __CASES[SchemaVersion1Dot3]
__CASES[SchemaVersion1Dot5] = __CASES[SchemaVersion1Dot4] | {
ComponentType.DATA,
ComponentType.DEVICE_DRIVER,
ComponentType.MACHINE_LEARNING_MODEL,
ComponentType.PLATFORM,
}
__CASES[SchemaVersion1Dot6] = __CASES[SchemaVersion1Dot5] | {
ComponentType.CRYPTOGRAPHIC_ASSET,
} so cryptographi-asset is not supported for any version < v1.6, so how to do i restrict tests not be generated from all v1.6? e.g. error err log : |
Will take a look at it sometime next week. |
b85dd98
to
3583283
Compare
I have squashed and rebased the PR with latest upstream main |
@@ -7429,7 +7429,7 @@ limitations under the License. | |||
</xs:sequence> | |||
</xs:complexType> | |||
</xs:element> | |||
<xs:element name="cryptoRef" type="bom:refType" minOccurs="0" maxOccurs="unbounded"> | |||
<xs:element name="cryptoRefArray" type="bom:refType" minOccurs="0" maxOccurs="unbounded"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this an intentional change?
you can not simply modify the schema here, it is downstream from
https://github.com/CycloneDX/specification/blob/master/schema/bom-1.6.xsd#L7432
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i did that intentionally as i saw it was cryptoRefArray in json so thought it might also have to be same here
cyclonedx/model/crypto.py
Outdated
@property | ||
@serializable.xml_array(serializable.XmlArraySerializationType.FLAT, 'cryptoRefArray') | ||
@serializable.xml_sequence(40) | ||
def crypto_ref_array(self) -> 'SortedSet[BomRef]': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def crypto_ref_array(self) -> 'SortedSet[BomRef]': | |
@serializable.xml_name('cryptoRef') | |
@serializable.xml_name('cryptoRef') | |
@serializable.json_name('cryptoRefArray') | |
def crypto_refs(self) -> 'SortedSet[BomRef]': |
cyclonedx/model/crypto.py
Outdated
""" | ||
return self._crypto_ref_array | ||
|
||
@crypto_ref_array.setter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@crypto_ref_array.setter | |
@crypto_refs.setter |
cyclonedx/model/crypto.py
Outdated
@@ -1309,11 +1309,13 @@ def __init__( | |||
version: Optional[str] = None, | |||
cipher_suites: Optional[Iterable[ProtocolPropertiesCipherSuite]] = None, | |||
ikev2_transform_types: Optional[Ikev2TransformTypes] = None, | |||
crypto_ref_array: Optional[Iterable[BomRef]] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
crypto_ref_array: Optional[Iterable[BomRef]] = None, | |
crypto_refs: Optional[Iterable[BomRef]] = None, |
applied the fix recommended in the thread, to add crypto_ref_array as an argument to ProtocolProperties class Also updated bom1.6.SNAPSHOT.xsd from cryptoRef -> cryptoRefArray added testcase and BOM json from the mentioned issue. Signed-off-by: Indivar Mishra <[email protected]>
resolve review comments Signed-off-by: Indivar Mishra <[email protected]>
so use applciation instead that is supported from v1.0 - v1.6 Signed-off-by: Indivar Mishra <[email protected]>
3583283
to
21f8900
Compare
applied the fix recommended in the thread.
added testcase and BOM json from the mentioned issue.
fixes #692