MISP / MISP/PyMISP

Adding mail flag to stats_report.py results in Unicode error

Open
#1,065 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
491
Forks
290
Avg merge
2d 8h
Merged PRs (30d)
3

Description

When calling stats.py, works fine with the date parameters, when adding the mail (-m) flag, results in the following error:

Traceback (most recent call last):
File "/var/www/MISP/PyMISP/examples/stats_report.py", line 405, in
print_report(report_body, attachments, smtp_from, smtp_to, smtp_server, misp_url)
File "/var/www/MISP/PyMISP/examples/stats_report.py", line 312, in print_report
server.sendmail(smtp_from, smtp_to, msg.as_string())
File "/usr/lib/python3.10/smtplib.py", line 875, in sendmail
msg = _fix_eols(msg).encode('ascii')
UnicodeEncodeError: 'ascii' codec can't encode characters in position 143201-143203: ordinal not in range(128)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with examples/stats_report.py, especially print_report and the server.sendmail call shown in the traceback. Reproduce the report using the date parameters and then the -m flag, checking the generated message for non-ASCII content. Done means the mail-enabled report sends successfully without the UnicodeEncodeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.