-
Notifications
You must be signed in to change notification settings - Fork 1
/
nsec_test.go
207 lines (196 loc) · 13.7 KB
/
nsec_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
package main
import (
"strings"
"testing"
)
var nsecZone0 string = `
test. 300 IN SOA master.ns.test. mail.nic.test. 12345 1800 3600 7200 14400
test. 300 IN RRSIG SOA 13 1 300 20220130235959 20220101000000 11082 test. WMA4R0HY1Kd9lPAwfnEbFJsvCNXNNGaKd0H1qSuVYh2sHlvHVPXyqKoclEZauYX/P4dEezwW1Ow15LIyJKbNOA==
test. 300 IN NS a.ns.test.
test. 300 IN NS ns.test.
test. 300 IN RRSIG NS 13 1 300 20220130235959 20220101000000 11082 test. Bc/kRNMbUO7fWz0zW7EnkCliA18qQhkBBPHwKBqW8DS5mpSqmRQxu12doazex/v4bbR9uoj6BsAN070dcxFq7w==
test. 300 IN DNSKEY 256 3 13 IcKbK9FMlIsJSzC2o53aPsWGELPvWpWbKnZ2zJiID6nY6TFpMy31z60TNNbbfgJsGloL+zrOZwuV+h6darXNUw== ;{id = 11082 (zsk), size = 256b}
test. 300 IN DNSKEY 257 3 13 t2LVP+yZIiE9JPorgUdZNesR9fYl+715hSjItwxqzxgdH4ApBhqpA/lu/xF9ADmtUAZeU1PbIHXtbwP2HMOyoA== ;{id = 32290 (ksk), size = 256b}
test. 300 IN RRSIG DNSKEY 13 1 300 20220130235959 20220101000000 32290 test. oySh9y2KXbVtUgIMVwhcSHbYnEKb5zegRh/3DG9wylfI70ptdH+UVDLvujCixgCR3NxxDq5nQsrw9MW+uDLzYA==
test. 300 IN NSEC brokensig.test. NS SOA RRSIG NSEC DNSKEY
test. 300 IN RRSIG NSEC 13 1 300 20220130235959 20220101000000 11082 test. m8gEEWBy1qNLHkIwjFm3Z0eXQzh9yiVsK+FLHVD/cVDU3BN06+5AMBiGu9yDUPCq1W1CHyKI+LUU1cWTqk0qlg==
brokensig.test. 300 IN A 10.0.0.0
brokensig.test. 300 IN RRSIG A 13 2 300 20220130235959 20220101000000 11082 test. ogZaRb7PxJTtOrpMdw4nYMQaXIX+uz97/hnYBim9WHxLMt+Rj+kjjgKw9edpaeU4fsZCXFtIjggOQVrI2FA+zg==
brokensig.test. 300 IN NSEC domain.test. A RRSIG NSEC
brokensig.test. 300 IN RRSIG NSEC 13 2 300 20220130235959 20220101000000 11082 test. JZFWTtPt5SKbVIzdV2TbO/ktX7jQbe0VdgS7FZpJgg2DaBvgUp/s+yfaO29N66OMGQI9Y7vWY8Eh826EtHCepQ==
domain.test. 300 IN NS noglue.example.
domain.test. 300 IN NSEC domain2.test. NS RRSIG NSEC
domain.test. 300 IN RRSIG NSEC 13 2 300 20220130235959 20220101000000 11082 test. LtInINyNBeCfIqcf54rC4TvR4xWNajylULWSL8BU/EyY/II1sCrWLorl8XUl/nZFhM5sCEXzqJTm+nRyeR0tnA==
domain2.test. 300 IN NS glue.example.
glue.example. 300 IN A 3.4.5.6
glue.example. 300 IN AAAA aced::cafe
domain2.test. 300 IN NSEC domain3.test. NS RRSIG NSEC
domain2.test. 300 IN RRSIG NSEC 13 2 300 20220130235959 20220101000000 11082 test. d+FhpZA4SVAyGvMadvcuqk2O2LVYzc5/k6VbsKoxpbg82lsYski8ThBpGDs8vKM1UZwdggyIohrUhwFCdd5QxA==
domain3.test. 300 IN A 4.5.6.7
domain3.test. 300 IN NS ns.domain3.test.
domain3.test. 300 IN NS domain3.test.
domain3.test. 300 IN NSEC domain4.test. NS RRSIG NSEC
domain3.test. 300 IN RRSIG NSEC 13 2 300 20220130235959 20220101000000 11082 test. Qyvh8+uA8Y6mdVZGxeY/58E7ZUOmWRQEXXSDw7l6nKwF6ARWxnUxPzXdI4YQf6K8gV0lfnyU1H9e871CdH8+wg==
ns.domain3.test. 300 IN AAAA dead::beef
domain4.test. 300 IN TXT "blahhblahhblahh"
domain4.test. 300 IN RRSIG TXT 13 2 300 20220130235959 20220101000000 11082 test. pAmD3Xyn1cJo1TGW/Pgxm9NGO2KtDl6H5TuLSBpD4QhIgE7pvD7KOnqMvbRkN7p/XiF4oIE50aeVOz0yVYt8Sw==
domain4.test. 300 IN NSEC ns.test. TXT RRSIG NSEC
domain4.test. 300 IN RRSIG NSEC 13 2 300 20220130235959 20220101000000 11082 test. p4u+q9tj80uohqMY1UWP4hbVS7fe1nJXgkXsQQFNVarfZbKx+pQD5oxCAk/sdYen82rF93rr74ON3wWT8vhrLw==
ns.test. 300 IN A 1.2.3.4
ns.test. 300 IN RRSIG A 13 2 300 20220130235959 20220101000000 11082 test. 8susQ9PcknV86vchocRejC8zf77Yacyp7FbLL4neS3K2QKkGDW2k3jUbssAJzLuyddPdjWcdyUgSnnjAhx6EPw==
ns.test. 300 IN AAAA cafe::bad
ns.test. 300 IN RRSIG AAAA 13 2 300 20220130235959 20220101000000 11082 test. ANXH1JnaHO+dtvOrwRPgeecQmKg4JwYd7Fmpezz00HUC5uHeb5/p38nm+X4SEAe2AyoG94a4sMt4/fZ9exjJ/g==
ns.test. 300 IN NSEC a.ns.test. A AAAA RRSIG NSEC
ns.test. 300 IN RRSIG NSEC 13 2 300 20220130235959 20220101000000 11082 test. B6HqjRiv3Iy+84ti9nPXkp+ZYikJF7TxpXWd+zpDWJnORxT6+Yy3yfTbikE8s1oMq25L8UzWh1SByBcklzEoag==
a.ns.test. 300 IN A 2.3.4.5
a.ns.test. 300 IN RRSIG A 13 3 300 20220130235959 20220101000000 11082 test. GQ+I6G4Th64EEaSnaFwm1Y1xNJ3TVBUXVEv4XqhulzI0VPe3B+v0wEojp7TEdT17IIZIRRf8IZ5v+7iiPEW9Dw==
a.ns.test. 300 IN AAAA bad::cafe
a.ns.test. 300 IN RRSIG AAAA 13 3 300 20220130235959 20220101000000 11082 test. 5KqoblqjalCrazgA+/ShmaUrqvRkcA2ZEYeJMLJUQky4MOJep/NHos4FpnwWk7pVGxVYdiSD2I7jqNWQIQDaUA==
a.ns.test. 300 IN NSEC test. A AAAA RRSIG NSEC
a.ns.test. 300 IN RRSIG NSEC 13 3 300 20220130235959 20220101000000 11082 test. kYCdRpsQfO0n9qi+Gn5aOvWnefz+gmJ6m6Van7AxOxYWrL0BQQnDSSDEdtKDhInkpZrPzKyNYUYXK34Moy52wQ==
`
var nsecZone1 string = `
test. 300 IN SOA master.ns.test. mail.nic.test. 12345 1800 3600 7200 14400
test. 300 IN RRSIG SOA 13 1 300 20220130235959 20220101000000 11082 test. WMA4R0HY1Kd9lPAwfnEbFJsvCNXNNGaKd0H1qSuVYh2sHlvHVPXyqKoclEZauYX/P4dEezwW1Ow15LIyJKbNOA==
test. 300 IN NS a.ns.test.
test. 300 IN NS ns.test.
test. 300 IN RRSIG NS 13 1 300 20220130235959 20220101000000 11082 test. Bc/kRNMbUO7fWz0zW7EnkCliA18qQhkBBPHwKBqW8DS5mpSqmRQxu12doazex/v4bbR9uoj6BsAN070dcxFq7w==
test. 300 IN DNSKEY 256 3 13 IcKbK9FMlIsJSzC2o53aPsWGELPvWpWbKnZ2zJiID6nY6TFpMy31z60TNNbbfgJsGloL+zrOZwuV+h6darXNUw== ;{id = 11082 (zsk), size = 256b}
test. 300 IN DNSKEY 257 3 13 t2LVP+yZIiE9JPorgUdZNesR9fYl+715hSjItwxqzxgdH4ApBhqpA/lu/xF9ADmtUAZeU1PbIHXtbwP2HMOyoA== ;{id = 32290 (ksk), size = 256b}
test. 300 IN RRSIG DNSKEY 13 1 300 20220130235959 20220101000000 32290 test. oySh9y2KXbVtUgIMVwhcSHbYnEKb5zegRh/3DG9wylfI70ptdH+UVDLvujCixgCR3NxxDq5nQsrw9MW+uDLzYA==
test. 300 IN NSEC brokensig.test. NS SOA RRSIG NSEC DNSKEY
test. 300 IN RRSIG NSEC 13 1 300 20220130235959 20220101000000 11082 test. m8gEEWBy1qNLHkIwjFm3Z0eXQzh9yiVsK+FLHVD/cVDU3BN06+5AMBiGu9yDUPCq1W1CHyKI+LUU1cWTqk0qlg==
brokensig.test. 300 IN A 10.0.0.0
brokensig.test. 300 IN RRSIG A 13 2 300 20220130235959 20220101000000 11082 test. ogZaRb7PxJTtOrpMdw4nYMQaXIX+uz97/hnYBim9WHxLMt+Rj+kjjgKw9edpaeU4fsZCXFtIjggOQVrI2FA+zg==
brokensig.test. 300 IN NSEC domain.test. A RRSIG NSEC
brokensig.test. 300 IN RRSIG NSEC 13 2 300 20220130235959 20220101000000 11082 test. JZFWTtPt5SKbVIzdV2TbO/ktX7jQbe0VdgS7FZpJgg2DaBvgUp/s+yfaO29N66OMGQI9Y7vWY8Eh826EtHCepQ==
domain.test. 300 IN NS noglue.example.
domain.test. 300 IN NSEC domain2.test. NS RRSIG NSEC
domain.test. 300 IN RRSIG NSEC 13 2 300 20220130235959 20220101000000 11082 test. LtInINyNBeCfIqcf54rC4TvR4xWNajylULWSL8BU/EyY/II1sCrWLorl8XUl/nZFhM5sCEXzqJTm+nRyeR0tnA==
domain2.test. 300 IN NS glue.example.
glue.example. 300 IN A 3.4.5.6
glue.example. 300 IN AAAA aced::cafe
domain2.test. 300 IN NSEC domain3.test. NS RRSIG NSEC
domain2.test. 300 IN RRSIG NSEC 13 2 300 20220130235959 20220101000000 11082 test. d+FhpZA4SVAyGvMadvcuqk2O2LVYzc5/k6VbsKoxpbg82lsYski8ThBpGDs8vKM1UZwdggyIohrUhwFCdd5QxA==
domain3.test. 300 IN A 4.5.6.7
domain3.test. 300 IN NS ns.domain3.test.
domain3.test. 300 IN NS domain3.test.
domain3.test. 300 IN NSEC ns.test. NS RRSIG NSEC
domain3.test. 300 IN RRSIG NSEC 13 2 300 20220130235959 20220101000000 11082 test. Qyvh8+uA8Y6mdVZGxeY/58E7ZUOmWRQEXXSDw7l6nKwF6ARWxnUxPzXdI4YQf6K8gV0lfnyU1H9e871CdH8+wg==
ns.domain3.test. 300 IN AAAA dead::beef
domain4.test. 300 IN TXT "blahhblahhblahh"
domain4.test. 300 IN RRSIG TXT 13 2 300 20220130235959 20220101000000 11082 test. pAmD3Xyn1cJo1TGW/Pgxm9NGO2KtDl6H5TuLSBpD4QhIgE7pvD7KOnqMvbRkN7p/XiF4oIE50aeVOz0yVYt8Sw==
ns.test. 300 IN A 1.2.3.4
ns.test. 300 IN RRSIG A 13 2 300 20220130235959 20220101000000 11082 test. 8susQ9PcknV86vchocRejC8zf77Yacyp7FbLL4neS3K2QKkGDW2k3jUbssAJzLuyddPdjWcdyUgSnnjAhx6EPw==
ns.test. 300 IN AAAA cafe::bad
ns.test. 300 IN RRSIG AAAA 13 2 300 20220130235959 20220101000000 11082 test. ANXH1JnaHO+dtvOrwRPgeecQmKg4JwYd7Fmpezz00HUC5uHeb5/p38nm+X4SEAe2AyoG94a4sMt4/fZ9exjJ/g==
ns.test. 300 IN NSEC a.ns.test. A AAAA RRSIG NSEC
ns.test. 300 IN RRSIG NSEC 13 2 300 20220130235959 20220101000000 11082 test. B6HqjRiv3Iy+84ti9nPXkp+ZYikJF7TxpXWd+zpDWJnORxT6+Yy3yfTbikE8s1oMq25L8UzWh1SByBcklzEoag==
a.ns.test. 300 IN A 2.3.4.5
a.ns.test. 300 IN RRSIG A 13 3 300 20220130235959 20220101000000 11082 test. GQ+I6G4Th64EEaSnaFwm1Y1xNJ3TVBUXVEv4XqhulzI0VPe3B+v0wEojp7TEdT17IIZIRRf8IZ5v+7iiPEW9Dw==
a.ns.test. 300 IN AAAA bad::cafe
a.ns.test. 300 IN RRSIG AAAA 13 3 300 20220130235959 20220101000000 11082 test. 5KqoblqjalCrazgA+/ShmaUrqvRkcA2ZEYeJMLJUQky4MOJep/NHos4FpnwWk7pVGxVYdiSD2I7jqNWQIQDaUA==
a.ns.test. 300 IN NSEC test. A AAAA RRSIG NSEC
a.ns.test. 300 IN NSEC test. A AAAA CNAME RRSIG NSEC
a.ns.test. 300 IN RRSIG NSEC 13 3 300 20220130235959 20220101000000 11082 test. kYCdRpsQfO0n9qi+Gn5aOvWnefz+gmJ6m6Van7AxOxYWrL0BQQnDSSDEdtKDhInkpZrPzKyNYUYXK34Moy52wQ==
`
var nsecZone2 string = `
test. 300 IN SOA master.ns.test. mail.nic.test. 12345 1800 3600 7200 14400
test. 300 IN RRSIG SOA 13 1 300 20220130235959 20220101000000 11082 test. WMA4R0HY1Kd9lPAwfnEbFJsvCNXNNGaKd0H1qSuVYh2sHlvHVPXyqKoclEZauYX/P4dEezwW1Ow15LIyJKbNOA==
test. 300 IN NS a.ns.test.
test. 300 IN NS ns.test.
test. 300 IN RRSIG NS 13 1 300 20220130235959 20220101000000 11082 test. Bc/kRNMbUO7fWz0zW7EnkCliA18qQhkBBPHwKBqW8DS5mpSqmRQxu12doazex/v4bbR9uoj6BsAN070dcxFq7w==
test. 300 IN DNSKEY 256 3 13 IcKbK9FMlIsJSzC2o53aPsWGELPvWpWbKnZ2zJiID6nY6TFpMy31z60TNNbbfgJsGloL+zrOZwuV+h6darXNUw== ;{id = 11082 (zsk), size = 256b}
test. 300 IN DNSKEY 257 3 13 t2LVP+yZIiE9JPorgUdZNesR9fYl+715hSjItwxqzxgdH4ApBhqpA/lu/xF9ADmtUAZeU1PbIHXtbwP2HMOyoA== ;{id = 32290 (ksk), size = 256b}
test. 300 IN RRSIG DNSKEY 13 1 300 20220130235959 20220101000000 32290 test. oySh9y2KXbVtUgIMVwhcSHbYnEKb5zegRh/3DG9wylfI70ptdH+UVDLvujCixgCR3NxxDq5nQsrw9MW+uDLzYA==
test. 300 IN NSEC brokensig.test. NS SOA RRSIG NSEC DNSKEY
test. 300 IN RRSIG NSEC 13 1 300 20220130235959 20220101000000 11082 test. m8gEEWBy1qNLHkIwjFm3Z0eXQzh9yiVsK+FLHVD/cVDU3BN06+5AMBiGu9yDUPCq1W1CHyKI+LUU1cWTqk0qlg==
brokensig.test. 300 IN A 10.0.0.0
brokensig.test. 300 IN RRSIG A 13 2 300 20220130235959 20220101000000 11082 test. ogZaRb7PxJTtOrpMdw4nYMQaXIX+uz97/hnYBim9WHxLMt+Rj+kjjgKw9edpaeU4fsZCXFtIjggOQVrI2FA+zg==
brokensig.test. 300 IN NSEC domain.test. A RRSIG NSEC
brokensig.test. 300 IN RRSIG NSEC 13 2 300 20220130235959 20220101000000 11082 test. JZFWTtPt5SKbVIzdV2TbO/ktX7jQbe0VdgS7FZpJgg2DaBvgUp/s+yfaO29N66OMGQI9Y7vWY8Eh826EtHCepQ==
domain.test. 300 IN NS noglue.example.
domain.test. 300 IN NSEC domain2.test. NS RRSIG NSEC
domain.test. 300 IN RRSIG NSEC 13 2 300 20220130235959 20220101000000 11082 test. LtInINyNBeCfIqcf54rC4TvR4xWNajylULWSL8BU/EyY/II1sCrWLorl8XUl/nZFhM5sCEXzqJTm+nRyeR0tnA==
domain2.test. 300 IN NS glue.example.
glue.example. 300 IN A 3.4.5.6
glue.example. 300 IN AAAA aced::cafe
glue.example. 300 IN NSEC domain2.test. A AAAA NSEC
domain2.test. 300 IN NSEC domain3.test. NS RRSIG NSEC
domain2.test. 300 IN RRSIG NSEC 13 2 300 20220130235959 20220101000000 11082 test. d+FhpZA4SVAyGvMadvcuqk2O2LVYzc5/k6VbsKoxpbg82lsYski8ThBpGDs8vKM1UZwdggyIohrUhwFCdd5QxA==
domain3.test. 300 IN A 4.5.6.7
domain3.test. 300 IN NS ns.domain3.test.
domain3.test. 300 IN NS domain3.test.
domain3.test. 300 IN NSEC ns.test. NS RRSIG NSEC
domain3.test. 300 IN RRSIG NSEC 13 2 300 20220130235959 20220101000000 11082 test. Qyvh8+uA8Y6mdVZGxeY/58E7ZUOmWRQEXXSDw7l6nKwF6ARWxnUxPzXdI4YQf6K8gV0lfnyU1H9e871CdH8+wg==
ns.domain3.test. 300 IN AAAA dead::beef
domain4.test. 300 IN TXT "blahhblahhblahh"
domain4.test. 300 IN RRSIG TXT 13 2 300 20220130235959 20220101000000 11082 test. pAmD3Xyn1cJo1TGW/Pgxm9NGO2KtDl6H5TuLSBpD4QhIgE7pvD7KOnqMvbRkN7p/XiF4oIE50aeVOz0yVYt8Sw==
ns.test. 300 IN A 1.2.3.4
ns.test. 300 IN RRSIG A 13 2 300 20220130235959 20220101000000 11082 test. 8susQ9PcknV86vchocRejC8zf77Yacyp7FbLL4neS3K2QKkGDW2k3jUbssAJzLuyddPdjWcdyUgSnnjAhx6EPw==
ns.test. 300 IN AAAA cafe::bad
ns.test. 300 IN RRSIG AAAA 13 2 300 20220130235959 20220101000000 11082 test. ANXH1JnaHO+dtvOrwRPgeecQmKg4JwYd7Fmpezz00HUC5uHeb5/p38nm+X4SEAe2AyoG94a4sMt4/fZ9exjJ/g==
ns.test. 300 IN NSEC a.ns.test. A AAAA RRSIG NSEC
ns.test. 300 IN RRSIG NSEC 13 2 300 20220130235959 20220101000000 11082 test. B6HqjRiv3Iy+84ti9nPXkp+ZYikJF7TxpXWd+zpDWJnORxT6+Yy3yfTbikE8s1oMq25L8UzWh1SByBcklzEoag==
a.ns.test. 300 IN A 2.3.4.5
a.ns.test. 300 IN RRSIG A 13 3 300 20220130235959 20220101000000 11082 test. GQ+I6G4Th64EEaSnaFwm1Y1xNJ3TVBUXVEv4XqhulzI0VPe3B+v0wEojp7TEdT17IIZIRRf8IZ5v+7iiPEW9Dw==
a.ns.test. 300 IN AAAA bad::cafe
a.ns.test. 300 IN RRSIG AAAA 13 3 300 20220130235959 20220101000000 11082 test. 5KqoblqjalCrazgA+/ShmaUrqvRkcA2ZEYeJMLJUQky4MOJep/NHos4FpnwWk7pVGxVYdiSD2I7jqNWQIQDaUA==
a.ns.test. 300 IN NSEC test. A AAAA RRSIG NSEC
a.ns.test. 300 IN NSEC test. A AAAA CNAME RRSIG NSEC
a.ns.test. 300 IN RRSIG NSEC 13 3 300 20220130235959 20220101000000 11082 test. kYCdRpsQfO0n9qi+Gn5aOvWnefz+gmJ6m6Van7AxOxYWrL0BQQnDSSDEdtKDhInkpZrPzKyNYUYXK34Moy52wQ==
`
func TestCheckNsec(t *testing.T) {
cases := []struct {
Zone string
Result
}{
{nsecZone0, Result{0, 0}},
{nsecZone1, Result{5, 0}},
{nsecZone2, Result{6, 0}},
}
for i, c := range cases {
myReader := strings.NewReader(c.Zone)
origin, cache := readZonefile(myReader)
if r := checkNSEC(cache, origin); r != c.Result {
t.Logf("Test case %d: checkNSEC expected %d errors and %d warnings, found %d errors and %d warnings.\n.", i, c.errors, c.warnings, r.errors, r.warnings)
t.Fail()
}
}
}
func TestCheckNsecChain(t *testing.T) {
cases := []struct {
Zone string
Result
}{
{nsecZone0, Result{0, 0}},
{nsecZone1, Result{3, 0}},
{nsecZone2, Result{3, 0}},
}
for i, c := range cases {
myReader := strings.NewReader(c.Zone)
origin, cache := readZonefile(myReader)
if r := checkNsecChain(cache, origin); r != c.Result {
t.Logf("Test case %d: checkNsecChain expected %d errors and %d warnings, found %d errors and %d warnings.\n.", i, c.errors, c.warnings, r.errors, r.warnings)
t.Fail()
}
}
}
func TestCheckNsecNoAdditional(t *testing.T) {
cases := []struct {
Zone string
Result
}{
{nsecZone0, Result{0, 0}},
{nsecZone1, Result{2, 0}},
{nsecZone2, Result{3, 0}},
}
for i, c := range cases {
myReader := strings.NewReader(c.Zone)
origin, cache := readZonefile(myReader)
if r := checkNoAdditionalNsec(cache, origin); r != c.Result {
t.Logf("Test case %d: checkNoAdditionalNsec expected %d errors and %d warnings, found %d errors and %d warnings.\n.", i, c.errors, c.warnings, r.errors, r.warnings)
t.Fail()
}
}
}