-
Notifications
You must be signed in to change notification settings - Fork 307
[smtp_batch] Additional field for grouping #2586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Sure! @e3rd is the original author of the bot and likely a user of it as well so I assume he can give you some feedback on your questions. |
Thanks, I ll definitely take a look at it, thanks! |
The 2nd approach really seems great! You make the group-by field defaulted to I am really ashamed I slowed down your PR by three weeks! Looking forward to the PR, please tag me there so that I can review. |
All good. Yes, the solution should be backwards compatible (also we need to force Probably this will be a while because of time constraints and I need to setup my development environment first (so I can test all this). |
Fingers crossed! |
If you don't mind, I'd suggest to add a configuration option too. What do you think?
If bigger than 0, the part of the attachment contents would be put into the body apart from being attached. |
Sounds interesting. Especially with the idea of introducing jinja2 to this bot (I know there already is the templated mail bot, but it does not allow for batching the events). Also I'm not decided on whether it should be something like, only include the start of the attachment if it is smaller than |
Talking more generally about this bot, I am curious. Do you know why the attachment always is zipped? Is is common the attachment is that large and compression really brings a benefit (or is necessary due to the size and limitations in E-Mail servers rejecting large attachments)? |
just the plain text
I have no opinion, both fit :) The preview seems slightly better as it is consistent, but I don't know.
Unfortunately, according to our experiences, mail servers are mad. Sometimes, 10 MB caused the e-mail to vanish if I remember well. To be consistent (so that the partners could automate), we've enforced the zip for all. But if you don't like it, just add a flag for that. |
Adding onto the ideas regarding the smtp_batch bot:
|
Great enhancement, of course! |
Sending mails with the smtp_batch output might fail e.g. due to wrong settings regarding the SMTP-Server. So far this is not reflected in the exit code when running the bot via cli to trigger sending the mails. Fixing this (at least for the non-interactive call) enables users to integrate this into their monitoring properly.
Sending mails with the smtp_batch output might fail e.g. due to wrong settings regarding the SMTP-Server. So far this is not reflected in the exit code when running the bot via cli to trigger sending the mails. Fixing this (at least for the non-interactive call) enables users to integrate this into their monitoring properly.
I am a bit confused intelmq/intelmq/bots/outputs/smtp_batch/output.py Lines 283 to 286 in ec37d0c
intelmq/intelmq/bots/outputs/smtp_batch/output.py Lines 301 to 304 in ec37d0c
@e3rd do you still remember what the idea here was? Why building the mail if (And if you already want to have a look, I'm drafting at https://github.com/Lukas-Heindl/intelmq/tree/smtpBatchGroup) |
Good point, a design flaw, get rid of it. The draft looks nice! :) |
Sending mails with the smtp_batch output might fail e.g. due to wrong settings regarding the SMTP-Server. So far this is not reflected in the exit code when running the bot via cli to trigger sending the mails. Fixing this (at least for the non-interactive call) enables users to integrate this into their monitoring properly.
Ok this is getting more like a (minor) refactoring of the bot. I noticed the parameters Reason:
will crash in case the ordered_keys (intersection of allowed_fieldnames and the keys defined in the event) contains a key which is not defined in fieldnames_translation .
Personally I'd be okay with this (shifting the responsibility to the user/admin to do the configuration right). Still I wanted to raise this for discussion whether the bot should be more robust in this regard. We could use Or we could remove the |
Except for the |
Addition to the collectio of ideas:
|
Hi,
I have a usecase where I'd like to send batched E-Mails to someone with collected events for which I want to use the smtp_batch output bot. Then in this case it would be nice to break down the events for one contact further into multiple E-Mails. Would it be possible to add some option such that the group-by is not only done by
source.abuse_contact
but also by a field determined by the bot configuration?Eventually it would also be nice to use this field also included in the group-by in e.g. the subject, but that's just for the future.
I'm willing to submit this as a PR myself, I just wanted to create a place for input and also most important to check beforehand whether this has any chance of being merged.
So far
smtp_batch
inserts each event as value into redis with thebot_id + source.abuse_contact
as key:intelmq/intelmq/bots/outputs/smtp_batch/output.py
Lines 77 to 78 in a5f2f9c
It then later uses
redis.keys()
to retrieve all keys with a certain prefix (bot_id
):intelmq/intelmq/bots/outputs/smtp_batch/output.py
Line 224 in a5f2f9c
So the most straight forward way would be to simply extend the redis-key with the value of the field that should be included in the logical group-by. But we'd need to be careful, the retrieved redis-key (here
mail_record
) is still used to obtain the destination E-Mail address:intelmq/intelmq/bots/outputs/smtp_batch/output.py
Line 282 in a5f2f9c
In order to solve this I see two options
|
-> in this case we'd need to make sure this character doesn't occur in any of the values -> replacing (but probably modifying the values is a bad idea) or escaping (a bit more complex) neededsource.abuse_contact
so we could simply get the value from an arbitrary event we retrieved from redis (same thing if we later want to gain access to the other field we included in the group-by). Decoupling the redis-key from the rest of the logic also should make it possible to simply hash the redis-key which avoids all trouble with the redis-key getting much longer with more keys involved in the group-by logic. So in this case the redis-key would look like thisf"{self.key}{hash(source.abuse_contact, other_field1, other_field2, ...)}"
As I mentioned above I've got two questions
The text was updated successfully, but these errors were encountered: