fix: [stix2 export] Making sure timestamps are always converted into the format STIX likes

pull/7387/head
chrisr3d 2021-04-29 20:05:38 +02:00
parent 3653e62fd8
commit 32849b1087
No known key found for this signature in database
GPG Key ID: 6BBED1B63A6D639F
1 changed files with 1 additions and 1 deletions

View File

@ -1822,7 +1822,7 @@ class StixBuilder():
@staticmethod
def handle_time_fields(attribute, timestamp, stix_type):
to_return = {'created': timestamp, 'modified': timestamp}
iso_timestamp = timestamp.isoformat(timespec='milliseconds')
iso_timestamp = f"{timestamp.isoformat(timespec='milliseconds')}Z"
for misp_field, stix_field in zip(('first_seen', 'last_seen'), _time_fields[stix_type]):
to_return[stix_field] = datetime.strptime(attribute[misp_field].split('+')[0], '%Y-%m-%dT%H:%M:%S.%f') if attribute.get(misp_field) else iso_timestamp
return to_return