Skip to content

bug: additional properties on property type in JSON #371

Closed

Description

@agschrei

Currently the definition for a property expects keys name and value but neither of them is required and the presence of other keys is not prohibited through a constraint like "additionalProperties": false

This is an inconsistency compared to other types defined on the schema such as component or dependency which disallow additional properties.

Concretely, that means this sample SBOM validates against the schema, but my argument is that it should not:

{
  "$schema": "http://cyclonedx.org/schema/bom-1.4.schema.json",
  "bomFormat": "CycloneDX",
  "specVersion": "1.4",
  "version": 1,
  "metadata": {
    "component": {
      "bom-ref": "foo",
      "type": "application",
      "name": "foo",
      "properties": [
        {
          "name": "myCustomProperty",
          "value": "myCustomValue",
          "abc": ["def"]
        }
      ]
    }
  },
  "components": [
    {
      "bom-ref": "foo/bar",
      "type": "library",
      "name": "bar"
    }
  ]
}

https://www.jsonschemavalidator.net/s/dRHUBrfG

This seems like a small thing, but I just spent an hour trying to figure out why cyclonedx-core-java would validate an sbom just fine but then fail to parse it. So I think the spec would benefit from a stronger constraint on the property type.

I'm happy to contribute the spec changes for 1.6 if this gets approved.

Activity

  1. jkowalleck commented on Feb 7, 2024

    @jkowalleck
    Member

    checked, can confirm for JSON:

    • name optional
    • value optional
    • additional properties allowed
    • see
      "property": {
      "type": "object",
      "title": "Lightweight name-value pair",
      "properties": {
      "name": {
      "type": "string",
      "title": "Name",
      "description": "The name of the property. Duplicate names are allowed, each potentially having a different value."
      },
      "value": {
      "type": "string",
      "title": "Value",
      "description": "The value of the property."
      }
      }
      },

    in contrast to the JSON, the XML defines

    • name is mandatory
    • value is implicit kind of optional (implicit allows empty string)
    • no additional properties/children allowed
    • see
      <xs:complexType name="propertyType">
      <xs:annotation>
      <xs:documentation>Specifies an individual property with a name and value.</xs:documentation>
      </xs:annotation>
      <xs:simpleContent>
      <xs:extension base="xs:normalizedString">
      <xs:attribute name="name" type="xs:string" use="required">
      <xs:annotation>
      <xs:documentation>The name of the property. Duplicate names are allowed, each potentially having a different value.</xs:documentation>
      </xs:annotation>
      </xs:attribute>
      </xs:extension>
      </xs:simpleContent>
      </xs:complexType>

    in contrast to JSON, the Protobuff defines

    • name is mandatory
    • value is optional
    • no additional properties/children allowed
    • see
      message Property {
      string name = 1;
      optional string value = 2;
      }
  2. jkowalleck commented on Feb 7, 2024

    @jkowalleck
    Member

    @stevespringett if the XML & ProtoBuff are the intended solutions,
    should I target a bug fix of the JSON for the upcoming v1.6 then?

  3. stevespringett commented on Feb 8, 2024

    @stevespringett
    Member

    Yes please. Thanks @jkowalleck

  4. self-assigned this
    on Feb 8, 2024
  5. added this to the 1.6 milestone on Feb 8, 2024
  6. changed the title [-]Suggestion to disallow additional properties on `property` type[/-] [+]bug: additional properties on `property` type in JOSN[/+] on Feb 8, 2024
  7. changed the title [-]bug: additional properties on `property` type in JOSN[/-] [+]bug: additional properties on `property` type in JSON[/+] on Feb 8, 2024
  8. agschrei commented on Feb 8, 2024

    @agschrei
    Author

    Thanks to both of you for the quick turnaround on this!

  9. linked a pull request that will close this issue1.6 dev fix properties json - fixes #371 #375on Feb 9, 2024
  10. added a commit that references this issue on Feb 9, 2024
    6686375
  11. stevespringett commented on Feb 9, 2024

    @stevespringett
    Member

    Thanks for reporting @agschrei . Fix will be included in the upcoming v1.6 specification.

  12. added a commit that references this issue on Apr 9, 2024
  13. added a commit that references this issue on Jan 27, 2026
  14. added 2 commits that reference this issue on Feb 23, 2026
    f0d66c1
    1d5c493
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions