Skip to content

Commit

Permalink
fix NPE if certificate contains invalid domain name (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinWeindel authored Aug 29, 2024
1 parent 04b57bc commit 7641419
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/dns/provider/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,10 +476,6 @@ func (this *EntryVersion) Setup(logger logger.LogContext, state *state, p *Entry
}

spec, targets, warnings, verr := validate(logger, state, this, p)
if p.provider != nil && spec.TTL != nil {
this.status.TTL = spec.TTL
}

if verr != nil {
hello.Infof(logger, "validation failed: %s", verr)

Expand All @@ -491,6 +487,10 @@ func (this *EntryVersion) Setup(logger logger.LogContext, state *state, p *Entry

hello.Infof(logger, "validation ok")

if p.provider != nil && spec.TTL != nil {
this.status.TTL = spec.TTL
}

if this.IsDeleting() {
logger.Infof("update state to %s", api.STATE_DELETING)
this.status.State = api.STATE_DELETING
Expand Down
24 changes: 24 additions & 0 deletions test/integration/entryLivecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,4 +312,28 @@ var _ = Describe("EntryLivecycle", func() {
err = testEnv.DeleteProviderAndSecret(pr)
Ω(err).ShouldNot(HaveOccurred())
})

It("handles entry with invalid domain name correctly", func() {
pr, domain, _, err := testEnv.CreateSecretAndProvider("inmemory.mock", 0)
Ω(err).ShouldNot(HaveOccurred())

defer testEnv.DeleteProviderAndSecret(pr)

setSpec := func(e *v1alpha1.DNSEntry) {
e.Spec.DNSName = fmt.Sprintf("invalid-*.%s", domain)
e.Spec.Targets = []string{"1.2.3.4"}
}
e0, err := testEnv.CreateEntryGeneric(0, setSpec)
Ω(err).ShouldNot(HaveOccurred())

checkProvider(pr)

Ω(testEnv.AwaitEntryInvalid(e0.GetName())).ShouldNot(HaveOccurred())

err = testEnv.DeleteEntryAndWait(e0)
Ω(err).ShouldNot(HaveOccurred())

err = testEnv.DeleteProviderAndSecret(pr)
Ω(err).ShouldNot(HaveOccurred())
})
})

0 comments on commit 7641419

Please sign in to comment.