Skip to content

Commit

Permalink
fix: Do not fail if the attribute value is not a string
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafiot committed May 28, 2020
1 parent 74a5d04 commit 1e9eed1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pymisp/mispevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -850,10 +850,11 @@ def add_attribute(self, object_relation: str, simple_value: Optional[Union[str,
return None
else:
# Make sure we're not adding an empty value.
value['value'] = value['value'].strip()
if value['value'] == '':
logger.warning("The value of the attribute you're trying to add is an empty string, skipping it. Object relation: {}".format(object_relation))
return None
if isinstance(value['value'], str):
value['value'] = value['value'].strip()
if value['value'] == '':
logger.warning("The value of the attribute you're trying to add is an empty string, skipping it. Object relation: {}".format(object_relation))
return None
if self._known_template and self._definition:
if object_relation in self._definition['attributes']:
attribute = MISPObjectAttribute(self._definition['attributes'][object_relation])
Expand Down

0 comments on commit 1e9eed1

Please sign in to comment.