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: log.privacy option no longer hides domain names being resolved #1255

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions e2e/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,50 @@ var _ = Describe("Basic functional tests", func() {
})
})
})

Describe("Logging", func() {
BeforeEach(func() {
moka, err = createDNSMokkaContainer("moka1", `A google/NOERROR("A 1.2.3.4 123")`)

Expect(err).Should(Succeed())
DeferCleanup(moka.Terminate)
})
When("log privacy is enabled", func() {
BeforeEach(func() {
blocky, err = createBlockyContainer(tmpDir,
"upstreams:",
" groups:",
" default:",
" - moka1",
"log:",
" level: trace",
" privacy: true",
)
Expect(err).Should(Succeed())
DeferCleanup(blocky.Terminate)
})
It("should not log answers and questions", func() {
msg := util.NewMsgWithQuestion("google.com.", A)

// do 2 requests

Expect(doDNSRequest(blocky, msg)).
Should(
SatisfyAll(
BeDNSRecord("google.com.", A, "1.2.3.4"),
HaveTTL(BeNumerically("==", 123)),
))

Expect(doDNSRequest(blocky, msg)).
Should(
SatisfyAll(
BeDNSRecord("google.com.", A, "1.2.3.4"),
HaveTTL(BeNumerically("<=", 123)),
))

Expect(getContainerLogs(blocky)).Should(Not(ContainElement(ContainSubstring("google.com"))))
Expect(getContainerLogs(blocky)).Should(Not(ContainElement(ContainSubstring("1.2.3.4"))))
})
})
})
})
2 changes: 1 addition & 1 deletion resolver/conditional_upstream_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (r *ConditionalUpstreamResolver) internalResolve(reso Resolver, doFQ, do st

logger.WithFields(logrus.Fields{
"answer": answer,
"domain": do,
"domain": util.Obfuscate(do),
"upstream": reso,
}).Debugf("received response from conditional upstream")

Expand Down
2 changes: 1 addition & 1 deletion resolver/hosts_file_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (r *HostsFileResolver) Resolve(request *model.Request) (*model.Response, er
if response != nil {
r.log().WithFields(logrus.Fields{
"answer": util.AnswerToString(response.Answer),
"domain": domain,
"domain": util.Obfuscate(domain),
}).Debugf("returning hosts file entry")

return &model.Response{Res: response, RType: model.ResponseTypeHOSTSFILE, Reason: "HOSTS FILE"}, nil
Expand Down
2 changes: 1 addition & 1 deletion resolver/query_logging_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (r *QueryLoggingResolver) createLogEntry(request *model.Request, response *
entry.Answer = util.AnswerToString(response.Res.Answer)

case config.QueryLogFieldQuestion:
entry.QuestionName = request.Req.Question[0].Name
entry.QuestionName = util.Obfuscate(request.Req.Question[0].Name)
entry.QuestionType = dns.TypeToString[request.Req.Question[0].Qtype]

case config.QueryLogFieldDuration:
Expand Down
2 changes: 1 addition & 1 deletion resolver/rewriter_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (r *RewriterResolver) rewriteRequest(logger *logrus.Entry, request *dns.Msg
rewritten.Question[i].Name = dns.Fqdn(domainRewritten)

logger.WithFields(logrus.Fields{
"domain": domainOriginal,
"domain": util.Obfuscate(domainOriginal),
"rewrite": rewriteKey + ":" + r.cfg.Rewrite[rewriteKey],
0xERR0R marked this conversation as resolved.
Show resolved Hide resolved
}).Debugf("rewriting %q to %q", domainOriginal, domainRewritten)
}
Expand Down