Skip to content

get_payload(decode=True) Returns None Causes Crash #28

@keraattin

Description

@keraattin

Bug Description
get_attachments() passes the result of attachment.get_payload(decode=True) directly to hashlib.md5(). For multipart sub-parts, get_payload(decode=True) returns None, causing hashlib.md5(None) to raise a TypeError and crash all attachment analysis.

Expected Behavior or Results
Attachments with undecodable payloads should be skipped or logged as "payload unavailable" rather than crashing.

Reproduce Steps

  1. Obtain an .eml with a multipart/mixed structure containing a multipart/alternative sub-part
  2. Run python3 email-analyzer.py -f sample.eml -a
  3. Observe TypeError: Strings must be encoded before hashing

Desktop (please complete the following information):

  • OS with Version: Any
  • Python Version: Python 3.10+
  • EmailAnalyzer Project Version: v2.0

Additional context
Affected code — email-analyzer.py lines 185–187:

attached_file["MD5"]    = hashlib.md5(attachment.get_payload(decode=True)).hexdigest()
attached_file["SHA1"]   = hashlib.sha1(attachment.get_payload(decode=True)).hexdigest()
attached_file["SHA256"] = hashlib.sha256(attachment.get_payload(decode=True)).hexdigest()

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions