Skip to content

Commit

Permalink
added null checks for vault record field value sanitizations
Browse files Browse the repository at this point in the history
  • Loading branch information
aaunario-keeper committed Oct 6, 2023
1 parent fcb1d25 commit 24c3d76
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion keepercommander/vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def sanitize_str_field_value(value): # type: (Any) -> str
return value


def sanitize_int_field_value(value, *, default=0): # type: (Any, *Any, **Any) -> int
def sanitize_int_field_value(value, *, default=0): # type: (Any, *Any, Optional[Any]) -> int
if not isinstance(value, int):
try:
value = int(value)
Expand Down Expand Up @@ -204,13 +204,15 @@ def new_field(cls, name, value):

class AttachmentFileThumb:
def __init__(self, thumb_field=None): # type: (Optional[dict]) -> None
thumb_field = thumb_field or {}
self.id = sanitize_str_field_value(thumb_field.get('id'))
self.type = sanitize_str_field_value(thumb_field.get('type'))
self.size = sanitize_int_field_value(thumb_field.get('size'))


class AttachmentFile(object):
def __init__(self, file_field=None): # type: (Optional[dict]) -> None
file_field = file_field or {}
self.id = sanitize_str_field_value(file_field.get('id'))
self.key = sanitize_str_field_value(file_field.get('key'))
self.name = sanitize_str_field_value(file_field.get('name'))
Expand Down

0 comments on commit 24c3d76

Please sign in to comment.