Skip to content

Missing .cbor and .cborseq control operators (RFC 8610 §3.8.4) #89

Description

@Mearman

RFC 8610 section 3.8.4 defines `.cbor`/`.cborseq` as control operators asserting that a `bstr`, once parsed as CBOR (or a sequence of CBOR items), matches the given type. This is the standard way to describe a byte string containing nested CBOR-encoded data -- exactly how COSE (RFC 9052) describes a `COSE_Sign1`'s protected header or payload field, for instance.

Neither operator is in `OPERATORS`/`OPERATORS_EXPECTING_VALUES` in `packages/cddl/src/parser.ts` today. `bstr .cbor sometype` currently crashes the parser (via the same underlying issue as #87 -- an unguarded `parseOperator()` call -- once #88 is merged it'll instead hit "expects a X property" from the operator not being recognised at all, rather than parsing).

I have a small patch (just the two operator-table additions, no new parsing logic needed since the operator's value is a plain type reference, which `parseOperator` already handles generically) and I'll open a PR.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions