fix: [stix export] Fixed email attachment export

- Fixed condition trying to reach the case where
  we have an attachment attribute in the object,
  which was never true because of a wrong key
  testing
- Fixed the email attachment related file object
  creation initiation
pull/4605/head
chrisr3d 2019-05-08 11:09:24 +02:00
parent 62f15433e4
commit 2b23f1e5b7
No known key found for this signature in database
GPG Key ID: 6BBED1B63A6D639F
1 changed files with 5 additions and 4 deletions

View File

@ -791,9 +791,9 @@ class StixBuilder(object):
if 'user-agent' in attributes_dict:
email_header.user_agent = attributes_dict['user-agent'][0]['value']
email_header.user_agent.condition = "Equals"
if 'email-attachment' in attributes_dict:
email.attachments = Attachments()
for attachment in attributes_dict['email-attachment']:
if 'attachment' in attributes_dict:
email_object.attachments = Attachments()
for attachment in attributes_dict['attachment']:
attachment_file = self.create_file_attachment(attachment['value'], attachment['uuid'])
email_object.add_related(attachment_file, "Contains", inline=True)
email_object.attachments.append(attachment_file.parent.id_)
@ -1374,7 +1374,8 @@ class StixBuilder(object):
return domain_observable
def create_file_attachment(self, value, uuid):
file_object = File(file_name=value)
file_object = File()
file_object.file_name = value
file_object.file_name.condition = "Equals"
file_object.parent.id_ = "{}:FileObject-{}".format(self.namespace_prefix, uuid)
return file_object