ehn-dcc-development / hcert-kotlin

Kotlin multiplatform implementation of the HCERT/DCC specification
Apache License 2.0
25 stars 25 forks source link

Clarify Requirements for Schema Validation #20

Closed JesusMcCloud closed 3 years ago

JesusMcCloud commented 3 years ago

Currently, both the JVM target and the JS target do not support all JSON schema features. On JS, schema validation is known to not cover all aspects, on the JVM, further investigation is needed.

jnischler commented 3 years ago

first of all thanks for your awsome work. we are currently integrating your libraries into one of our android applications. integration is straight forward.

But we also stumbled across the this issue. Using the default code:

chain = DefaultChain.buildVerificationChain(repository)

a validator is created and added to the chain

DefaultSchemaValidationService()

https://github.com/ehn-dcc-development/hcert-kotlin/blob/main/src/jvmMain/kotlin/ehn/techiop/hcert/kotlin/chain/impl/DefaultSchemaValidationService.kt

the validate function always fails and sets the error to: CBOR_DESERIALIZATION_FAILED

and also hides the exception, I would recommend throwing the exception out of the validator. I would also recommend changing the error from CBOR_DESERIALIZATION_FAILED to something like SCHEMA_VALIDATION_FAILED.

The validator can't find the file "json/DCC.combined-schema.json". Also I am unable to provide the file to the validator as i can't find this file ;)

This one is the closest file I could find: https://github.com/ehn-dcc-development/ehn-dcc-schema/blob/release/1.3.0/DCC.combined-schema.json

For our first test we will create a Chain without a validator or with a very basic validator.

Thanks

JesusMcCloud commented 3 years ago

Thanks for the input! The file is located in src/commonMain/resources On Android resource loading like done in the code won't work and the schema validation library does not support .getResourceAsStream, which would work on Android. My bad for not considering Android! Until there's an official fix, you could replace the schema validation service with a NOOP one on Android. In addition, logging is already making progress.

JesusMcCloud commented 3 years ago

Commits bb1b569c4d97ebf54066ba81ff76ff3ecc204cc4 and 3cff16fc34f0ae5feff2f53242f5b2bfce1cfc88 should address both issues

jnischler commented 3 years ago

perfect thanks will run a new test asap