domainaware / parsedmarc

A Python package and CLI for parsing aggregate and forensic DMARC reports
https://domainaware.github.io/parsedmarc/
Apache License 2.0
986 stars 214 forks source link

Refactor Gmail integration with MailboxConnection interface #307

Closed nathanthorpe closed 2 years ago

nathanthorpe commented 2 years ago

Changes:

seanthegeek commented 2 years ago

The tests hit an error https://github.com/domainaware/parsedmarc/runs/6121079486?check_suite_focus=true

nathanthorpe commented 2 years ago

Yeah still working on this PR, it will be draft until I get a chance to test it with Gmail. I will keep an eye on the CI checks.

nathanthorpe commented 2 years ago

Ok this is ready for review. Seems to work with gmail on my end.

exetico commented 2 years ago

Hi

I've added both IMAP and gmail_api as options, but would something point out: Q: Why do I need to add both imap and gmail_api?

If I comment out the [imap] part, it's returning ERROR:cli.py:598:You must supply input files, or an IMAP configuration in the logs.

After fiddling around with the settings, it has now scanned the mails as it should. But I'm pretty insure if archive_folder and reports_folder should only be in one of the settings-domains. 🙃

[general]
save_aggregate = True
save_forensic = True

[imap]
# IMAP login
host = imap.gmail.com
port = 993
user = my@gmail.com
password = my-app-password
ssl = True

[mailbox]
watch = True
archive_folder = DMARCReports_Archive
reports_folder = DMARCReports_Inbox
delete = False
test = True

# gmail
[gmail_api]
credentials_file = /etc/parsedmarc/gmail_auth/credentials.json # Get this file from console.google.com. See https://developers.google.com/identity/protocols/oauth2
token_file = /etc/parsedmarc/gmail_auth/token.json             # This file will be generated automatically
scopes = https://mail.google.com/
include_spam_trash=True
reports_folder = DMARCReports_Inbox
archive_folder = DMARCReports_Archive

[elasticsearch]
hosts = elasticsearch:9200
ssl = False

image

Also.. Are there any good way of triggering a report/mail, if the DMARC are not reporing pass?. I'm running a small mail-server, so it would be nice to have that kind of message based on the scan done by parsedmarc.**

nathanthorpe commented 2 years ago

Q: Why do I need to add both imap and gmail_api?

You shouldn't have to supply both, it will only work with one or the other.

Looking at your log output it seems that you have an older version installed? Please verify that v8 is installed.

If you look at L663 of cli.py, the error message that you are referencing is: "You must supply input files or a mailbox connection" https://github.com/domainaware/parsedmarc/blob/master/parsedmarc/cli.py#L662

exetico commented 2 years ago

Thank you for the quick response. I ended up disabling parsedmarc on the machine, but I'll move it to another one. There was simply not enough room for more ram-usage on the instance. but I totally missed that fact that it will require a bit of both ram and CPU on/off 😄 ... And more than a few of my other running containers...

I was using the patschi/parsedmarc:latest tag.

nathanthorpe commented 2 years ago

That's not an official image, so I'm assuming that it is an outdated version.