From 41d4959422269f0b550c23afb33b1e8c1ab0ea66 Mon Sep 17 00:00:00 2001 From: Thibault Cohen <47721+titilambert@users.noreply.github.com> Date: Thu, 19 Jan 2023 20:17:53 -0500 Subject: [PATCH] Raise error when fields is not present or empty --- src/kv.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/kv.py b/src/kv.py index 409b929..c5d3e0c 100644 --- a/src/kv.py +++ b/src/kv.py @@ -19,11 +19,17 @@ def create_kv(secret, secret_json, content_def): if key == "secretScope": _secret_scope = value if _secret_scope == "login": + value = parse_login_scope(secret_json, _secret_key) + if value is None: + raise Exception(f"Field {_secret_key} has no value in bitwarden secret") secret.data[_secret_ref] = str(base64.b64encode( - parse_login_scope(secret_json, _secret_key).encode("utf-8")), "utf-8") + value.encode("utf-8")), "utf-8") if _secret_scope == "fields": + value = parse_fields_scope(secret_json, _secret_key) + if value is None: + raise Exception(f"Field {_secret_key} has no value in bitwarden secret") secret.data[_secret_ref] = str(base64.b64encode( - parse_fields_scope(secret_json, _secret_key).encode("utf-8")), "utf-8") + value.encode("utf-8")), "utf-8") return secret