Skip to content

[V3.1.3 Backport] fix(schema): use anyOf where BNF allows mixed inline and named groups#612

Open
sebbader-sap wants to merge 2 commits into
IDTA-01001-3-1-3_workingfrom
backport/v3.1.3/pr581-anyof-schema
Open

[V3.1.3 Backport] fix(schema): use anyOf where BNF allows mixed inline and named groups#612
sebbader-sap wants to merge 2 commits into
IDTA-01001-3-1-3_workingfrom
backport/v3.1.3/pr581-anyof-schema

Conversation

@sebbader-sap
Copy link
Copy Markdown
Contributor

Backport from PR #581

This is a backport of the bugfix from PR #581 to the V3.1.3 release branch.

Original PR Description

This PR addresses a mismatch between BNF grammar and JSON Schema validation. The BNF distinguishes between concatenation (allowing mixed variants) and alternation (exactly one), but the schemas incorrectly used oneOf for concatenation cases.

Changes Made:

  • Converted oneOf to anyOf for three concatenation pairs:
    • ACL.{ATTRIBUTES, USEATTRIBUTES}
    • AccessPermissionRule.{OBJECTS, USEOBJECTS}
    • DEFATTRIBUTES item.{attributes, USEATTRIBUTES}
  • Retained oneOf for true XOR scenarios (ACL/USEACL, FORMULA/USEFORMULA pairs)

Impact: This relaxes schema validation to align with grammar specifications. Previously valid documents remain valid; additionally, documents combining inline and named groups now validate correctly.

Related

The BNF distinguishes concatenation (mix allowed) from alternation
(XOR) for the pairs inline-group / named-group. Three pairs in the
JSON schemas were marked oneOf (XOR) even though the grammar is CAT.

Grammar references (access-rules.bnf / grammar.bnf):

  <AttributeGroup> ::=
      ( <SingleAttribute> <ws> )*
      ( <UseAttributeGroup> <ws> )*     -- CAT

  <AccessPermissionRule> ::=
      "ACCESSRULE:" ...
      ( <ACL> | <UseACL> ) <ws>          -- XOR
      "OBJECTS:" <ws>
      ( <SingleObject> <ws> )*
      ( <UseObjectGroup> <ws> )*         -- CAT (inline, not <ObjectGroup>)
      ( "FORMULA:" ... | <UseFormula> )  -- XOR

Changes:

  - ACL.{ATTRIBUTES, USEATTRIBUTES}              oneOf -> anyOf
  - AccessPermissionRule.{OBJECTS, USEOBJECTS}   oneOf -> anyOf
  - DEFATTRIBUTES item.{attributes, USEATTRIBUTES} oneOf -> anyOf
    (only in aas-specs-security; API schema doesn't have USEATTRIBUTES
     at DEFATTRIBUTES level.)

Kept as oneOf (XOR):

  - AccessPermissionRule.{ACL, USEACL}
  - AccessPermissionRule.{FORMULA, USEFORMULA}
  - DEFOBJECTS item.{objects, USEOBJECTS}
  - SecurityQueryFilter.{CONDITION, USEFORMULA}

Refs: Review Finding T-13
Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants