Repository navigation
AttributeError: 'list' object has no attribute 'isoformat' #350
Description
instance.stix_xml = package.to_xml()
File "/home/ubuntu/ctix-2/venv/lib/python3.5/site-packages/stix/base.py", line 141, in to_xml
obj = self.to_obj(ns_info=ns_info if auto_namespace else None)
File "/home/ubuntu/ctix-2/venv/lib/python3.5/site-packages/mixbox/entities.py", line 304, in to_obj
val = _objectify(field, val, ns_info)
File "/home/ubuntu/ctix-2/venv/lib/python3.5/site-packages/mixbox/entities.py", line 32, in _objectify
return value.to_obj(ns_info=ns_info)
File "/home/ubuntu/ctix-2/venv/lib/python3.5/site-packages/mixbox/entities.py", line 300, in to_obj
val = [_objectify(field, x, ns_info) for x in val]
File "/home/ubuntu/ctix-2/venv/lib/python3.5/site-packages/mixbox/entities.py", line 300, in
val = [_objectify(field, x, ns_info) for x in val]
File "/home/ubuntu/ctix-2/venv/lib/python3.5/site-packages/mixbox/entities.py", line 32, in _objectify
return value.to_obj(ns_info=ns_info)
File "/home/ubuntu/ctix-2/venv/lib/python3.5/site-packages/mixbox/entities.py", line 304, in to_obj
val = _objectify(field, val, ns_info)
File "/home/ubuntu/ctix-2/venv/lib/python3.5/site-packages/mixbox/entities.py", line 32, in _objectify
return value.to_obj(ns_info=ns_info)
File "/home/ubuntu/ctix-2/venv/lib/python3.5/site-packages/mixbox/entities.py", line 304, in to_obj
val = _objectify(field, val, ns_info)
File "/home/ubuntu/ctix-2/venv/lib/python3.5/site-packages/mixbox/entities.py", line 32, in _objectify
return value.to_obj(ns_info=ns_info)
File "/home/ubuntu/ctix-2/venv/lib/python3.5/site-packages/mixbox/entities.py", line 304, in to_obj
val = _objectify(field, val, ns_info)
File "/home/ubuntu/ctix-2/venv/lib/python3.5/site-packages/mixbox/entities.py", line 32, in _objectify
return value.to_obj(ns_info=ns_info)
File "/home/ubuntu/ctix-2/venv/lib/python3.5/site-packages/cybox/common/object_properties.py", line 87, in to_obj
obj = super(ObjectProperties, self).to_obj(ns_info=ns_info)
File "/home/ubuntu/ctix-2/venv/lib/python3.5/site-packages/mixbox/entities.py", line 304, in to_obj
val = _objectify(field, val, ns_info)
File "/home/ubuntu/ctix-2/venv/lib/python3.5/site-packages/mixbox/entities.py", line 32, in _objectify
return value.to_obj(ns_info=ns_info)
File "/home/ubuntu/ctix-2/venv/lib/python3.5/site-packages/mixbox/entities.py", line 304, in to_obj
val = _objectify(field, val, ns_info)
File "/home/ubuntu/ctix-2/venv/lib/python3.5/site-packages/mixbox/entities.py", line 32, in _objectify
return value.to_obj(ns_info=ns_info)
File "/home/ubuntu/ctix-2/venv/lib/python3.5/site-packages/cybox/common/properties.py", line 204, in to_obj
attr_obj = super(BaseProperty, self).to_obj(ns_info=ns_info)
File "/home/ubuntu/ctix-2/venv/lib/python3.5/site-packages/cybox/common/attribute_groups.py", line 73, in to_obj
obj = super(PatternFieldGroup, self).to_obj(ns_info=ns_info)
File "/home/ubuntu/ctix-2/venv/lib/python3.5/site-packages/mixbox/entities.py", line 304, in to_obj
val = _objectify(field, val, ns_info)
File "/home/ubuntu/ctix-2/venv/lib/python3.5/site-packages/mixbox/entities.py", line 33, in _objectify
return field.binding_value(value)
File "/home/ubuntu/ctix-2/venv/lib/python3.5/site-packages/mixbox/fields.py", line 365, in binding_value
return serialize_datetime(value)
File "/home/ubuntu/ctix-2/venv/lib/python3.5/site-packages/mixbox/dates.py", line 41, in serialize_datetime
return value.isoformat()
AttributeError: 'list' object has no attribute 'isoformat'
date(its a field in EmailHeader of EmailMessage) is of type DateTime which has value of list type.
Activity
gtback commentedon May 24, 2018
Hi @ajnovice . Can you provide a sample STIX Package (or code to create the package) that demonstrates this problem. If I understand correctly, it may be as simple as "if the value is a list, call
isoformaton every item in the list rather than on the list itself", but want to make sure I'm solving the problem in the right place. Thanks!ajnovice commentedon May 26, 2018
Below is the code of
DateTimeclass.As we can seevalueis ofListDateTimeFieldBut
serialize_datetimeinmixbox/dates.pyserialize only scalar value.So have made the following change in
serialize_datetimeAfter making above changes, everything is working fine.
PS: Please check changes,if you want I would push the changes.
gtback commentedon Jun 6, 2018
Thanks for the additional information, @ajnovice ! I don't think we should make a change in
serialize_datetime, which is supposed to work on scalar values. It's likely somewhere in python-cybox (which allows fields to contain both single values or lists of values) that we should make this change. I'll create an issue there.