cddl
cddl copied to clipboard
Validation always fails for CBOR with non-standard simple values
Seems like cddl is unable to validate any CBOR binary that uses non-standard simple values, instead producing
Validation of "filename.cbor" failed
error parsing cbor: unassigned type at offset X
As far as I understand this is due to serde_cbor intentionally producing parser error when it encounters any simple value it doesn't understand.
Is there any workaround for that or the fix would be to replace serde_cbor with other library?
hey @Anrock, thanks for highlighting this. Indeed, this is due to error in the serde_cbor
library as you indicated. Given that https://github.com/pyfisch/cbor is now archived and no longer being maintained, I plan to replace it with a different library.
@anweiss not sure if it's fixed with ciborium. I just compiled 8d398daf and tried to validate same cbor against cddl spec and got
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Semantic(None, "invalid type: simple, expected known simple value")', src/validator/mod.rs:169:76
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Seems like it's the same thing with ciborium too - it intentionally produces an error on any custom simple value it doesn't know about
hey @Anrock, can you provide the CDDL you are using that is causing this error?
@anweiss I don't think it's the CDDL itself but a cbor binary. Minimal repro should be just a simple
value from unassigned range, like 40 or 41 (CDDL #7.40
or #7.41
). I'll try to get minimal repro tomorrow.
@anweiss okay, I got minimal repro.
cddl: root = #7.32
cbor: f820
.
I don't think I can attach a binary file in github, but you can easily create it via echo f820 | xxd -p -r > min.cbor
Then running ./cddl validate --cddl min.cddl --cbor min.cbor
will produce
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Semantic(None, "invalid type: simple, expected known simple value")', src/validator/mod.rs:169:76
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Thanks @Anrock for reporting this. Putting this in the backlog until https://github.com/enarx/ciborium/issues/60 is looked at.