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

Fix unbound_dot: allow requests without domain parameter set #77

Merged
merged 2 commits into from
Jun 20, 2024

Conversation

Cyatris
Copy link
Contributor

@Cyatris Cyatris commented Jun 20, 2024

Description

When creating a DNS over TLS rule in Opnsense, specifying a target attribute is required. One may also define one of the following optional parameters: domain, port or validate (and reload).

Expected Behavior

According to the docs domain is not a required parameter.
An Ansible task without the domain parameter set should therefore execute correctly.

Actual Behavior

The validate_domain function called in unbound_dot.py will throw an AttributeError: 'NoneType' object has no attribute 'find'

Changes

  • validate_domain is only called if domain is set.
  • Opnsense rule matching without domain set allows usage of verify instead.
  • If neither domain nor verify is set, only target parameter is used.

Discussion

Changing match_fields to allow matching only against target if neither domain nor verify is set may lead to ansible operating on the wrong rule, if multiple rules with the same target attribute are set.

An alternative approach could be to always require either verify or domain parameter being set.
However, since both are marked as optional, this will probably not solve the underlying issue.

Copy link
Owner

@ansibleguy ansibleguy left a comment

Choose a reason for hiding this comment

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

Makes sense

@ansibleguy
Copy link
Owner

Thank you for correcting it - we had the same issue with unbound_forward before. It seems we forgot about the dot module at that time :(

I've set the matching to use only target if no domain is supplied - else domain and target will be used.
I don't think there are many setups where the target is used with more than one verify CN's - as the server certificate and thus CN will normally not change if you address the same server & port.
I thought about using target and port - but I don't think there are many setups where one server is used for multiple DNS services. Does not really make sense in my opinion.

@ansibleguy ansibleguy merged commit a1ea6cf into ansibleguy:latest Jun 20, 2024
2 checks passed
@ansibleguy ansibleguy self-assigned this Jun 20, 2024
@ansibleguy ansibleguy added the bug Something isn't working label Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants