fix: Properly strip value in MISPObject.add_attribute

Fix #546
pull/591/head
Raphaël Vinot 2020-05-29 00:56:28 +02:00
parent 5d97d7ee0c
commit 524aa13641
1 changed files with 2 additions and 0 deletions

View File

@ -845,6 +845,8 @@ class MISPObject(AbstractMISP):
dictionary with all the keys supported by MISPAttribute"""
if simple_value is not None: # /!\ The value *can* be 0
value = {'value': simple_value}
# Make sure we're not adding an empty value.
value['value'] = value['value'].strip()
if value.get('value') in [None, '']:
logger.warning("The value of the attribute you're trying to add is None or empty string, skipping it. Object relation: {}".format(object_relation))
return None