anweiss / cddl

Concise data definition language (RFC 8610) implementation and JSON and CBOR validator in Rust
https://cddl.anweiss.tech
MIT License
91 stars 13 forks source link

Tagged data seems not to work as expected #173

Closed hansl closed 1 year ago

hansl commented 1 year ago

The following CDDL:

start = [ * help ]

help = #6.123(bstr)

With the following CBOR (diag notation, hex is 81D87B4100):

[ 123(h'00') ]

Does not validate using this library. The Ruby cddl gem validates it correctly. The errors are as follow:

$ cddl validate --cddl 2.cddl --cbor 2.cbor                                                                                                                                                                                                          
[ERROR] Validation of "5.cbor" failed: error validating group entry associated with rule "help" at cbor location : expected tagged data #6.123("hello"), got Array([Tag(123, Text("hello"))])

Edit: I just tested with the main branch and I get the same result. Edit2: further simplified the CDDL and CBOR.

hansl commented 1 year ago

Note that the CDDL validates properly, the CBOR does not.

hansl commented 1 year ago

Creating some tests for the CBOR validation, it seems like maps and arrays don't properly visit the CBOR itself, instead staying at the root of the array/map. I'm still investigating and may come up with a PR to fix, as this is a very important tool for us.

anweiss commented 1 year ago

Fixed in #203. Re-open if needed.