Skip to content
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

Check SPF/DKIM/DMARC record on dns like MX records #3083

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Riscue
Copy link
Contributor

@Riscue Riscue commented Dec 7, 2023

What type of PR?

Enhancement

What does this PR do?

Checks TXT records for SPF, DKIM, DMARC same as MX record checker

Copy link
Contributor

mergify bot commented Dec 7, 2023

Thanks for submitting this pull request.
Bors-ng will now build test images. When it succeeds, we will continue to review and test your PR.

bors try

Note: if this build fails, read this.

bors-mailu bot added a commit that referenced this pull request Dec 7, 2023
@bors-mailu
Copy link
Contributor

bors-mailu bot commented Dec 7, 2023

try

Build succeeded:

Copy link
Contributor

@ghostwheel42 ghostwheel42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi. Thanks for your contribution.
I was thinking about doing the checks asynchronously (by having a "spinner" image and requesting the check via src="" returning a good or bad image), but this is a good start.
I didn't run in yet, but I think the regex should be changed.

try:
hostnames = app.config['HOSTNAMES'].replace(',', '|')
return any(
re.search(f'^"v=spf1 mx a:{hostnames} [?+-~]all"$', rset.to_text())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think hostnames should be grouped: f'^"v=spf1 mx a:({hostnames}) [?+-~]all"$'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can improve all regexes if there is expert about dns records. Yeah my mistake, i will update this.

except dns.exception.DNSException:
return False

def check_dmarc(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be nice to check dns_dmarc_report, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dmarc record and DMARC report record was grouped, check mark icon is in first column per row. That's why i checked both record in one method. And both record has only one icon in their first column. I can split and put two check mark next to record besides row

@Riscue
Copy link
Contributor Author

Riscue commented Dec 7, 2023

Hi. Thanks for your contribution. I was thinking about doing the checks asynchronously (by having a "spinner" image and requesting the check via src="" returning a good or bad image), but this is a good start. I didn't run in yet, but I think the regex should be changed.

If we do this asynchronously, I will explicitly check all dns entries as well as auto-configuration entries.

And check methods could return states like exist-correct, exist-unknown, not exist? Any thought?

@ghostwheel42
Copy link
Contributor

Sorry for the delay. At first I thought the simplest way to implement this would be a route to check dns entries like .../check/dkim returning a single location header pointing to an image (good or bad).
The web page would have a spinning circle as lowsrc and the check as src.
Another way would be to do it via JS/jquery and a jsonp response. This could return more precise error messages and the values of the actual records.

Alex

@ghostwheel42 ghostwheel42 added type/enhancement Enhances existing functionality priority/p2 Minor bug / Could have python Pull requests that update Python code labels Dec 22, 2023
Copy link
Contributor

mergify bot commented Feb 22, 2024

Thanks for submitting this pull request.
Bors-ng will now build test images. When it succeeds, we will continue to review and test your PR.

bors try

Note: if this build fails, read this.

bors-mailu bot added a commit that referenced this pull request Feb 29, 2024
@bors-mailu
Copy link
Contributor

bors-mailu bot commented Feb 29, 2024

try

Build succeeded:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/p2 Minor bug / Could have python Pull requests that update Python code type/enhancement Enhances existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants