Skip to content

Commit e489bee

Browse files
author
Sebastian Wagner
committed
Merge branch 'maintenance' into develop
2 parents 09e1d59 + d87ec6a commit e489bee

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ CHANGELOG
5050
### Core
5151
- `intelmq.lib.bot_debugger`: Fix accessing the bot's destination queues (PR#2027 by Mikk Margus Möll).
5252
- `intelmq.lib.pipeline`: Fix handling of `load_balance` parameter (PR#2027 by Mikk Margus Möll).
53+
- `intelmq.lib.bot`: Fix handling of parameter `destination_queues` if value is an empty dictionary (PR#2051 by Sebastian Wagner, fixes #2034).
5354

5455
### Development
5556

@@ -76,6 +77,7 @@ CHANGELOG
7677
#### Outputs
7778
- `intelmq.bots.outputs.mcafee.output_esm_ip`: Fix access to parameters, the bot wrongly used `self.parameters` (by Sebastian Wagner).
7879
- `intelmq.bots.outputs.misp.output_api`: Fix access to parameters, the bot wrongly used `self.parameters` (by Sebastian Wagner).
80+
- `intelmq.bots.outputs.smtp.output`: Add `Content-Disposition`-header to the attachment, fixing the display in Mail Clients as actual attachment (PR#2052 by Sebastian Wagner, fixes #2018).
7981

8082
### Documentation
8183
- Various formatting fixes (by Sebastian Wagner).

intelmq/bots/outputs/smtp/output.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ def process(self):
7070
if self.text is not None:
7171
msg.attach(MIMEText(self.text.format(ev=event)))
7272
if self.fieldnames:
73-
msg.attach(MIMEText(attachment, 'csv'))
73+
mime_attachment = MIMEText(attachment, 'csv')
74+
mime_attachment.add_header("Content-Disposition", "attachment", filename="events.csv")
75+
msg.attach(mime_attachment)
7476
msg['Subject'] = self.subject.format(ev=event)
7577
msg['From'] = self.mail_from.format(ev=event)
7678
msg['To'] = self.mail_to.format(ev=event)

intelmq/lib/bot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class Bot(object):
6464
destination_pipeline_host: str = "127.0.0.1"
6565
destination_pipeline_password: Optional[str] = None
6666
destination_pipeline_port: int = 6379
67-
destination_queues: Optional[dict] = None
67+
destination_queues: dict = {}
6868
error_dump_message: bool = True
6969
error_log_exception: bool = True
7070
error_log_message: bool = False
@@ -389,7 +389,7 @@ def start(self, starting: bool = True, error_on_pipeline: bool = True,
389389
warnings.warn("Message will be removed from the pipeline and not dumped to the disk. "
390390
"Set `error_dump_message` to true to save the message on disk. "
391391
"This warning is only shown once in the runtime of a bot.")
392-
if self.destination_queues and '_on_error' in self.destination_queues:
392+
if '_on_error' in self.destination_queues:
393393
self.send_message(self.__current_message, path='_on_error')
394394

395395
if message_to_dump or self.__current_message:
@@ -563,7 +563,7 @@ def __connect_pipelines(self):
563563
self.__current_message = None
564564
self.logger.debug("Connected to source queue.")
565565

566-
if self.destination_queues is not None:
566+
if self.destination_queues:
567567
self.logger.debug("Loading destination pipeline and queues %r.", self.destination_queues)
568568
self.__destination_pipeline = PipelineFactory.create(logger=self.logger,
569569
direction="destination",

intelmq/tests/bots/outputs/smtp/test_output.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ def test_event(self):
5151
''')
5252
self.assertEqual({'from_addr': 'myself', 'to_addrs': ['you', 'yourself']},
5353
SENT_MESSAGE[1])
54+
# https://github.com/certtools/intelmq/issues/2018
55+
self.assertIn(('Content-Disposition', 'attachment; filename="events.csv"'),
56+
SENT_MESSAGE[0].get_payload()[1]._headers)
5457

5558
def test_multiple_recipients_event(self):
5659
"""

0 commit comments

Comments
 (0)