It appears the generated parsing code is incorrect with regards to the parsing of xs:date, xs:time, and xs:datetime in the bindings API of python-maec 4.1.0.9. The attributes are actually python strings instead of python datetime.
As an example of the source of this, the parsing of the 'start_datetime' attribute on the AnalysisType complexType is handled as follows:
value = find_attr_value_('start_datetime', node)
if value is not None and 'start_datetime' not in already_processed:
already_processed.add('start_datetime')
try:
self.start_datetime = value
except ValueError, exp:
raise ValueError('Bad date-time attribute (start_datetime): %s' % exp)
but should be handled as follows, as is done in the handling of equivalent types in the python-stix Bindings API:
value = find_attr_value_('timestamp', node)
if value is not None and 'timestamp' not in already_processed:
already_processed.add('timestamp')
try:
self.timestamp = self.gds_parse_datetime(value, node, 'timestamp')
except ValueError, exp:
raise ValueError('Bad date-time attribute (timestamp): %s' % exp)
The issue is the 'value' returned from find-attr_value is a python string and needs to be converted to a datetime object by calling self.gds_parse_datetime(). Given that self.gds_validate_datetime() wasn't called nor was self.gds_parse_datetime() was call and yet there is exception handling, it appears as if the parsing code was modified.
It appears the generated parsing code is incorrect with regards to the parsing of xs:date, xs:time, and xs:datetime in the bindings API of python-maec 4.1.0.9. The attributes are actually python strings instead of python datetime.
As an example of the source of this, the parsing of the 'start_datetime' attribute on the AnalysisType complexType is handled as follows:
but should be handled as follows, as is done in the handling of equivalent types in the python-stix Bindings API:
The issue is the 'value' returned from find-attr_value is a python string and needs to be converted to a datetime object by calling self.gds_parse_datetime(). Given that self.gds_validate_datetime() wasn't called nor was self.gds_parse_datetime() was call and yet there is exception handling, it appears as if the parsing code was modified.