-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(pihole): support special characters in pihole password #5988
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
base: master
Are you sure you want to change the base?
Conversation
Updated test of pihole provider to create a pihole api client with
password containing special characters.
When requesting API token, current implementation does not perform
proper json marshalling of request. That results in sending invalid
json & getting 400 bad request error if password contains special
characters which break json syntax.
Run of the test with current code:
=== RUN TestNewPiholeClientV6
clientV6_test.go:129: invalid character 'w' in string escape code
clientV6_test.go:200: Post "http://127.0.0.1:57465/api/auth": EOF
--- FAIL: TestNewPiholeClientV6 (0.01s)
Added proper JSON marshalling of API token request body.
That fixes support of special characters in pihole password.
The previously updated test now passes:
=== RUN TestNewPiholeClientV6
--- PASS: TestNewPiholeClientV6 (0.00s)
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Welcome @alex-ac! |
|
Hi @alex-ac. Thanks for your PR. I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/ok-to-test |
Pull Request Test Coverage Report for Build 19861145459Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
| w.Header().Set("Content-Type", "application/json") | ||
|
|
||
| if requestData["password"] != "correct" { | ||
| if requestData["password"] != "correct" && requestData["password"] != "correct\\with\"special'characters" { |
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.
You could also simply change the existing password to include special characters. Something like this:
| if requestData["password"] != "correct" && requestData["password"] != "correct\\with\"special'characters" { | |
| if requestData["password"] != `correct\"²` { |
What does it do ?
Current implementation does not handle special characters in pihole password correctly. It skips proper JSON marshalling of the request & sends invalid json to pihole API. This change fixes it by introducing proper JSON marshalling.
Motivation
I've hit this problem myself on my homelab setup, here's a log:
Hint in the log is part of the request json starting with invalid escape sequence
\hwhich happened because my password contains backslash.More