MISP / mail_to_misp

Connect your mail client/infrastructure to MISP in order to create events based on the information contained within mails.
GNU Affero General Public License v3.0
69 stars 25 forks source link

AttributeError: 'bytes' object has no attribute 'encode'. Did you mean: 'decode'? #76

Open m-kas opened 1 year ago

m-kas commented 1 year ago

I encountered an issue while using the mail_to_misp extension with my newly configured MISP server.

Upon sending an email to the configured address, I noticed the following entries in the server logs:

28803    May 19 06:49:23 misp3 mail_to_misp.py[7447]: Job started.
28804    May 19 06:49:23 misp3 postfix/local[7446]: B1931BDE2C: to=<misp_handler@my.misp.handler.com>, relay=local, delay=1.1, delays=0.09/0.01/0/1, dsn=5.3.0, status=bounced
(Command died with status 1: "/usr/local/src/mail_to_misp/mail_to_misp.py -". Command output: Traceback (most recent call last): File "/usr/local/src/mail_to_misp/mail_to_misp.py", line 50, in <module> pseudofile = BytesIO(args.infile.read().encode('utf8', 'surrogateescape'))
AttributeError: 'bytes' object has no attribute 'encode'. Did you mean: 'decode'? )

It appears that the mail successfully reaches the server and the script attempts to parse the message. However, the process crashes with an AttributeError on a specific line of the script, throwing the following error:

AttributeError: 'bytes' object has no attribute 'encode'. Did you mean: 'decode'?

Considering the above, I would greatly appreciate any insights or assistance you can provide regarding the possible cause of this error. I'm eager to resolve this issue and fully utilize the capabilities of the mail_to_misp plugin.