-
Notifications
You must be signed in to change notification settings - Fork 41
get_payload(decode=True) Returns None Causes Crash #28
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't working
Description
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
- Obtain an
.emlwith amultipart/mixedstructure containing amultipart/alternativesub-part - Run
python3 email-analyzer.py -f sample.eml -a - 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()Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working