You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
@CyberDaedalus00 thanks for reporting this! You're right in that we modified the parsing code to remove the gds_parse_datetime usage; its been a while, but I believe it was because it caused issues when dumping parsed MAEC XML documents as JSON:
This is related to the CybOX issue I linked to above. Once we have consensus on the solution, we may able to revert the bindings to function as before.
@ikiril01: I believe that the commit you reference has the effect of treating dates parsed from XML as strings rather than date-times. I don't think that's we want to work with them in the Python APIs; better to use the Python datetime class.
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.
The text was updated successfully, but these errors were encountered: