Skip to content

Commit c80ee63

Browse files
Unify instances of "additionals" -> "additional" when referring to the section as a whole (#487)
* additionals -> additional * Revert "additionals -> additional" This reverts commit d755d3e. * only change authorities for user-visible fields, leave plural for sets of authority records in the code * use x_section to allign with dig * Revert "use x_section to allign with dig" This reverts commit c6fe501. * pluralized * fix dnssec pluralization * remove overzealous find/replace * missed a few more * pr cleanup * singular module name DNSKEY --------- Co-authored-by: Zakir Durumeric <[email protected]>
1 parent 410eb82 commit c80ee63

13 files changed

+100
-101
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Lookup Modules
113113
--------------
114114

115115
Raw DNS responses frequently do not provide the data you _want_. For example,
116-
an MX response may not include the associated A records in the additionals
116+
an MX response may not include the associated A records in the additional
117117
section requiring an additional lookup. To address this gap and provide a
118118
friendlier interface, we also provide several _lookup_ modules: `alookup`,
119119
`mxlookup`, and `nslookup`.

src/cli/worker_manager_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func TestConvertNameServerStringToNameServer(t *testing.T) {
7676
containsExpectedNameServerStrings(t, nses, expectedNSes)
7777
})
7878
t.Run("Bad domain name", func(t *testing.T) {
79-
_, err := convertNameServerStringToNameServer("bad.domain.name", zdns.IPv4OrIPv6, false, false)
79+
_, err := convertNameServerStringToNameServer("bad.domain.name.random.j83bs", zdns.IPv4OrIPv6, false, false)
8080
require.Error(t, err)
8181
})
8282
t.Run("Bad IP address", func(t *testing.T) {

src/zdns/alookup.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ func getIPAddressesFromQueryResult(res *SingleQueryResult, queryType, name strin
8282
if res == nil {
8383
return nil, errors.New("nil SingleQueryResult")
8484
}
85-
ips := make([]string, 0, len(res.Answers)+len(res.Additional))
85+
ips := make([]string, 0, len(res.Answers)+len(res.Additionals))
8686
for _, ans := range res.Answers {
8787
if a, ok := ans.(Answer); ok {
8888
if a.Type == queryType {
8989
ips = append(ips, a.Answer)
9090
}
9191
}
9292
}
93-
for _, ans := range res.Additional {
93+
for _, ans := range res.Additionals {
9494
if a, ok := ans.(Answer); ok {
9595
if a.Type == queryType {
9696
ips = append(ips, a.Answer)

src/zdns/cache.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func (s *Cache) getCachedResult(q Question, ns *NameServer, isAuthority bool, de
136136
retv = new(SingleQueryResult)
137137
retv.Answers = make([]interface{}, 0, len(cachedRes.Answers))
138138
retv.Authorities = make([]interface{}, 0, len(cachedRes.Authorities))
139-
retv.Additional = make([]interface{}, 0, len(cachedRes.Additionals))
139+
retv.Additionals = make([]interface{}, 0, len(cachedRes.Additionals))
140140
retv.Flags = cachedRes.Flags
141141
retv.DNSSECResult = cachedRes.DNSSECResult
142142
// great we have a result. let's go through the entries and build a result. In the process, throw away anything
@@ -163,11 +163,11 @@ func (s *Cache) getCachedResult(q Question, ns *NameServer, isAuthority bool, de
163163
partiallyExpired = true
164164
s.VerboseLog(depth+2, "expiring cache additional ", cachedAdditional.Answer.BaseAns().Name)
165165
} else {
166-
retv.Additional = append(retv.Additional, cachedAdditional.Answer)
166+
retv.Additionals = append(retv.Additionals, cachedAdditional.Answer)
167167
}
168168
}
169169
// Don't return an empty response.
170-
if len(retv.Answers) == 0 && len(retv.Authorities) == 0 && len(retv.Additional) == 0 {
170+
if len(retv.Answers) == 0 && len(retv.Authorities) == 0 && len(retv.Additionals) == 0 {
171171
// remove from cache since it's completely expired
172172
s.IterativeCache.Delete(cacheKey)
173173
s.VerboseLog(depth+2, "-> no entry found in cache, after expiration for ", cacheKey, ", removing from cache")
@@ -229,8 +229,8 @@ func (s *Cache) buildCachedResult(res *SingleQueryResult, depth int, layer strin
229229
})
230230
}
231231
}
232-
cachedRes.Additionals = make([]TimedAnswer, 0, len(res.Additional))
233-
for _, a := range res.Additional {
232+
cachedRes.Additionals = make([]TimedAnswer, 0, len(res.Additionals))
233+
for _, a := range res.Additionals {
234234
castAns, expiresAt := getExpirationForSafeAnswer(a)
235235
if castAns != nil {
236236
cachedRes.Additionals = append(cachedRes.Additionals, TimedAnswer{
@@ -252,7 +252,7 @@ func (s *Cache) SafeAddCachedAnswer(q Question, res *SingleQueryResult, ns *Name
252252
nsString = ns.String()
253253
}
254254
// check for poison
255-
for _, a := range util.Concat(res.Answers, res.Authorities, res.Additional) {
255+
for _, a := range util.Concat(res.Answers, res.Authorities, res.Additionals) {
256256
castAns, ok := a.(WithBaseAnswer)
257257
if !ok {
258258
// if we can't cast, it won't be added to the cache. We'll log in buildCachedResult

src/zdns/cache_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func TestNoNameServerLookupSuccess(t *testing.T) {
3838
Name: "google.com",
3939
Answer: "192.0.2.1",
4040
}},
41-
Additional: nil,
41+
Additionals: nil,
4242
Authorities: nil,
4343
Protocol: "",
4444
Flags: DNSFlags{Authoritative: true},
@@ -59,7 +59,7 @@ func TestNoNameServerLookupForNamedNameServer(t *testing.T) {
5959
Name: "google.com",
6060
Answer: "192.0.2.1",
6161
}},
62-
Additional: nil,
62+
Additionals: nil,
6363
Authorities: nil,
6464
Protocol: "",
6565
Flags: DNSFlags{Authoritative: true},
@@ -83,7 +83,7 @@ func TestNamedServerLookupForNonNamedNameServer(t *testing.T) {
8383
Name: "google.com",
8484
Answer: "192.0.2.1",
8585
}},
86-
Additional: nil,
86+
Additionals: nil,
8787
Authorities: nil,
8888
Protocol: "",
8989
Flags: DNSFlags{Authoritative: true},
@@ -107,7 +107,7 @@ func TestNamedServerLookupForNamedNameServer(t *testing.T) {
107107
Name: "google.com",
108108
Answer: "192.0.2.1",
109109
}},
110-
Additional: nil,
110+
Additionals: nil,
111111
Authorities: nil,
112112
Protocol: "",
113113
Flags: DNSFlags{Authoritative: true},
@@ -134,7 +134,7 @@ func TestNoNameServerLookupNotAuthoritative(t *testing.T) {
134134
Name: "google.com",
135135
Answer: "192.0.2.1",
136136
}},
137-
Additional: nil,
137+
Additionals: nil,
138138
Authorities: nil,
139139
Protocol: "",
140140
Flags: DNSFlags{Authoritative: false},

src/zdns/dnssec.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ const NSEC3OptOutFlag = 0x01
6262
// - *DNSSECResult: Contains validation results for all message sections:
6363
// - Status: Overall DNSSEC validation status (Secure/Insecure/Bogus/Indeterminate)
6464
// - DS: Collection of DS records actually used during validation
65-
// - DNSKEY: Collection of DNSKEY records actually used during validation
66-
// - Answer/Additional/Authoritative: Per-RRset validation results
65+
// - DNSKEYs: Collection of DNSKEY records actually used during validation
66+
// - Answers/Additionals/Authorities: Per-RRset validation results
6767
//
6868
// - Trace: Updated trace context containing validation path
6969
func (v *dNSSECValidator) validate(layer string, msg *dns.Msg, nameServer *NameServer, depth int, trace Trace) (*DNSSECResult, Trace) {
@@ -99,28 +99,28 @@ func (v *dNSSECValidator) validate(layer string, msg *dns.Msg, nameServer *NameS
9999
// Validate the answer section
100100
var sectionRes []DNSSECPerSetResult
101101
sectionRes, trace = v.validateSection(v.msg.Answer, depth, trace)
102-
result.Answer = sectionRes
102+
result.Answers = sectionRes
103103

104104
// If the message is authoritative, we drop the additional and authoritative sections
105105
// in Resolver.iterativeLookup, hence no need to validate them here. Validating them
106106
// causes circular lookups in some cases and can confuse the user.
107107
if !v.msg.Authoritative {
108108
// Validate the additional section
109109
sectionRes, trace = v.validateSection(v.msg.Extra, depth, trace)
110-
result.Additional = sectionRes
110+
result.Additionals = sectionRes
111111

112112
// Validate the authoritative section
113113
sectionRes, trace = v.validateSection(v.msg.Ns, depth, trace)
114-
result.Authoritative = sectionRes
114+
result.Authorities = sectionRes
115115
}
116116

117117
for ds := range v.ds {
118118
parsed := ParseAnswer(&ds).(DSAnswer) //nolint:golint,errcheck
119-
result.DS = append(result.DS, &parsed)
119+
result.DSes = append(result.DSes, &parsed)
120120
}
121121
for dnskey := range v.dNSKEY {
122122
parsed := ParseAnswer(&dnskey).(DNSKEYAnswer) //nolint:golint,errcheck
123-
result.DNSKEY = append(result.DNSKEY, &parsed)
123+
result.DNSKEYs = append(result.DNSKEYs, &parsed)
124124
}
125125

126126
result.populateStatus()
@@ -277,7 +277,7 @@ func (v *dNSSECValidator) findSEPsFromAnswer(rrSet []dns.RR, signerDomain string
277277
}
278278

279279
if len(dnskeys) == 0 {
280-
return nil, trace, errors.New("could not find any DNSKEY")
280+
return nil, trace, errors.New("could not find any DNSKEYs")
281281
}
282282

283283
// Find SEP keys
@@ -328,7 +328,7 @@ func (v *dNSSECValidator) getDNSKEYs(signerDomain string, trace Trace, depth int
328328
} else if res.DNSSECResult != nil && res.DNSSECResult.Status != DNSSECSecure { // // DNSSECResult may be nil if the response is from the cache.
329329
v.r.verboseLog(depth, fmt.Sprintf("DNSSEC: Failed to get DNSKEYs for signer domain %s, DNSSEC status: %s", signerDomain, res.DNSSECResult.Status))
330330

331-
if prevResult := getResultForRRset(RRsetKey(dnskeyQuestion.Q), res.DNSSECResult.Answer); prevResult != nil && prevResult.Error != "" {
331+
if prevResult := getResultForRRset(RRsetKey(dnskeyQuestion.Q), res.DNSSECResult.Answers); prevResult != nil && prevResult.Error != "" {
332332
return nil, nil, trace, fmt.Errorf("DNSKEY fetch failed: %s", prevResult.Error)
333333
} else {
334334
return nil, nil, trace, errors.New(res.DNSSECResult.Reason)
@@ -403,7 +403,7 @@ func (v *dNSSECValidator) fetchDSRecords(signerDomain string, trace Trace, depth
403403
} else if res.DNSSECResult != nil && res.DNSSECResult.Status != DNSSECSecure {
404404
v.r.verboseLog(depth, fmt.Sprintf("DNSSEC: Failed to get DS records for signer domain %s, DNSSEC status: %s", signerDomain, res.DNSSECResult.Status))
405405

406-
if prevResult := getResultForRRset(RRsetKey(dsQuestion.Q), res.DNSSECResult.Authoritative); prevResult != nil && prevResult.Error != "" {
406+
if prevResult := getResultForRRset(RRsetKey(dsQuestion.Q), res.DNSSECResult.Authorities); prevResult != nil && prevResult.Error != "" {
407407
return nil, false, trace, fmt.Errorf("DS fetch failed: %s", prevResult.Error)
408408
} else {
409409
return nil, false, trace, errors.New(res.DNSSECResult.Reason)

src/zdns/dnssec_types.go

+17-17
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ type DNSSECPerSetResult struct {
4545

4646
// DNSSECResult captures all information generated during a DNSSEC validation
4747
type DNSSECResult struct {
48-
Status DNSSECStatus `json:"status" groups:"dnssec,dnssec,normal,long,trace"`
49-
Reason string `json:"reason" groups:"dnssec,dnssec,normal,long,trace"`
50-
DS []*DSAnswer `json:"ds" groups:"dnssec,long,trace"`
51-
DNSKEY []*DNSKEYAnswer `json:"dnskey" groups:"dnssec,long,trace"`
52-
Answer []DNSSECPerSetResult `json:"answer" groups:"dnssec,long,trace"`
53-
Additional []DNSSECPerSetResult `json:"additional" groups:"dnssec,long,trace"`
54-
Authoritative []DNSSECPerSetResult `json:"authoritative" groups:"dnssec,long,trace"`
48+
Status DNSSECStatus `json:"status" groups:"dnssec,dnssec,normal,long,trace"`
49+
Reason string `json:"reason" groups:"dnssec,dnssec,normal,long,trace"`
50+
DSes []*DSAnswer `json:"dses" groups:"dnssec,long,trace"`
51+
DNSKEYs []*DNSKEYAnswer `json:"dnskeys" groups:"dnssec,long,trace"`
52+
Answers []DNSSECPerSetResult `json:"answers" groups:"dnssec,long,trace"`
53+
Additionals []DNSSECPerSetResult `json:"additionals" groups:"dnssec,long,trace"`
54+
Authorities []DNSSECPerSetResult `json:"authorities" groups:"dnssec,long,trace"`
5555
}
5656

5757
func getResultForRRset(rrsetKey RRsetKey, results []DNSSECPerSetResult) *DNSSECPerSetResult {
@@ -100,13 +100,13 @@ func (v *dNSSECValidator) resetDNSSECValidator(msg *dns.Msg, nameServer *NameSer
100100
// makeDNSSECResult creates and initializes a new DNSSECResult instance
101101
func makeDNSSECResult() *DNSSECResult {
102102
return &DNSSECResult{
103-
Status: DNSSECIndeterminate,
104-
Reason: "",
105-
DS: make([]*DSAnswer, 0),
106-
DNSKEY: make([]*DNSKEYAnswer, 0),
107-
Answer: make([]DNSSECPerSetResult, 0),
108-
Additional: make([]DNSSECPerSetResult, 0),
109-
Authoritative: make([]DNSSECPerSetResult, 0),
103+
Status: DNSSECIndeterminate,
104+
Reason: "",
105+
DSes: make([]*DSAnswer, 0),
106+
DNSKEYs: make([]*DNSKEYAnswer, 0),
107+
Answers: make([]DNSSECPerSetResult, 0),
108+
Additionals: make([]DNSSECPerSetResult, 0),
109+
Authorities: make([]DNSSECPerSetResult, 0),
110110
}
111111
}
112112

@@ -129,7 +129,7 @@ func (r *DNSSECResult) populateStatus() {
129129
r.Status = DNSSECSecure
130130

131131
// Check for bogus results first (highest priority)
132-
checkSections := [][]DNSSECPerSetResult{r.Answer, r.Additional, r.Authoritative}
132+
checkSections := [][]DNSSECPerSetResult{r.Answers, r.Additionals, r.Authorities}
133133
for _, section := range checkSections {
134134
for _, result := range section {
135135
if result.Status == DNSSECBogus {
@@ -140,7 +140,7 @@ func (r *DNSSECResult) populateStatus() {
140140
}
141141
}
142142

143-
for _, result := range r.Answer {
143+
for _, result := range r.Answers {
144144
if result.Status == DNSSECInsecure {
145145
// This is considered bogus. If we are at this point, we know a DS exists for
146146
// the zone, so the answer section (authoritative data) should be signed.
@@ -156,7 +156,7 @@ func (r *DNSSECResult) populateStatus() {
156156
}
157157

158158
// Check DNSSEC-related RRsets in other sections
159-
for _, section := range [][]DNSSECPerSetResult{r.Additional, r.Authoritative} {
159+
for _, section := range [][]DNSSECPerSetResult{r.Additionals, r.Authorities} {
160160
for _, result := range section {
161161
if isDNSSECType(result.RRset.Type) {
162162
if result.Status == DNSSECInsecure {

src/zdns/lookup.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ func (r *Resolver) filterNameServersForUniqueNames(nameServers []NameServer) []N
327327
}
328328
}
329329
if ipv4NS == nil && ipv6NS == nil {
330-
// can be the case that nameservers don't have IPs (like if we have an authority but no additionals)
330+
// can be the case that nameservers don't have IPs (like if we have an authority but no additional)
331331
// use the first NS if so
332332
if len(nsSlice) > 0 {
333333
filteredNameServersSet = append(filteredNameServersSet, nsSlice[0])
@@ -472,7 +472,7 @@ func (r *Resolver) extractNameServersFromLayerResults(layerResults []ExtendedRes
472472
if res.Status != StatusNoError {
473473
continue
474474
}
475-
for _, ans := range res.Res.Additional {
475+
for _, ans := range res.Res.Additionals {
476476
if a, ok := ans.(Answer); ok {
477477
uniqueAdditionals[mapKey{Type: a.RrType, Name: a.Name, Answer: a.Answer}] = a
478478
}
@@ -695,16 +695,16 @@ func (r *Resolver) iterativeLookup(ctx context.Context, qWithMeta *QuestionWithM
695695
r.verboseLog((depth + 1), "-> error occurred during lookup")
696696
return result, trace, status, err
697697
} else if len(result.Answers) != 0 || result.Flags.Authoritative {
698-
// DS records is authoritative from parent NS and will be in Authority section. Avoid dropping them.
698+
// DS records are authoritative from parent NS and will be in Authority section. Avoid dropping them.
699699
if len(result.Answers) != 0 && qWithMeta.Q.Type != dns.TypeDS {
700700
r.verboseLog((depth + 1), "-> answers found")
701701
if len(result.Authorities) > 0 {
702702
r.verboseLog((depth + 2), "Dropping ", len(result.Authorities), " authority answers from output")
703703
result.Authorities = make([]interface{}, 0)
704704
}
705-
if len(result.Additional) > 0 {
706-
r.verboseLog((depth + 2), "Dropping ", len(result.Additional), " additional answers from output")
707-
result.Additional = make([]interface{}, 0)
705+
if len(result.Additionals) > 0 {
706+
r.verboseLog((depth + 2), "Dropping ", len(result.Additionals), " additional answers from output")
707+
result.Additionals = make([]interface{}, 0)
708708
}
709709
} else {
710710
r.verboseLog((depth + 1), "-> authoritative response found")
@@ -868,7 +868,7 @@ func (r *Resolver) cachedLookup(ctx context.Context, q Question, nameServer *Nam
868868
if ok {
869869
r.verboseLog(depth+2, "Cache auth hit for ", authName)
870870
// only want to return if we actually have additionals and authorities from the cache for the caller
871-
if len(cachedResult.Additional) > 0 && len(cachedResult.Authorities) > 0 {
871+
if len(cachedResult.Additionals) > 0 && len(cachedResult.Authorities) > 0 {
872872
return cachedResult, true, StatusNoError, trace, nil
873873
}
874874
// unsuccessful in retrieving from the cache, we'll continue to the wire
@@ -1010,7 +1010,7 @@ func doDoTLookup(ctx context.Context, connInfo *ConnectionInfo, q Question, name
10101010
Protocol: DoTProtocol,
10111011
Answers: []interface{}{},
10121012
Authorities: []interface{}{},
1013-
Additional: []interface{}{},
1013+
Additionals: []interface{}{},
10141014
}
10151015
// if we have it, add the TLS handshake info
10161016
if connInfo.tlsHandshake != nil {
@@ -1082,7 +1082,7 @@ func doDoHLookup(ctx context.Context, httpClient *http.Client, q Question, nameS
10821082
Protocol: DoHProtocol,
10831083
Answers: []interface{}{},
10841084
Authorities: []interface{}{},
1085-
Additional: []interface{}{},
1085+
Additionals: []interface{}{},
10861086
}
10871087
if resp.Request != nil && resp.Request.TLSLog != nil {
10881088
processor := output.Processor{Verbose: false}
@@ -1098,7 +1098,7 @@ func doDoHLookup(ctx context.Context, httpClient *http.Client, q Question, nameS
10981098

10991099
// wireLookupTCP performs a DNS lookup on-the-wire over TCP with the given parameters
11001100
func wireLookupTCP(ctx context.Context, connInfo *ConnectionInfo, q Question, nameServer *NameServer, ednsOptions []dns.EDNS0, recursive, dnssec, checkingDisabled bool) (*SingleQueryResult, *dns.Msg, Status, error) {
1101-
res := SingleQueryResult{Answers: []interface{}{}, Authorities: []interface{}{}, Additional: []interface{}{}}
1101+
res := SingleQueryResult{Answers: []interface{}{}, Authorities: []interface{}{}, Additionals: []interface{}{}}
11021102
res.Resolver = nameServer.String()
11031103

11041104
m := new(dns.Msg)
@@ -1152,7 +1152,7 @@ func wireLookupTCP(ctx context.Context, connInfo *ConnectionInfo, q Question, na
11521152

11531153
// wireLookupUDP performs a DNS lookup on-the-wire over UDP with the given parameters
11541154
func wireLookupUDP(ctx context.Context, connInfo *ConnectionInfo, q Question, nameServer *NameServer, ednsOptions []dns.EDNS0, recursive, dnssec, checkingDisabled bool) (*SingleQueryResult, *dns.Msg, Status, error) {
1155-
res := SingleQueryResult{Answers: []interface{}{}, Authorities: []interface{}{}, Additional: []interface{}{}}
1155+
res := SingleQueryResult{Answers: []interface{}{}, Authorities: []interface{}{}, Additionals: []interface{}{}}
11561156
res.Resolver = nameServer.String()
11571157
res.Protocol = "udp"
11581158

@@ -1196,7 +1196,7 @@ func constructSingleQueryResultFromDNSMsg(res *SingleQueryResult, r *dns.Msg) (*
11961196
for _, ans := range r.Extra {
11971197
inner := ParseAnswer(ans)
11981198
if inner != nil {
1199-
res.Additional = append(res.Additional, inner)
1199+
res.Additionals = append(res.Additionals, inner)
12001200
}
12011201
}
12021202
return res, r, TranslateDNSErrorCode(r.Rcode), nil
@@ -1221,7 +1221,7 @@ func constructSingleQueryResultFromDNSMsg(res *SingleQueryResult, r *dns.Msg) (*
12211221
for _, ans := range r.Extra {
12221222
inner := ParseAnswer(ans)
12231223
if inner != nil {
1224-
res.Additional = append(res.Additional, inner)
1224+
res.Additionals = append(res.Additionals, inner)
12251225
}
12261226
}
12271227
for _, ans := range r.Ns {

0 commit comments

Comments
 (0)