-
-
Notifications
You must be signed in to change notification settings - Fork 208
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
Add additional config validation #1773
Conversation
Signed-off-by: DL6ER <[email protected]>
Signed-off-by: DL6ER <[email protected]>
Signed-off-by: DL6ER <[email protected]>
Signed-off-by: DL6ER <[email protected]>
Signed-off-by: DL6ER <[email protected]>
Signed-off-by: DL6ER <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a comment (in the source code), which items are validated by dnsmasq
. Otherwise it's hard to judge if something was forgotten or left out on purpose.
@@ -767,6 +767,20 @@ static int api_config_patch(struct ftl_conn *api) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the line above we have config_changed=true;
> should this be placed after the new value validation? We reject the new config when the value is invalid in the end.
Otherwise manual editing of pihole.toml
can still add invalid entries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't matter. If validation fails, this function will free the temporary newconf
in line 776 below and return. Nobody will ever look at the value of config_changed
Signed-off-by: DL6ER <[email protected]>
|
Should one-character domains be considered valid? In the context of FTL/src/tools/gravity-parseList.c Lines 98 to 102 in 3bdf652
|
I think it should be two characters for external domains, but accept single characters for local hostnames. Someone might have |
Those are FQDN. The length limitation applies only to the last label ( |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Signed-off-by: DL6ER <[email protected]>
Conflicts have been resolved. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Signed-off-by: DL6ER <[email protected]>
Conflicts have been resolved. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Signed-off-by: DL6ER <[email protected]>
…log error that will fail the CI tests. This will help ensuring we won't forget to add validators for PRs that are merged in parallel or new config options added in the future Signed-off-by: DL6ER <[email protected]>
…hen a user tries to set multiple values at once (e.g. via the web UI) Signed-off-by: DL6ER <[email protected]>
Signed-off-by: DL6ER <[email protected]>
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Signed-off-by: DL6ER <[email protected]>
Conflicts have been resolved. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Signed-off-by: DL6ER <[email protected]>
Conflicts have been resolved. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Signed-off-by: DL6ER <[email protected]>
Signed-off-by: DL6ER <[email protected]>
Conflicts have been resolved. |
This all looks good, do you plan on adding some unit tests? |
Signed-off-by: DL6ER <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff, even greater with tests!
What does this implement/fix?
FTL is already pretty selective when it comes to accepting config values as it has a strong filter on a config value's type. For instance, your cannot set
dhcp.start
to a number or hostname. Similarly, you canot setdns.port
to 100,000 as such a high value does not exist or-12
as negative ports don't exist either.However, we have two config value types that do not allow strict testing: strings and arrays of strings.
This PR adds the facility to add validation callbacks to such config values so FTL will be able to check validity of those, too. I added validators for almost all string config options with only a few exceptions, e.g.
dns.upstreams
asdnsmasq
allows upstreams to be defined by IP address or hostname, optionally with a port - we can leave checking the values todnsmasq
and will tell the user on error:Some examples for validators we're adding herein:
dns.hosts
:dns.domain
(similarlydns.revServer.domain
,dhcp.domain
,webserver.domain
):dns.cnameRecords
:dns.revServer.cidr
:dns.revServer.target
webserver.tls.cert
(similarly all paths infiles
):Related issue or feature (if applicable): N/A
Pull request in docs with documentation (if applicable): N/A
By submitting this pull request, I confirm the following:
git rebase
)Checklist:
developmental
branch.