admin-ch / CovidCertificate-Apidoc

API documentation for the integration of primary systems with the machine to machine API
73 stars 7 forks source link

Rules are not valid CertLogic #30

Open davemecha opened 2 years ago

davemecha commented 2 years ago

Hi,

I fetched rules from the Verification API to verify a covid certificate. I used certlogic-js for verification but I had problems with the date-related rules.

As discussed in an issue in the certlogic-js project the rules do not seem to follow the specification.

For example, the rules TR-CH-0005 and TR-CH-0006 are using the wrong operators for date comparison.

     {
        "inputParameter":"[\"t.0\",\"t.0.sc\"]",
        "description":"The date of sample collection must be before the validation date",
        "id":"TR-CH-0005",
        "logic":{
           "if":[
              {
                 "var":"payload.t.0"
              },
              {
                 "<":[
                    {
                       "plusTime":[
                          {
                             "var":"payload.t.0.sc"
                          },
                          0,
                          "day"
                       ]
                    },
                    {
                       "plusTime":[
                          {
                             "var":"external.validationClock"
                          },
                          0,
                          "day"
                       ]
                    }
                 ]
              },
              true
           ]
        }
     },
     {
        "inputParameter":"[\"t.0.tt\",\"t.0.sc\"]",
        "description":"If the test type is \"RAT\" then the validation date must be before the date of sample collection plus 48 hours",
        "id":"TR-CH-0006",
        "logic":{
           "if":[
              {
                 "===":[
                    {
                       "var":"payload.t.0.tt"
                    },
                    "LP217198-3"
                 ]
              },
              {
                 "<":[
                    {
                       "plusTime":[
                          {
                             "var":"external.validationClock"
                          },
                          0,
                          "day"
                       ]
                    },
                    {
                       "plusTime":[
                          {
                             "var":"payload.t.0.sc"
                          },
                          48,
                          "hour"
                       ]
                    }
                 ]
              },
              true
           ]
        }
     },

This rule does not return a boolean:

     {
        "inputParameter":"[\"t.0\",\"t.0.sc\"]",
        "description":"Date of sample collection must exist",
        "id":"TR-CH-0004",
        "logic":{
           "if":[
              {
                 "var":"payload.t.0"
              },
              {
                 "var":"payload.t.0.sc"
              },
              true
           ]
        }
     },

I'm not sure if this is a valid issue here, but I'd be happy for help, since I'm trying to create a verification implementation in node-js.

Thanks :)