Skip to content

Commit

Permalink
Merge branch 'maintenance' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Wagner committed Aug 19, 2021
2 parents 09e1d59 + d87ec6a commit e489bee
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ CHANGELOG
### Core
- `intelmq.lib.bot_debugger`: Fix accessing the bot's destination queues (PR#2027 by Mikk Margus Möll).
- `intelmq.lib.pipeline`: Fix handling of `load_balance` parameter (PR#2027 by Mikk Margus Möll).
- `intelmq.lib.bot`: Fix handling of parameter `destination_queues` if value is an empty dictionary (PR#2051 by Sebastian Wagner, fixes #2034).

### Development

Expand All @@ -76,6 +77,7 @@ CHANGELOG
#### Outputs
- `intelmq.bots.outputs.mcafee.output_esm_ip`: Fix access to parameters, the bot wrongly used `self.parameters` (by Sebastian Wagner).
- `intelmq.bots.outputs.misp.output_api`: Fix access to parameters, the bot wrongly used `self.parameters` (by Sebastian Wagner).
- `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).

### Documentation
- Various formatting fixes (by Sebastian Wagner).
Expand Down
4 changes: 3 additions & 1 deletion intelmq/bots/outputs/smtp/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ def process(self):
if self.text is not None:
msg.attach(MIMEText(self.text.format(ev=event)))
if self.fieldnames:
msg.attach(MIMEText(attachment, 'csv'))
mime_attachment = MIMEText(attachment, 'csv')
mime_attachment.add_header("Content-Disposition", "attachment", filename="events.csv")
msg.attach(mime_attachment)
msg['Subject'] = self.subject.format(ev=event)
msg['From'] = self.mail_from.format(ev=event)
msg['To'] = self.mail_to.format(ev=event)
Expand Down
6 changes: 3 additions & 3 deletions intelmq/lib/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Bot(object):
destination_pipeline_host: str = "127.0.0.1"
destination_pipeline_password: Optional[str] = None
destination_pipeline_port: int = 6379
destination_queues: Optional[dict] = None
destination_queues: dict = {}
error_dump_message: bool = True
error_log_exception: bool = True
error_log_message: bool = False
Expand Down Expand Up @@ -389,7 +389,7 @@ def start(self, starting: bool = True, error_on_pipeline: bool = True,
warnings.warn("Message will be removed from the pipeline and not dumped to the disk. "
"Set `error_dump_message` to true to save the message on disk. "
"This warning is only shown once in the runtime of a bot.")
if self.destination_queues and '_on_error' in self.destination_queues:
if '_on_error' in self.destination_queues:
self.send_message(self.__current_message, path='_on_error')

if message_to_dump or self.__current_message:
Expand Down Expand Up @@ -563,7 +563,7 @@ def __connect_pipelines(self):
self.__current_message = None
self.logger.debug("Connected to source queue.")

if self.destination_queues is not None:
if self.destination_queues:
self.logger.debug("Loading destination pipeline and queues %r.", self.destination_queues)
self.__destination_pipeline = PipelineFactory.create(logger=self.logger,
direction="destination",
Expand Down
3 changes: 3 additions & 0 deletions intelmq/tests/bots/outputs/smtp/test_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def test_event(self):
''')
self.assertEqual({'from_addr': 'myself', 'to_addrs': ['you', 'yourself']},
SENT_MESSAGE[1])
# https://github.com/certtools/intelmq/issues/2018
self.assertIn(('Content-Disposition', 'attachment; filename="events.csv"'),
SENT_MESSAGE[0].get_payload()[1]._headers)

def test_multiple_recipients_event(self):
"""
Expand Down

0 comments on commit e489bee

Please sign in to comment.