line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Zonemaster::Engine::Constants; |
2
|
|
|
|
|
|
|
|
3
|
26
|
|
|
26
|
|
165
|
use version; our $VERSION = version->declare("v1.2.2"); |
|
26
|
|
|
|
|
53
|
|
|
26
|
|
|
|
|
179
|
|
4
|
|
|
|
|
|
|
|
5
|
26
|
|
|
26
|
|
2346
|
use strict; |
|
26
|
|
|
|
|
75
|
|
|
26
|
|
|
|
|
606
|
|
6
|
26
|
|
|
26
|
|
139
|
use warnings; |
|
26
|
|
|
|
|
57
|
|
|
26
|
|
|
|
|
722
|
|
7
|
|
|
|
|
|
|
|
8
|
26
|
|
|
26
|
|
138
|
use Carp; |
|
26
|
|
|
|
|
54
|
|
|
26
|
|
|
|
|
1647
|
|
9
|
|
|
|
|
|
|
|
10
|
26
|
|
|
26
|
|
7939
|
use English qw( -no_match_vars ) ; |
|
26
|
|
|
|
|
61111
|
|
|
26
|
|
|
|
|
133
|
|
11
|
|
|
|
|
|
|
|
12
|
26
|
|
|
26
|
|
8554
|
use parent 'Exporter'; |
|
26
|
|
|
|
|
57
|
|
|
26
|
|
|
|
|
191
|
|
13
|
26
|
|
|
26
|
|
1368
|
use Zonemaster::Engine::Net::IP; |
|
26
|
|
|
|
|
56
|
|
|
26
|
|
|
|
|
849
|
|
14
|
26
|
|
|
26
|
|
11245
|
use Text::CSV; |
|
26
|
|
|
|
|
373788
|
|
|
26
|
|
|
|
|
1262
|
|
15
|
26
|
|
|
26
|
|
6504
|
use File::ShareDir qw[dist_dir dist_file]; |
|
26
|
|
|
|
|
99716
|
|
|
26
|
|
|
|
|
1629
|
|
16
|
|
|
|
|
|
|
|
17
|
26
|
|
|
26
|
|
8352
|
use Readonly; |
|
26
|
|
|
|
|
76390
|
|
|
26
|
|
|
|
|
17936
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our @EXPORT_OK = qw[ |
20
|
|
|
|
|
|
|
$ALGO_STATUS_DEPRECATED |
21
|
|
|
|
|
|
|
$ALGO_STATUS_PRIVATE |
22
|
|
|
|
|
|
|
$ALGO_STATUS_RESERVED |
23
|
|
|
|
|
|
|
$ALGO_STATUS_UNASSIGNED |
24
|
|
|
|
|
|
|
$ALGO_STATUS_VALID |
25
|
|
|
|
|
|
|
$DURATION_12_HOURS_IN_SECONDS |
26
|
|
|
|
|
|
|
$DURATION_180_DAYS_IN_SECONDS |
27
|
|
|
|
|
|
|
$FQDN_MAX_LENGTH |
28
|
|
|
|
|
|
|
$LABEL_MAX_LENGTH |
29
|
|
|
|
|
|
|
$IP_VERSION_4 |
30
|
|
|
|
|
|
|
$IP_VERSION_6 |
31
|
|
|
|
|
|
|
$MAX_SERIAL_VARIATION |
32
|
|
|
|
|
|
|
$MINIMUM_NUMBER_OF_NAMESERVERS |
33
|
|
|
|
|
|
|
$SOA_DEFAULT_TTL_MAXIMUM_VALUE |
34
|
|
|
|
|
|
|
$SOA_DEFAULT_TTL_MINIMUM_VALUE |
35
|
|
|
|
|
|
|
$SOA_EXPIRE_MINIMUM_VALUE |
36
|
|
|
|
|
|
|
$SOA_REFRESH_MINIMUM_VALUE |
37
|
|
|
|
|
|
|
$SOA_RETRY_MINIMUM_VALUE |
38
|
|
|
|
|
|
|
$UDP_PAYLOAD_LIMIT |
39
|
|
|
|
|
|
|
$UDP_COMMON_EDNS_LIMIT |
40
|
|
|
|
|
|
|
@IPV4_SPECIAL_ADDRESSES |
41
|
|
|
|
|
|
|
@IPV6_SPECIAL_ADDRESSES |
42
|
|
|
|
|
|
|
]; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
45
|
|
|
|
|
|
|
all => \@EXPORT_OK, |
46
|
|
|
|
|
|
|
algo => [ |
47
|
|
|
|
|
|
|
qw($ALGO_STATUS_DEPRECATED $ALGO_STATUS_PRIVATE $ALGO_STATUS_RESERVED $ALGO_STATUS_UNASSIGNED $ALGO_STATUS_VALID) |
48
|
|
|
|
|
|
|
], |
49
|
|
|
|
|
|
|
name => [qw($FQDN_MAX_LENGTH $LABEL_MAX_LENGTH)], |
50
|
|
|
|
|
|
|
ip => [qw($IP_VERSION_4 $IP_VERSION_6)], |
51
|
|
|
|
|
|
|
soa => [ |
52
|
|
|
|
|
|
|
qw($SOA_DEFAULT_TTL_MAXIMUM_VALUE $SOA_DEFAULT_TTL_MINIMUM_VALUE $SOA_EXPIRE_MINIMUM_VALUE $SOA_REFRESH_MINIMUM_VALUE $SOA_RETRY_MINIMUM_VALUE $DURATION_12_HOURS_IN_SECONDS $DURATION_180_DAYS_IN_SECONDS $MAX_SERIAL_VARIATION) |
53
|
|
|
|
|
|
|
], |
54
|
|
|
|
|
|
|
misc => [qw($UDP_PAYLOAD_LIMIT $UDP_COMMON_EDNS_LIMIT $MINIMUM_NUMBER_OF_NAMESERVERS)], |
55
|
|
|
|
|
|
|
addresses => [qw(@IPV4_SPECIAL_ADDRESSES @IPV6_SPECIAL_ADDRESSES)], |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Readonly our $ALGO_STATUS_DEPRECATED => 1; |
59
|
|
|
|
|
|
|
Readonly our $ALGO_STATUS_PRIVATE => 4; |
60
|
|
|
|
|
|
|
Readonly our $ALGO_STATUS_RESERVED => 2; |
61
|
|
|
|
|
|
|
Readonly our $ALGO_STATUS_UNASSIGNED => 3; |
62
|
|
|
|
|
|
|
Readonly our $ALGO_STATUS_VALID => 5; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Readonly our $DURATION_12_HOURS_IN_SECONDS => 12 * 60 * 60; |
65
|
|
|
|
|
|
|
Readonly our $DURATION_180_DAYS_IN_SECONDS => 180 * 24 * 60 * 60; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Maximum length of ASCII version of a domain name, with trailing dot. |
68
|
|
|
|
|
|
|
Readonly our $FQDN_MAX_LENGTH => 254; |
69
|
|
|
|
|
|
|
Readonly our $LABEL_MAX_LENGTH => 63; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Readonly our $IP_VERSION_4 => 4; |
72
|
|
|
|
|
|
|
Readonly our $IP_VERSION_6 => 6; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Readonly our $MAX_SERIAL_VARIATION => 0; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Readonly our $MINIMUM_NUMBER_OF_NAMESERVERS => 2; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Readonly our $SOA_DEFAULT_TTL_MAXIMUM_VALUE => 86_400; # 1 day |
79
|
|
|
|
|
|
|
Readonly our $SOA_DEFAULT_TTL_MINIMUM_VALUE => 300; # 5 minutes |
80
|
|
|
|
|
|
|
Readonly our $SOA_EXPIRE_MINIMUM_VALUE => 604_800; # 1 week |
81
|
|
|
|
|
|
|
Readonly our $SOA_REFRESH_MINIMUM_VALUE => 14_400; # 4 hours |
82
|
|
|
|
|
|
|
Readonly our $SOA_RETRY_MINIMUM_VALUE => 3_600; # 1 hour |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Readonly our $UDP_PAYLOAD_LIMIT => 512; |
85
|
|
|
|
|
|
|
Readonly our $UDP_COMMON_EDNS_LIMIT => 4_096; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Readonly::Array our @IPV4_SPECIAL_ADDRESSES => _extract_iana_ip_blocks($IP_VERSION_4); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Readonly::Array our @IPV6_SPECIAL_ADDRESSES => _extract_iana_ip_blocks($IP_VERSION_6); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub _extract_iana_ip_blocks { |
92
|
52
|
|
|
52
|
|
305
|
my $ip_version = shift; |
93
|
52
|
|
|
|
|
472
|
my @list = (); |
94
|
|
|
|
|
|
|
|
95
|
52
|
|
|
|
|
479
|
my $csv = Text::CSV->new ({ |
96
|
|
|
|
|
|
|
binary => 1, |
97
|
|
|
|
|
|
|
auto_diag => 1, |
98
|
|
|
|
|
|
|
sep_char => q{,} |
99
|
|
|
|
|
|
|
}); |
100
|
52
|
|
|
|
|
8228
|
my @files_details = ( |
101
|
|
|
|
|
|
|
{ name => q{iana-ipv4-special-registry.csv}, ip_version => $IP_VERSION_4 }, |
102
|
|
|
|
|
|
|
{ name => q{iana-ipv6-special-registry.csv}, ip_version => $IP_VERSION_6 }, |
103
|
|
|
|
|
|
|
); |
104
|
|
|
|
|
|
|
|
105
|
52
|
|
|
|
|
541
|
foreach my $file_details ( @files_details ) { |
106
|
104
|
|
|
|
|
216
|
my $first_line = 1; |
107
|
104
|
100
|
|
|
|
163
|
next if ${$file_details}{ip_version} != $ip_version; |
|
104
|
|
|
|
|
389
|
|
108
|
52
|
|
|
|
|
114
|
my $makefile_name = 'Zonemaster-Engine'; # This must be the same name as "name" in Makefile.PL |
109
|
52
|
|
|
|
|
103
|
my $data_location = dist_file($makefile_name, ${$file_details}{name}); |
|
52
|
|
|
|
|
253
|
|
110
|
26
|
50
|
|
26
|
|
191
|
open(my $data, '<:encoding(utf8)', $data_location) or croak "Cannot open '${data_location}' : ${OS_ERROR}"; |
|
26
|
|
|
|
|
57
|
|
|
26
|
|
|
|
|
219
|
|
|
52
|
|
|
|
|
9657
|
|
111
|
52
|
|
|
|
|
325070
|
while (my $fields = $csv->getline( $data )) { |
112
|
1118
|
100
|
|
|
|
37518
|
if ( $first_line ) { |
113
|
52
|
|
|
|
|
116
|
$first_line = 0; |
114
|
52
|
|
|
|
|
1139
|
next; |
115
|
|
|
|
|
|
|
} |
116
|
1066
|
|
|
|
|
2049
|
my $address_data = $fields->[0]; |
117
|
1066
|
|
|
|
|
2106
|
$address_data =~ s/[ ]+//smx; |
118
|
1066
|
|
|
|
|
2959
|
foreach my $address_item ( split /,/smx, $address_data ) { |
119
|
1092
|
|
|
|
|
4992
|
$address_item =~ s/(\A.+\/\d+).*\z/$1/smx; |
120
|
1092
|
|
|
|
|
4221
|
push @list, { ip => Zonemaster::Engine::Net::IP->new( $address_item ), name => $fields->[1], reference => $fields->[2] }; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
} |
123
|
52
|
50
|
|
|
|
5556
|
close $data or croak "Cannot close '${data_location}' : ${OS_ERROR}"; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
52
|
|
|
|
|
1253
|
return @list; |
127
|
|
|
|
|
|
|
} ## end sub _extract_iana_ip_blocks |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
1; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 NAME |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Zonemaster::Engine::Constants - module holding constants used in test modules |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 SYNOPSIS |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
use Zonemaster::Engine::Constants ':all'; |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 EXPORTED GROUPS |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=over |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item all |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
All exportable names. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item algo |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
DNSSEC algorithms. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item name |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Label and name lengths. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item ip |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
IP version constants. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item soa |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
SOA value limits. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=item misc |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
UDP payload limit and minimum number of nameservers per zone. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=item addresses |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Address classes for IPv4 and IPv6. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item extract_iana_ip_blocks($ip_version) |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Will extract IPs details from IANA files. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=back |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 EXPORTED NAMES |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=over |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item * |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
C<$ALGO_STATUS_DEPRECATED> |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=item * |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
C<$ALGO_STATUS_PRIVATE> |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=item * |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
C<$ALGO_STATUS_RESERVED> |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=item * |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
C<$ALGO_STATUS_UNASSIGNED> |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=item * |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
C<$ALGO_STATUS_VALID> |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=item * |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
C<$DURATION_12_HOURS_IN_SECONDS> |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=item * |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
C<$DURATION_180_DAYS_IN_SECONDS> |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=item * |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
C<$FQDN_MAX_LENGTH> |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=item * |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
C<$LABEL_MAX_LENGTH> |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=item * |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
C<$IP_VERSION_4> |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=item * |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
C<$IP_VERSION_6> |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=item * |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
C<$MAX_SERIAL_VARIATION> |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=item * |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
C<$MINIMUM_NUMBER_OF_NAMESERVERS> |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=item * |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
C<$SOA_DEFAULT_TTL_MAXIMUM_VALUE> |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=item * |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
C<$SOA_DEFAULT_TTL_MINIMUM_VALUE> |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=item * |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
C<$SOA_EXPIRE_MINIMUM_VALUE> |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=item * |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
C<$SOA_REFRESH_MINIMUM_VALUE> |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=item * |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
C<$SOA_RETRY_MINIMUM_VALUE> |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=item * |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
C<$UDP_PAYLOAD_LIMIT> |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=item * |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
C<UDP_COMMON_EDNS_LIMIT> |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=item * |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
C<@IPV4_SPECIAL_ADDRESSES> |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=item * |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
C<@IPV6_SPECIAL_ADDRESSES> |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=back |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
=cut |