Update types, allow 0 as attribute value

pull/63/head
Raphaël Vinot 2017-03-12 23:05:13 +01:00
parent e029b60455
commit 638ad3d4b7
2 changed files with 13 additions and 7 deletions

View File

@ -69,6 +69,10 @@
"default_category": "Payload delivery", "default_category": "Payload delivery",
"to_ids": 1 "to_ids": 1
}, },
"float": {
"default_category": "Other",
"to_ids": 0
},
"url": { "url": {
"default_category": "External analysis", "default_category": "External analysis",
"to_ids": 1 "to_ids": 1
@ -544,6 +548,7 @@
"email-dst", "email-dst",
"email-subject", "email-subject",
"email-attachment", "email-attachment",
"float",
"url", "url",
"http-method", "http-method",
"user-agent", "user-agent",
@ -998,14 +1003,15 @@
"other" "other"
], ],
"Other": [ "Other": [
"comment",
"text",
"other",
"size-in-bytes", "size-in-bytes",
"counter", "counter",
"datetime", "datetime",
"cpe", "cpe",
"port", "port",
"comment", "float"
"text",
"other"
] ]
} }
} }

View File

@ -130,9 +130,9 @@ class MISPAttribute(object):
type_defaults = self.sane_default[self.type] type_defaults = self.sane_default[self.type]
if kwargs.get('value'): self.value = kwargs.get('value')
self.value = kwargs['value']
elif not self.value: if self.value is None:
raise NewAttributeError('The value of the attribute is required.') raise NewAttributeError('The value of the attribute is required.')
# Default values # Default values
@ -444,7 +444,7 @@ class MISPEvent(object):
raise NewEventError('{} is invalid, the analysis has to be in 0, 1, 2'.format(self.analysis)) raise NewEventError('{} is invalid, the analysis has to be in 0, 1, 2'.format(self.analysis))
if kwargs.get('published') is not None: if kwargs.get('published') is not None:
self.unpublish() self.unpublish()
if kwargs.get("published") == True: if kwargs.get("published") is True:
self.publish() self.publish()
if kwargs.get('date'): if kwargs.get('date'):
self.set_date(kwargs['date']) self.set_date(kwargs['date'])