diff options
| author | Yuval Adam <_@yuv.al> | 2021-03-17 23:33:31 +0200 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2021-03-17 23:33:31 +0200 |
| commit | c105914f8341d5c6135d077b879a26db13679ded (patch) | |
| tree | a958a4786ed83c76c804a6796ecb93e063cfd85d | |
| parent | 66e098b0d9c200271412fd92e9a2e677ec7fbb4c (diff) | |
Add bytes validation and warn on no signature
| -rw-r--r-- | verify.py | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -15,6 +15,8 @@ from pyzbar import pyzbar class GreenPassVerifier(object): def __init__(self, data_bytes): + self.validate_bytes(data_bytes) + sig, self.payload = data_bytes.split(b"#", maxsplit=1) self.signature = base64.decodebytes(sig) self.data = json.loads(self.payload) @@ -48,6 +50,15 @@ class GreenPassVerifier(object): data = img.getImageData(output="png") return cls.from_qr(BytesIO(data)) + def validate_bytes(self, bs): + if bs.decode().startswith("GreenPass"): + click.secho( + "⚠️ Green pass QR code contains no signature to verify", + fg="yellow", + bold=True, + ) + click.get_current_context().exit() + def validate_data(self): ct = self.data["ct"] if ct not in (1, 2): |
