italia / verificac19-sdk

✅ Official VerificaC19 Node.js SDK
MIT License
49 stars 17 forks source link

[#36] fix - bug TEST_NEEDED on newer three doses qr #37

Closed depontimatteo closed 2 years ago

depontimatteo commented 2 years ago

Description

As already mentioned in #36, this PR tackles:

Trying to validate several third doses Moderna Green Pass Certificates with VISITORS_RSA scan mode, the validate function returns TEST_NEEDED uncorrectly. Doing some reverse engineering, we've found that third doses Green Pass Certificates are uncorrectly defined with validationStatus = complete, which represent just a complete cycle Green Pass Certificate (two doses or one dose for Johnson&Johnson), instead of a validationStatus = booster (check code at line 168 of validator.js).

This issue happens because of a bad comparison of last.doseNumber > last.totalSeriesOfDoses. My personal Green Pass certificate (three doses) and some others have doseNumber = 3 and totalSeriesOfDoses = 3, in this situation, the condition will be always false and all the newer Green Pass Certificates with totalSeriesOfDoses = 3 will fail the validation.

codecov[bot] commented 2 years ago

Codecov Report

Merging #37 (6110a31) into master (72bdf7f) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #37   +/-   ##
=======================================
  Coverage   98.43%   98.43%           
=======================================
  Files           8        8           
  Lines         511      511           
=======================================
  Hits          503      503           
  Misses          8        8           
Impacted Files Coverage Δ
src/validator.js 98.26% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 72bdf7f...6110a31. Read the comment docs.