Open
Description
Describe the bug
Metachema definition
Metaschema defines the top-level catalog/group (recursing by refs) as follows (note; it is a choice
without attributes):
<choice>
<assembly ref="group" max-occurs="unbounded">
<group-as name="groups" in-json="ARRAY"/>
</assembly>
<assembly ref="control" max-occurs="unbounded">
<group-as name="controls" in-json="ARRAY"/>
</assembly>
</choice>
I assume that the defaults in Metaschema match XSD ones and fall back to min/max-Occurs defaulting to 1
XSD schema definition
Ends up as follows:
<xs:choice>
<xs:element name="group"
type="oscal-catalog-group-ASSEMBLY"
minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="control"
type="oscal-catalog-control-ASSEMBLY"
minOccurs="0"
maxOccurs="unbounded"/>
</xs:choice>
which considering mixOccurs and maxOccurs defaulting to 1 => we have effectively an Exclusive OR
JSON Schema on the other hand
Has a plain no-choice-restricted definition (excerpt is larger than the two above to illustrate the context):
"params" :
{ "type" : "array",
"minItems" : 1,
"items" :
{ "$ref" : "#assembly_oscal-control-common_parameter" } },
"controls" :
{ "type" : "array",
"minItems" : 1,
"items" :
{ "$ref" : "#assembly_oscal-catalog_control" } },
"groups" :
{ "type" : "array",
"minItems" : 1,
"items" :
{ "$ref" : "#assembly_oscal-catalog_group" } },
"back-matter" :
{ "$ref" : "#assembly_oscal-metadata_back-matter" } },
"required" :
[ "uuid",
"metadata" ],
while the XSD equivalent, probably should be:
"params" :
{ "type" : "array",
"minItems" : 1,
"items" :
{ "$ref" : "#assembly_oscal-control-common_parameter" } },
//========= CHANGE-START =========
"oneOf":[
"controls" :
{ "type" : "array",
"minItems" : 1,
"items" : { "$ref" : "#assembly_oscal-catalog_control" }
},
"groups" :
{ "type" : "array",
"minItems" : 1,
"items" : { "$ref" : "#assembly_oscal-catalog_group" }
},
],
//=========== CHANGE-END ===========
"back-matter" :
{ "$ref" : "#assembly_oscal-metadata_back-matter" } },
"required" :
[ "uuid",
"metadata" ],
Who is the bug affecting
People who try to validate "inventive" and "non-classical" JSON catalogs
When groups and controls mixed together in "twigs and leaves in same bag"-style, which is allowed by OSCAL JSON Schema, but isn't allowed by Metaschema, XSD, and OSCAL-CLI tool, the catalog-authors get confused.
What is affected by this bug
Modeling
How do we replicate this issue
- Create JSON catalog with top-level group that contains a more than 0 groups and more than 0 controls of the depth 2
- Validate the catalog with JSON Schema (player's choice: AJV, Oxygen, etc...)
- Validate the catalog with CLI tool
- Notice the difference
Expected behavior (i.e. solution)
Difference should be not be noticeable
Other comments
No response
Revisions
No response
Metadata
Metadata
Type
Projects
Status
Needs Triage