Skip to content

extract_msg.signed_attachment.save returning Message object after data has been written to disk #372

@cccs-rs

Description

@cccs-rs

Bug Metadata

  • Version of extract_msg: [0.41.5]
  • Your python version: Python [3.9.15]
  • How did you launch extract_msg?
    • My command line or
    • I used the extract_msg package

Describe the bug
Is there a reason why extract_msg.signed_attachment.save() returns back the Message object instead of null or the path to the written file?

else:
if kwargs.get('extractEmbedded', False):
with _open(str(fullFilename), mode) as f:
# We just use the data we were given for this one.
f.write(self.__asBytes)
else:
self.saveEmbededMessage(**kwargs)
# Close the ZipFile if this function created it.
if _zip and createdZip:
_zip.close()
return self.msg

**What code did you use or can we use to reproduce this error?

            try:
                ret_value = attachment.save(customPath=self.working_directory,
                                            customFilename=customFilename, extractEmbedded=True)
            except Exception:
                continue

            if isinstance(attachment, extract_msg.signed_attachment.SignedAttachment):
                attachment_name = os.path.basename(ret_value)
                attachment_path = ret_value

Traceback

  File "/var/lib/assemblyline/.local/lib/python3.9/site-packages/assemblyline_v4_service/common/base.py", line 169, in handle_task
    self.execute(request)
  File "/opt/al_service/emlparser/emlparser.py", line 50, in execute
    self.handle_outlook(request)
  File "/opt/al_service/emlparser/emlparser.py", line 167, in handle_outlook
    attachment_name = os.path.basename(ret_value)
  File "/usr/local/lib/python3.9/posixpath.py", line 142, in basename
    p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not MessageSigned

Additional context
self.type == AttachmentType.SIGNED

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions