phires / go-guerrilla

MIT License
112 stars 18 forks source link

feat: save email contents to local files #47

Open guilhem-martin opened 4 months ago

guilhem-martin commented 4 months ago

Proposition of a new processor that save the email as local files - one per mime part - with extensions.

phires commented 4 months ago

Hi, thank you a lot for your PR and effort! I'm currently on the road, I'll have a detailed look into it once I return

phires commented 4 months ago

Maybe we can move some of the ParseContent func to another file, just to have it somewhat cleaner, and also to be able to create versions for other OSes, as with the current code it would fail on Windows. Also the charset parsing looks strange, there has to be a better way. From just having done a quick search there seems to be modules to do the parsing, e.g. https://github.com/jhillyerd/enmime It might be worth to look into that before we reinvent the wheel ;)

guilhem-martin commented 4 months ago

Thanks for your feedbacks - I'm going to propose evolutions based on your suggestion - and keep you posted.

For information, I manually test with a bunch of smtp messages that I stored here: https://github.com/guilhem-martin/go-guerrilla-wiki/blob/docs/manual_tests/Manual-testing.md

A question about the configuration of the content parser that has currently one parameter - the path where to store the files - should I move the configuration to the goguerrilla.conf.json? If yes, how can I retrieve the Config object to get the path?

guilhem-martin commented 4 months ago

@phires so I've added the use of enmime library to take care of the parsing and decoding of the mime parts. Let me know if this looks good to you for that part of the PR, thanks!

phires commented 2 months ago

Sorry, I was offline a while. I'll have a look into it as soon I find some time!

guilhem-martin commented 2 months ago

No problem. Let me know if you think if this feature can be of interest . I've used it for a personal use case - so thanks anyway for maintaining this project.

I realize that I added the configuration to the generic configuration file whereas the documentation states to have dedicated configuration for a given processor - I'll update it.