You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a spin-off issue from #302 which discusses 2 issues focused on how to support Extension subclasses.
According to the SPDX AIPackage specification an optional property field is extension. This field is of type Extension.
Extension is an abstract class so it can't be instantiated.
Referencing an Extension in the JSON-LD without parameters passes the Java coded validation but fails the JSON schema validation (see related spdx/spdx-3-model#1017):
From the spec, I think to use Extension, one needs to define a concrete class to use it.
An SPDX validator may be expected to validate everything according to the standard SPDX schema but once it encounters the non-standard extension part - it will leave the validation of that part to the extension's validator (if any).
This means, if an SBOM uses a non-standard extension, it has to supply the extension schema too, if full validation is needed.
Discussing this on the implementers call with @pmonks - we could just store the JSON data for the extension property as a simple array of strings. We would leave it up to the caller of the library to deserialize the JSON string and utilize it.
It gets a bit more complicated if we want to handle the CdxPropertiesExtension which can be deserialized reliably.
I would propose that if we deserialize extensions and have a "type" : "extension_CdxPropertiesExtension", we handle it exactly as we do today.
For any other JSON value for extension, we store it in a new subclass of Extension that just stores the string value of the JSON.
This would make it easy to serialize / deserialize the Extension data reliably. However, it does move the work to interpret the extension data to the caller.
Specifically:
A new Java class ExtensionJson will be introduced in the SPDX 3 model that has a single property json of type String. ExtensionJson would be a subclass of Extension.
if the Element class has an extension array element with a "type" : "extension_CdxPropertiesExtension", it would be handled in the same manner as today
for any JSON files that does not have a "type" : "extension_CdxPropertiesExtension", we create a ExtensionJson object and store the string value of the JSON.
Would result in an ExtensionJson object being created and added to the collection of values for the Elementextension property with the json property string value equal to:
Activity
bact commentedon Apr 14, 2025
Note, the
extensionproperty is part of theElementclass. So every subclasses inherit it. (Not specificallyAIPackage).bact commentedon Apr 14, 2025
From the spec, I think to use
Extension, one needs to define a concrete class to use it.An SPDX validator may be expected to validate everything according to the standard SPDX schema but once it encounters the non-standard extension part - it will leave the validation of that part to the extension's validator (if any).
This means, if an SBOM uses a non-standard extension, it has to supply the extension schema too, if full validation is needed.
goneall commentedon Apr 16, 2025
Discussing this on the implementers call with @pmonks - we could just store the JSON data for the
extensionproperty as a simple array of strings. We would leave it up to the caller of the library to deserialize the JSON string and utilize it.It gets a bit more complicated if we want to handle the
CdxPropertiesExtensionwhich can be deserialized reliably.I would propose that if we deserialize extensions and have a
"type" : "extension_CdxPropertiesExtension", we handle it exactly as we do today.For any other JSON value for
extension, we store it in a new subclass ofExtensionthat just stores the string value of the JSON.This would make it easy to serialize / deserialize the Extension data reliably. However, it does move the work to interpret the
extensiondata to the caller.Specifically:
ExtensionJsonwill be introduced in the SPDX 3 model that has a single propertyjsonof typeString.ExtensionJsonwould be a subclass ofExtension.Elementclass has anextensionarray element with a"type" : "extension_CdxPropertiesExtension", it would be handled in the same manner as today"type" : "extension_CdxPropertiesExtension", we create aExtensionJsonobject and store the string value of the JSON.For example, the serialization:
Would result in an
ExtensionJsonobject being created and added to the collection of values for theElementextensionproperty with thejsonproperty string value equal to:goneall commentedon Apr 22, 2025
Suggestion from tech call: Implement as a map of property name
StringtoObject.