Skip to content
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

License Schema Inconsistency between XML/JSON #133

Closed
TiberiusDRAIG opened this issue Feb 11, 2022 · 5 comments
Closed

License Schema Inconsistency between XML/JSON #133

TiberiusDRAIG opened this issue Feb 11, 2022 · 5 comments
Milestone

Comments

@TiberiusDRAIG
Copy link

The XML schema does not require an ID for the license property, whereas the JSON schema not only requires it but also enforces that it be one of the SPDX values specified.

This causes problems when a package does not provide an SPDX ID; for example, Microsoft's System.IO package, which only provides a URL, results in the cyclonedx-dotnet tool generating this:

<license> <url>http://go.microsoft.com/fwlink/?LinkId=329770</url> </license>

This validates successfully against the XML schema.

The equivalent JSON:

"license": { "url": "http://go.microsoft.com/fwlink/?LinkId=329770" }

...is considered invalid as it has no ID.

@TiberiusDRAIG
Copy link
Author

TiberiusDRAIG commented Feb 11, 2022

Ah, sorry - realised I was misreading the JSON schema and 'Name' can be used instead. What, however, should we be doing if a package doesn't provide a license name? Is this a case of manually updating the BOM by hand?

EDIT: This is still inconsistent since 'choice' in the XML schema doesn't enforce that at least one element must be present, but rather that only one of the elements can be present.

@stevespringett
Copy link
Member

What, however, should we be doing if a package doesn't provide a license name?

I would recommend naming the license after 1) the name of the project, or 2) the name of the organization, whichever is most relevant. The important thing is to capture the complete license text for non-standard licenses.

For example:

This is still inconsistent since 'choice' in the XML schema doesn't enforce that at least one element must be present, but rather that only one of the elements can be present.

I'm not entirely sure why that is. Will need to investigate.

See also: https://cyclonedx.org/use-cases/#license-compliance

@TiberiusDRAIG
Copy link
Author

Okay, thanks - I'll use the CycloneDX Core models to add-in the missing information in a follow-up script.

@stevespringett stevespringett added this to the 2.0 milestone Jan 22, 2023
@jkowalleck
Copy link
Member

jkowalleck commented Jul 12, 2023

this report appears to be still relevant.
https://github.com/CycloneDX/specification/blob/1.5/schema/bom-1.5.xsd#L643-L654

change/patch

            <xs:choice>
-               <xs:element name="id" type="spdx:licenseId" minOccurs="0" maxOccurs="1">
+               <xs:element name="id" type="spdx:licenseId" minOccurs="1" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>A valid SPDX license ID</xs:documentation>
                    </xs:annotation>
                </xs:element>
-               <xs:element name="name" type="xs:normalizedString" minOccurs="0" maxOccurs="1">
+               <xs:element name="name" type="xs:normalizedString" minOccurs="1" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>If SPDX does not define the license used, this field may be used to provide the license name</xs:documentation>
                    </xs:annotation>
                </xs:element>
            </xs:choice>

unfortunately, this would be a breaking change, even though it fixes a "bug"

@jkowalleck
Copy link
Member

is duplicated by #288

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants