BlockerHelper/backends/cloudflare.pm

filter: Statementstmt 42.7% 179 / 419 Branchbran 39.4% 71 / 180 Conditioncond 49.2% 31 / 63 MC/DCmcdc 17.1% 6 / 35 Subroutinesub 87.5% 21 / 24 Podpod 100% 13 / 13 totaltotal 43.7% 321 / 734 CC 117 SCAR 39.3
CC
117
Cov
42%
_request
132.0
unban_cidr
76.6
new
74.0
CRAP 50.7
« BlockerHelper/backends/fastly.pm ↑ Summary BlockerHelper/backends/checkpoint.pm »
1 package Net::Firewall::BlockerHelper::backends::cloudflare;
2  
3 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use base qw( Error::Helper Net::Firewall::BlockerHelper::Util );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Regexp::IPv4 qw($IPv4_re);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Regexp::IPv6 qw($IPv6_re);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 =head1 NAME
11  
12 Net::Firewall::BlockerHelper::backends::cloudflare - Cloudflare IP access rules backend for Net::Firewall::BlockerHelper.
13  
14 =head1 VERSION
15  
16 Version 0.2.0
17  
18 =cut
19  
20 1 our $VERSION = '0.2.0';
21  
22 =head1 SYNOPSIS
23  
24 use Net::Firewall::BlockerHelper;
25  
26 my $fw_helper = Net::Firewall::BlockerHelper->new(
27 backend => 'cloudflare',
28 name => 'ssh',
29 options => {
30 token => $cf_api_token,
31 zone => $cf_zone_id,
32 },
33 );
34  
35 $fw_helper->init_backend;
36 $fw_helper->ban(ban => '1.2.3.4');
37 $fw_helper->unban(ban => '1.2.3.4');
38  
39 =head1 DESCRIPTION
40  
41 Blocks IPs remotely via the Cloudflare v4 API using IP access rules,
42 equivalent to the fail2ban cloudflare and cloudflare-token actions, but
43 using L<LWP::UserAgent> rather than curl.
44  
45 Auth is via either a API token (preferred, the C<token> option) or the
46 legacy email plus global API key (the C<email> and C<key> options). If the
47 C<zone> option is set the rules are managed zone level, otherwise user
48 level.
49  
50 Blocking is per IP; ports and protocols are not supported and specifying
51 them is an error.
52  
53 L<LWP::UserAgent> is only loaded at run time, so it is only required if
54 this backend is actually used. For https, L<LWP::Protocol::https> must be
55 present as well.
56  
57 =head1 NOTES
58  
59 This backend was written going off the API docs and actual testing is
60 needed to double check a few things as the exact behavior is not clear.
61  
62 teardown currently only removes the single IP access rules, leaving CIDR
63 bans in place remotely, while flush removes both. A re_init after a
64 teardown will re-add the CIDR bans, and how the API handles creating a
65 rule that already exists needs checking.
66  
67 =head1 METHODS
68  
69 =head2 new
70  
71 Initiates the the object.
72  
73 - options :: Backend specific options. See below.
74 - Default :: {}
75  
76 - prefix :: Prefix to use. Must match the regex /^[a-zA-Z0-9]+$/
77 - default :: kur
78  
79 - name :: Name of this specific instance. This must be specified.
80 - default :: undef
81  
82 Ports and protocols are not supported by this backend and specifying either
83 is an error.
84  
85 The options hash accepts the following. Either token or both email and key
86 must be specified.
87  
88 - token :: Cloudflare API token, used as a bearer token. Ideally
89 restricted to just the needed permissions.
90 - Default :: undef
91  
92 - email :: Account email for legacy global API key auth.
93 - Default :: undef
94  
95 - key :: Legacy global API key.
96 - Default :: undef
97  
98 - zone :: Zone ID to manage the rules under. If not set, the rules are
99 managed at the user level.
100 - Default :: undef
101  
102 - mode :: What Cloudflare should do with matching requests. One of
103 'block', 'challenge', 'js_challenge', or 'managed_challenge'.
104 - Default :: block
105  
106 - notes :: Note attached to created rules, also used to find them again
107 for removal.
108 - Default :: <prefix>_<name>
109  
110 - timeout :: HTTP timeout in seconds.
111 - Default :: 30
112  
113 All errors are considered fatal, meaning if new fails it will die.
114  
115 =cut
116  
117 5 ▶sub new {
Subroutine new: called CC=31 SCAR=43.0
Pod documented
118 5 my ( $blank, %opts ) = @_;
119  
120 5 my $self = {
121 perror => undef,
122 error => undef,
123 errorLine => undef,
124 errorFilename => undef,
125 errorString => "",
126 errorExtra => {
127 all_errors_fatal => 1,
128 # all_fatal is what Error::Helper 2.1.0 actually checks; all_errors_fatal
129 # is kept for the name documented in its POD
130 all_fatal => 1,
131 flags => {
132 1 => 'notInited',
133 6 => 'invalidPrefixSpecified',
134 7 => 'invalidName',
135 8 => 'optionsNotHash',
136 9 => 'noBanItem',
137 10 => 'banItemNotIP',
138 12 => 'backendInitError',
139 13 => 'banFailed',
140 14 => 'unbanFailed',
141 15 => 'listFailed',
142 16 => 'reInitFailed',
143 17 => 'teardownFailed',
144 18 => 'alreadyInited',
145 20 => 'modeInvalid',
146 23 => 'initFailed',
147 24 => 'checkFailed',
148 25 => 'flushFailed',
149 26 => 'portsNotSupported',
150 27 => 'protocolsNotSupported',
151 28 => 'optionInvalid',
152 29 => 'banCidrFailed',
153 30 => 'unbanCidrFailed',
154 31 => 'cidrItemNotCidr',
155 32 => 'cidrNotSupported',
156 33 => 'listCidrFailed',
157 },
158 fatal_flags => {},
159 perror_not_fatal => 0,
160 },
161 options => {},
162 ports => [],
163 protocols => [],
164 testing => undef,
165 test_data => undef,
166 prefix => 'kur',
167 frontend_obj => undef,
168 inited => 0,
169 banned => {},
170 banned_cidr => {},
171 cidr_supported => 1,
172 ua => undef,
173 };
174 5 bless $self;
175  
176 # blocking is per IP; the API has no concept of ports or protocols
177 5 ▶ if ( defined( $opts{ports} ) && ref( $opts{ports} ) eq 'ARRAY' && defined( $opts{ports}[0] ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opts{"ports"} and ref $opts{"ports"} eq "ARRAY" and defined $opts{"ports"}[0]) 1 4 5
Condition83%5/6
defined $opts{"ports"} and ref $opts{"ports"} eq "ARRAY" and defined $opts{"ports"}[0]
!ll&&!rl&&r
221
defined $opts{"ports"} and ref $opts{"ports"} eq "ARRAY"
!ll&&!rl&&r
203
MC/DC66%2/3
defined $opts{"ports"} and ref $opts{"ports"} eq "ARRAY" and defined $opts{"ports"}[0]
defined $opts{"ports"} ref $opts{"ports"} eq "ARRAY" defined $opts{"ports"}[0]
Truth table75%3/4
A and B and C
A= defined $opts{"ports"}B= ref $opts{"ports"} eq "ARRAY"C= defined $opts{"ports"}[0]
ABCresult
0XX0
10X0
1100
1111
178 1 $self->{perror} = 1;
179 1 $self->{error} = 26;
180 1 $self->{errorString} = 'the cloudflare backend blocks whole IPs and does not support ports';
181 1 $self->warn;
182 }
183 4 ▶ if ( defined( $opts{protocols} ) && ref( $opts{protocols} ) eq 'ARRAY' && defined( $opts{protocols}[0] ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opts{"protocols"} and ref $opts{"protocols"} eq "ARRAY" and defined $opts{"protocols"}[0]) 0 4 4
Condition66%4/6
defined $opts{"protocols"} and ref $opts{"protocols"} eq "ARRAY" and defined $opts{"protocols"}[0]
!ll&&!rl&&r
220
defined $opts{"protocols"} and ref $opts{"protocols"} eq "ARRAY"
!ll&&!rl&&r
202
MC/DC0%0/3
defined $opts{"protocols"} and ref $opts{"protocols"} eq "ARRAY" and defined $opts{"protocols"}[0]
defined $opts{"protocols"} ref $opts{"protocols"} eq "ARRAY" defined $opts{"protocols"}[0]
Truth table50%2/4
A and B and C
A= defined $opts{"protocols"}B= ref $opts{"protocols"} eq "ARRAY"C= defined $opts{"protocols"}[0]
ABCresult
0XX0
10X0
1100
1111
184 0 $self->{perror} = 1;
185 0 $self->{error} = 27;
186 0 $self->{errorString} = 'the cloudflare backend blocks whole IPs and does not support protocols';
187 0 $self->warn;
188 }
189  
190 # make sure prefix is sane if defiend
191 4 ▶ if ( defined( $opts{prefix} ) && $opts{prefix} !~ /^[a-zA-Z0-9]+$/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $opts{'prefix'} and not $opts{'prefix'} =~ /^[a-zA-Z0-9]+$/) { } 0 4 4
elsif (defined $opts{'prefix'}) { } 2 2 4
Condition66%2/3
defined $opts{"prefix"} and not $opts{"prefix"} =~ /^[a-zA-Z0-9]+$/
!ll&&!rl&&r
220
MC/DC0%0/2
defined $opts{"prefix"} and not $opts{"prefix"} =~ /^[a-zA-Z0-9]+$/
defined $opts{"prefix"} not $opts{"prefix"} =~ /^[a-zA-Z0-9]+$/
Truth table66%2/3
A and not(B)
A= defined $opts{"prefix"}B= not $opts{"prefix"} =~ /^[a-zA-Z0-9]+$/
ABresult
0X0
100
111
192 0 $self->{perror} = 1;
193 0 $self->{error} = 6;
194 $self->{errorString}
195 0 = '"' . $opts{prefix} . '" is not a valid prefix as it does not match the regex /^[a-zA-Z0-9]+$/';
196 0 $self->warn;
197 } elsif ( defined( $opts{prefix} ) ) {
198 2 $self->{prefix} = $opts{prefix};
199 }
200  
201 # make sure we have a name and that it is valid
202 4 ▶ if ( !defined( $opts{name} ) ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $opts{'name'}) { } 0 4 4
elsif (not $opts{'name'} =~ /^[a-zA-Z0-9\-]+$/) { } 0 4 4
203 0 $self->{perror} = 1;
204 0 $self->{error} = 7;
205 0 $self->{errorString} = 'name is undef';
206 0 $self->warn;
207 } elsif ( $opts{name} !~ /^[a-zA-Z0-9\-]+$/ ) {
208 0 $self->{perror} = 1;
209 0 $self->{error} = 7;
210 0 $self->{errorString} = 'name set to "' . $opts{name} . '" which does not match the regexp /^[a-zA-Z0-9\-]+$/';
211 0 $self->warn;
212 }
213 4 $self->{name} = $opts{name};
214  
215 # used internally for testing
216 4 ▶ if ( defined( $opts{testing} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opts{"testing"}) 2 2 4
217 2 $self->{testing} = $opts{testing};
218 }
219 4 ▶ if ( defined( $opts{frontend_obj} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opts{"frontend_obj"}) 2 2 4
220 2 $self->{frontend_obj} = $opts{frontend_obj};
221 }
222  
223 4 ▶ if ( defined( $opts{options} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opts{"options"}) 3 1 4
224 3 ▶ if ( ref( $opts{options} ) ne 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $opts{"options"} ne "HASH") 0 3 3
225 0 $self->{perror} = 1;
226 0 $self->{error} = 8;
227 0 $self->{errorString} = 'ref for options is "' . ref( $opts{options} ) . '" and not HASH';
228 0 $self->warn;
229 }
230 3 $self->{options} = $opts{options};
231 }
232  
233 # needs a token, or a email + key for legacy auth
234 4 ▶ if ( !defined( $self->{options}{token} )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"options"}{"token"} or defined $self->{"options"}{"email"} and defined $self->{"options"}{"key"}) 1 3 4
Condition83%5/6
defined $self->{"options"}{"token"} or defined $self->{"options"}{"email"} and defined $self->{"options"}{"key"}
l!l&&r!l&&!r
211
defined $self->{"options"}{"email"} and defined $self->{"options"}{"key"}
!ll&&!rl&&r
101
MC/DC66%2/3
defined $self->{"options"}{"token"} or defined $self->{"options"}{"email"} and defined $self->{"options"}{"key"}
defined $self->{"options"}{"token"} defined $self->{"options"}{"email"} defined $self->{"options"}{"key"}
Truth table75%3/4
A or B and C
A= defined $self->{"options"}{"token"}B= defined $self->{"options"}{"email"}C= defined $self->{"options"}{"key"}
ABCresult
1XX1
0111
00X0
0100
235 && ( !defined( $self->{options}{email} ) || !defined( $self->{options}{key} ) ) )
236 {
237 1 $self->{perror} = 1;
238 1 $self->{error} = 28;
239 $self->{errorString}
240 1 = 'either the option token, or both the options email and key, must be specified for auth';
241 1 $self->warn;
242 }
243  
244 3 ▶ if ( defined( $self->{options}{zone} ) && $self->{options}{zone} !~ /^[a-fA-F0-9]+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"options"}{"zone"} and not $self->{"options"}{"zone"} =~ /^[a-fA-F0-9]+$/) 0 3 3
Condition66%2/3
defined $self->{"options"}{"zone"} and not $self->{"options"}{"zone"} =~ /^[a-fA-F0-9]+$/
!ll&&!rl&&r
210
MC/DC0%0/2
defined $self->{"options"}{"zone"} and not $self->{"options"}{"zone"} =~ /^[a-fA-F0-9]+$/
defined $self->{"options"}{"zone"} not $self->{"options"}{"zone"} =~ /^[a-fA-F0-9]+$/
Truth table66%2/3
A and not(B)
A= defined $self->{"options"}{"zone"}B= not $self->{"options"}{"zone"} =~ /^[a-fA-F0-9]+$/
ABresult
0X0
100
111
245 0 $self->{perror} = 1;
246 0 $self->{error} = 28;
247 0 $self->{errorString} = 'the option zone, "' . $self->{options}{zone} . '", does not look like a zone ID';
248 0 $self->warn;
249 }
250  
251 3 ▶ if ( defined( $self->{options}{mode} )
Branch: 2 branches
BranchTrueFalseTotal
if (defined $self->{'options'}{'mode'} and $self->{'options'}{'mode'} ne 'block' and $self->{'options'}{'mode'} ne 'challenge' and $self->{'options'}{'mode'} ne 'js_challenge' and $self->{'options'}{'mode'} ne 'managed_challenge') { } 1 2 3
elsif (not defined $self->{'options'}{'mode'}) { } 1 1 2
Condition75%9/12
defined $self->{"options"}{"mode"} and $self->{"options"}{"mode"} ne "block" and $self->{"options"}{"mode"} ne "challenge" and $self->{"options"}{"mode"} ne "js_challenge" and $self->{"options"}{"mode"} ne "managed_challenge"
!ll&&!rl&&r
201
defined $self->{"options"}{"mode"} and $self->{"options"}{"mode"} ne "block" and $self->{"options"}{"mode"} ne "challenge" and $self->{"options"}{"mode"} ne "js_challenge"
!ll&&!rl&&r
201
defined $self->{"options"}{"mode"} and $self->{"options"}{"mode"} ne "block" and $self->{"options"}{"mode"} ne "challenge"
!ll&&!rl&&r
111
defined $self->{"options"}{"mode"} and $self->{"options"}{"mode"} ne "block"
!ll&&!rl&&r
102
MC/DC40%2/5
defined $self->{"options"}{"mode"} and $self->{"options"}{"mode"} ne "block" and $self->{"options"}{"mode"} ne "challenge" and $self->{"options"}{"mode"} ne "js_challenge" and $self->{"options"}{"mode"} ne "managed_challenge"
defined $self->{"options"}{"mode"} $self->{"options"}{"mode"} ne "block" $self->{"options"}{"mode"} ne "challenge" $self->{"options"}{"mode"} ne "js_challenge" $self->{"options"}{"mode"} ne "managed_challenge"
Truth table50%3/6
A and B and C and D and E
A= defined $self->{"options"}{"mode"}B= $self->{"options"}{"mode"} ne "block"C= $self->{"options"}{"mode"} ne "challenge"D= $self->{"options"}{"mode"} ne "js_challenge"E= $self->{"options"}{"mode"} ne "managed_challenge"
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
252 && $self->{options}{mode} ne 'block'
253 && $self->{options}{mode} ne 'challenge'
254 && $self->{options}{mode} ne 'js_challenge'
255 && $self->{options}{mode} ne 'managed_challenge' )
256 {
257 1 $self->{perror} = 1;
258 1 $self->{error} = 20;
259 $self->{errorString}
260 = '$opts{options}{mode} is "'
261 . $self->{options}{mode}
262 1 . '" and not "block", "challenge", "js_challenge", or "managed_challenge"';
263 1 $self->warn;
264 } elsif ( !defined( $self->{options}{mode} ) ) {
265 1 $self->{options}{mode} = 'block';
266 }
267  
268 2 ▶ if ( !defined( $self->{options}{notes} ) && defined( $self->{name} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{"options"}{"notes"} and defined $self->{"name"}) 2 0 2
Condition33%1/3
not defined $self->{"options"}{"notes"} and defined $self->{"name"}
!ll&&!rl&&r
002
MC/DC0%0/2
not defined $self->{"options"}{"notes"} and defined $self->{"name"}
not defined $self->{"options"}{"notes"} defined $self->{"name"}
Truth table33%1/3
not(A) and B
A= not defined $self->{"options"}{"notes"}B= defined $self->{"name"}
ABresult
0X0
100
111
269 2 $self->{options}{notes} = $self->{prefix} . '_' . $self->{name};
270 }
271  
272 2 ▶ if ( !defined( $self->{options}{timeout} ) ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $self->{'options'}{'timeout'}) { } 2 0 2
elsif (not $self->{'options'}{'timeout'} =~ /^[0-9]+$/) { } 0 0 0
273 2 $self->{options}{timeout} = 30;
274 } elsif ( $self->{options}{timeout} !~ /^[0-9]+$/ ) {
275 0 $self->{perror} = 1;
276 0 $self->{error} = 28;
277 0 $self->{errorString} = 'the option timeout, "' . $self->{options}{timeout} . '", is not an int';
278 0 $self->warn;
279 }
280  
281 2 return $self;
282 } ## end sub new
283  
284 # Internal helper. Returns the access rules endpoint this instance operates
285 # on, which is either zone scoped or account wide depending on configuration.
286 #
287 # Cloudflare exposes the same access rules API at two levels. A zone level
288 # rule applies only to that one zone, while a user level rule applies across
289 # every zone on the account. Which one an instance uses is decided entirely by
290 # whether the zone option was set, and it changes the blast radius of every
291 # ban, so it is worth being deliberate about.
292 #
293 # Note the test is on the option being defined rather than being non empty, so
294 # a zone explicitly set to the empty string would still take the zone branch
295 # and produce a malformed URL.
296 #
297 # Takes no arguments.
298 #
299 # Returns the endpoint as a string, with no trailing slash. Every other URL in
300 # this backend is built on it.
301 #
302 # # with the zone option set
303 # $self->_endpoint;
304 # # https://api.cloudflare.com/client/v4/zones/<zone>/firewall/access_rules/rules
305 #
306 # # with no zone, so account wide
307 # $self->_endpoint;
308 # # https://api.cloudflare.com/client/v4/user/firewall/access_rules/rules
309 24 ▶sub _endpoint {
Subroutine _endpoint: called CC=2 SCAR=6.9
310 24 my ($self) = @_;
311  
312 24 ▶ if ( defined( $self->{options}{zone} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"options"}{"zone"}) 21 3 24
313 21 return 'https://api.cloudflare.com/client/v4/zones/' . $self->{options}{zone} . '/firewall/access_rules/rules';
314 }
315 3 return 'https://api.cloudflare.com/client/v4/user/firewall/access_rules/rules';
316 }
317  
318 # Internal helper. Performs one HTTP request against the Cloudflare API. Every
319 # call this backend makes goes through here.
320 #
321 # Like the panos backend and unlike the other JSON ones, this cannot trust the
322 # HTTP status alone. Cloudflare reports application level problems in a
323 # success key inside the response body, so a rejected token or a malformed
324 # rule can arrive as an HTTP 200 whose body says it failed. Both are therefore
325 # checked, and either being bad is an error; without the body check a ban
326 # could report success while blocking nothing.
327 #
328 # The user agent is built on first use and cached on the object, so a run of
329 # requests shares one agent. LWP::UserAgent is loaded with require at that
330 # point rather than at compile time, since only the HTTP backends need it;
331 # failing to load it dies with an explanation naming this backend.
332 #
333 # Any failure, HTTP level or API level, dies rather than setting an error. The
334 # callers wrap this in eval and turn the exception into the appropriate error
335 # code, which is what lets one helper serve paths that report ban, unban, and
336 # teardown failures differently.
337 #
338 # Never called in testing mode; those paths record the request instead.
339 #
340 # Args:
341 #
342 # method - The HTTP method, as a plain string: 'GET' for the rule
343 # lookups, 'POST' to create a rule, 'DELETE' to remove one.
344 #
345 # url - The full URL to request, as a plain string, built on
346 # _endpoint.
347 #
348 # body - Optional request body, as an already encoded JSON string. undef
349 # for the lookups and deletes, which carry everything in the URL.
350 #
351 # Returns the decoded response body as a hashref. The interesting parts are
352 # the result key, which holds the rule or an array of them, and the success
353 # key that was already checked. Dies on any failure.
354 #
355 # my $decoded = $self->_request( 'GET', $self->_unban_lookup_url($ip) );
356 # my $id = $decoded->{result}[0]{id};
357 #
358 # # the usual shape at the call sites
359 # eval { $self->_request( 'POST', $self->_endpoint, $body ); };
360 # if ($@) { ... raise banFailed ... }
361 0 ▶sub _request {
Subroutine _request: not called CC=11 SCAR=48.8
362 0 my ( $self, $method, $url, $body ) = @_;
363  
364 0 ▶ if ( !defined( $self->{ua} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"ua"}) 0 0 0
365 0 local $@;
366 0 ▶ eval {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { require LWP::UserAgent; $self->{"ua"} = "LWP::UserAgent"->new("agent", 'Net::Firewall::BlockerHelper/' . $Net::Firewall::BlockerHelper::backends::cloudflare::VERSION, "timeout", $self->{"options"}{"timeout"}); 1 } } or die 'failed to load LWP::UserAgent, which the cloudflare backend requires... ' . $@ 0 0 0
367 0 require LWP::UserAgent;
368 $self->{ua} = LWP::UserAgent->new(
369 agent => 'Net::Firewall::BlockerHelper/' . $VERSION,
370 timeout => $self->{options}{timeout},
371 0 );
372 0 1;
373 } or die( 'failed to load LWP::UserAgent, which the cloudflare backend requires... ' . $@ );
374 }
375  
376 0 my @headers = ( 'Content-Type' => 'application/json' );
377 0 ▶ if ( defined( $self->{options}{token} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'options'}{'token'}) { } 0 0 0
378 0 push( @headers, 'Authorization' => 'Bearer ' . $self->{options}{token} );
379 } else {
380 0 push( @headers, 'X-Auth-Email' => $self->{options}{email}, 'X-Auth-Key' => $self->{options}{key} );
381 }
382  
383 0 require HTTP::Request;
384 0 my $request = HTTP::Request->new( $method, $url, \@headers, $body );
385  
386 0 my $response = $self->{ua}->request($request);
387  
388 0 my $decoded;
389 0 local $@;
390 0 eval { $decoded = $self->_json->decode( $response->decoded_content ); };
391  
392 0 ▶ if ( !$response->is_success || !defined($decoded) || !$decoded->{success} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($response->is_success and defined $decoded and $decoded->{"success"}) 0 0 0
Condition0%0/6
$response->is_success and defined $decoded and $decoded->{"success"}
!ll&&!rl&&r
000
$response->is_success and defined $decoded
!ll&&!rl&&r
000
MC/DC0%0/3
$response->is_success and defined $decoded and $decoded->{"success"}
$response->is_success defined $decoded $decoded->{"success"}
Truth table0%0/4
A and B and C
A= $response->is_successB= defined $decodedC= $decoded->{"success"}
ABCresult
0XX0
10X0
1100
1111
393 0 my $api_errors = '';
394 0 ▶ if ( defined($decoded) && ref( $decoded->{errors} ) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $decoded and ref $decoded->{"errors"} eq "ARRAY") 0 0 0
Condition0%0/3
defined $decoded and ref $decoded->{"errors"} eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $decoded and ref $decoded->{"errors"} eq "ARRAY"
defined $decoded ref $decoded->{"errors"} eq "ARRAY"
Truth table0%0/3
A and B
A= defined $decodedB= ref $decoded->{"errors"} eq "ARRAY"
ABresult
0X0
100
111
395 $api_errors = ' API errors... ' . join(
396 ', ',
397 map {
398 ( defined( $_->{code} ) ? $_->{code} : '?' ) . ': '
399 0 ▶ . ( defined( $_->{message} ) ? $_->{message} : '?' )
Branch: 2 branches
BranchTrueFalseTotal
defined $_->{'code'} ? : 0 0 0
defined $_->{'message'} ? : 0 0 0
400 0 } @{ $decoded->{errors} }
401 );
402 }
403 0 die( $method . ' '
404 . $url
405 . ' failed... HTTP status... '
406 . $response->status_line
407 . $api_errors );
408 } ## end if ( !$response->is_success || !defined($decoded...))
409  
410 0 return $decoded;
411 } ## end sub _request
412  
413 =head2 init
414  
415 Initiates the backend. Verifies the credentials and endpoint by listing a
416 few rules.
417  
418 $backend->init;
419  
420 =cut
421  
422 3 ▶sub init {
Subroutine init: called CC=4 SCAR=20.3
Pod documented
423 3 my ( $self, %opts ) = @_;
424  
425 3 $self->errorblank;
426  
427 3 ▶ if ( $self->{inited} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"inited"}) 0 3 3
428 0 $self->{error} = 18;
429 0 $self->{errorString} = 'backend has already been inited';
430 0 $self->warn;
431 }
432  
433 3 my $url = $self->_endpoint . '?per_page=5';
434  
435 3 ▶ if ( $self->{testing} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'testing'}) { } 3 0 3
436 3 $self->{frontend_obj}->{test_data} = { requests => [ { method => 'GET', url => $url } ] };
437 } else {
438 0 local $@;
439 0 ▶ eval { $self->_request( 'GET', $url ); 1; } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $self->_request("GET", $url); 1 } } or do { $self->{"error"} = 23; $self->{"errorString"} = 'init failed. probing the access rules endpoint failed... ' . $@; $self->warn } 0 0 0
440 0 $self->{error} = 23;
441 0 $self->{errorString} = 'init failed. probing the access rules endpoint failed... ' . $@;
442 0 $self->warn;
443 };
444 }
445  
446 3 $self->{inited} = 1;
447 } ## end sub init
448  
449 =head2 ban
450  
451 Bans an IP. The value of ban is validated as being a IPv4 or IPv6 address
452 and lowercased, then an access rule is created for it via a POST to the
453 access rules endpoint, using the configured mode and notes. Banning an
454 already banned IP is a noop.
455  
456 $backend->ban(ban => $ip);
457  
458 =cut
459  
460 4 ▶sub ban {
Subroutine ban: called CC=11 SCAR=34.7
Pod documented
461 4 my ( $self, %opts ) = @_;
462  
463 4 $self->errorblank;
464  
465 4 ▶ if ( !$self->{inited} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"inited"}) 0 4 4
466 0 $self->{error} = 1;
467 0 $self->{errorString} = 'backend has not been inited';
468 0 $self->warn;
469 0 return;
470 }
471  
472 4 ▶ if ( !defined( $opts{ban} ) ) {
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $opts{'ban'}) { } 0 4 4
elsif (ref $opts{'ban'} ne '') { } 0 4 4
elsif (not $opts{'ban'} =~ /\A$Net::Firewall::BlockerHelper::backends::cloudflare::IPv4_re\z/ || $opts{'ban'} =~ /\A$Net::Firewall::BlockerHelper::backends::cloudflare::IPv6_re\z/) { } 0 4 4
473 0 $self->{error} = 9;
474 0 $self->{errorString} = 'Nothing specified for the value ban';
475 0 $self->warn;
476 0 return;
477 } elsif ( ref( $opts{ban} ) ne '' ) {
478 0 $self->{error} = 10;
479 0 $self->{errorString} = 'Bad ref type for ban... ref is "' . ref( $opts{ban} ) . '"';
480 0 $self->warn;
481 0 return;
482 ▶ } elsif ( $opts{ban} !~ /\A$IPv4_re\z/
Condition66%2/3
$opts{'ban'} =~ /\A$Net::Firewall::BlockerHelper::backends::cloudflare::IPv4_re\z/ || $opts{'ban'} =~ /\A$Net::Firewall::BlockerHelper::backends::cloudflare::IPv6_re\z/
l!l&&r!l&&!r
310
MC/DC0%0/2
$opts{'ban'} =~ /\A$Net::Firewall::BlockerHelper::backends::cloudflare::IPv4_re\z/ || $opts{'ban'} =~ /\A$Net::Firewall::BlockerHelper::backends::cloudflare::IPv6_re\z/
$opts{'ban'} =~ /\A$Net::Firewall::BlockerHelper::backends::cloudflare::IPv4_re\z/ $opts{'ban'} =~ /\A$Net::Firewall::BlockerHelper::backends::cloudflare::IPv6_re\z/
Truth table66%2/3
A || B
A= $opts{'ban'} =~ /\A$Net::Firewall::BlockerHelper::backends::cloudflare::IPv4_re\z/B= $opts{'ban'} =~ /\A$Net::Firewall::BlockerHelper::backends::cloudflare::IPv6_re\z/
ABresult
1X1
011
000
483 && $opts{ban} !~ /\A$IPv6_re\z/ )
484 {
485 0 $self->{error} = 10;
486 0 $self->{errorString} = 'ban item,"' . $opts{ban} . '", does not appear to be a IPv4 or IPv6 IP';
487 0 $self->warn;
488 0 return;
489 }
490  
491 # lowercase so the same IPv6 IP in differing cases can't result in duplicate entries
492 4 $opts{ban} = lc( $opts{ban} );
493  
494 4 ▶ if ( $self->{banned}{ $opts{ban} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"banned"}{$opts{"ban"}}) 1 3 4
495 1 ▶ if ( $self->{testing} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"testing"}) 1 0 1
496 1 $self->{frontend_obj}->{test_data} = 'already banned';
497 }
498 1 return;
499 }
500  
501 3 ▶ my $target = ( $opts{ban} =~ /\A$IPv4_re\z/ ) ? 'ip' : 'ip6';
Branch: 1 branch
BranchTrueFalseTotal
$opts{'ban'} =~ /\A$Net::Firewall::BlockerHelper::backends::cloudflare::IPv4_re\z/ ? : 2 1 3
502 my $body = $self->_json->encode(
503 {
504 mode => $self->{options}{mode},
505 configuration => { target => $target, value => $opts{ban} },
506 notes => $self->{options}{notes},
507 }
508 3 );
509  
510 3 ▶ if ( $self->{testing} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'testing'}) { } 3 0 3
511 3 $self->{frontend_obj}->{test_data} = [ { method => 'POST', url => $self->_endpoint, content => $body } ];
512 } else {
513 0 local $@;
514 0 ▶ eval { $self->_request( 'POST', $self->_endpoint, $body ); 1; } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $self->_request("POST", $self->_endpoint, $body); 1 } } or do { $self->{"error"} = 13; $self->{"errorString"} = 'banning "' . $opts{"ban"} . '" failed... ' . $@; $self->warn; return } 0 0 0
515 0 $self->{error} = 13;
516 0 $self->{errorString} = 'banning "' . $opts{ban} . '" failed... ' . $@;
517 0 $self->warn;
518 0 return;
519 };
520 }
521  
522 3 $self->{banned}{ $opts{ban} } = 1;
523 } ## end sub ban
524  
525 # Internal helper. Returns the URL that finds the access rule for one address.
526 #
527 # This exists because Cloudflare rules are addressed by an opaque id rather
528 # than by their contents. There is no way to delete "the rule for 10.0.0.1";
529 # the id has to be looked up first and then deleted, which is why unbanning
530 # takes two round trips while banning takes one.
531 #
532 # The query filters on four things, not just the address: the mode and notes
533 # as well as the target and value. Matching on the configured notes is what
534 # keeps an instance from deleting a rule some other tool or another instance
535 # created for the same address, since the notes are what identify a rule as
536 # this instance's.
537 #
538 # The target is the family, spelled 'ip' or 'ip6', which Cloudflare requires
539 # alongside the value.
540 #
541 # Args:
542 #
543 # ip - The address whose rule is wanted, as a plain string. Expected to be
544 # an already validated and lowercased IPv4 or IPv6 address. The
545 # family is decided by matching against $IPv4_re.
546 #
547 # Returns the URL as a string, for a GET whose result key holds an array of
548 # matching rules.
549 #
550 # $self->_unban_lookup_url('10.0.0.1');
551 # # <endpoint>?mode=block&notes=<notes>&configuration.target=ip&configuration.value=10.0.0.1
552 #
553 # $self->_unban_lookup_url('2001:db8::1');
554 # # <endpoint>?mode=block&notes=<notes>&configuration.target=ip6&configuration.value=2001%3Adb8%3A%3A1
555 3 ▶sub _unban_lookup_url {
Subroutine _unban_lookup_url: called CC=2 SCAR=6.9
556 3 my ( $self, $ip ) = @_;
557  
558 3 ▶ my $target = ( $ip =~ /\A$IPv4_re\z/ ) ? 'ip' : 'ip6';
Branch: 1 branch
BranchTrueFalseTotal
$ip =~ /\A$Net::Firewall::BlockerHelper::backends::cloudflare::IPv4_re\z/ ? : 1 2 3
559  
560 return
561 $self->_endpoint
562 . '?mode='
563 . $self->{options}{mode}
564 . '&notes='
565 . $self->_uri_escape( $self->{options}{notes} )
566 3 . '&configuration.target='
567 . $target
568 . '&configuration.value='
569 . $self->_uri_escape($ip);
570 } ## end sub _unban_lookup_url
571  
572 # Internal helper. Performs the full two step unban of one address: find its
573 # access rule, then delete it by id.
574 #
575 # The two steps are wrapped together because neither is useful alone and the
576 # id from the first is the only way to address the second.
577 #
578 # A lookup that matches nothing is treated as success rather than as an error.
579 # The rule having already gone, whether removed through the dashboard or by
580 # another process, means the address is not banned, which is exactly what the
581 # caller wanted. Erroring there would make an unban fail for having already
582 # achieved its goal.
583 #
584 # Only the first match is acted on. Given the notes and value filter there
585 # should not be more than one, and any extra would be picked up by a later
586 # unban rather than being silently wrong.
587 #
588 # Never called in testing mode; that path records the request instead.
589 #
590 # Args:
591 #
592 # ip - The address to unban, as a plain string. Expected to be an already
593 # validated and lowercased IPv4 or IPv6 address, spelled the same way
594 # it was when banned.
595 #
596 # Returns nothing. Dies if either request fails, which the caller catches and
597 # turns into unbanFailed.
598 #
599 # $self->_unban_ip('10.0.0.1');
600 #
601 # # the usual shape at the call site
602 # eval { $self->_unban_ip( $opts{ban} ); };
603 # if ($@) { ... raise unbanFailed ... }
604 0 ▶sub _unban_ip {
Subroutine _unban_ip: not called CC=4 SCAR=30.0
605 0 my ( $self, $ip ) = @_;
606  
607 0 my $decoded = $self->_request( 'GET', $self->_unban_lookup_url($ip) );
608  
609 0 my $id;
610 0 ▶ if ( ref( $decoded->{result} ) eq 'ARRAY' && defined( $decoded->{result}[0] ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $decoded->{"result"} eq "ARRAY" and defined $decoded->{"result"}[0]) 0 0 0
Condition0%0/3
ref $decoded->{"result"} eq "ARRAY" and defined $decoded->{"result"}[0]
!ll&&!rl&&r
000
MC/DC0%0/2
ref $decoded->{"result"} eq "ARRAY" and defined $decoded->{"result"}[0]
ref $decoded->{"result"} eq "ARRAY" defined $decoded->{"result"}[0]
Truth table0%0/3
A and B
A= ref $decoded->{"result"} eq "ARRAY"B= defined $decoded->{"result"}[0]
ABresult
0X0
100
111
611 0 $id = $decoded->{result}[0]{id};
612 }
613  
614 # no rule found means something else removed it already, which is fine
615 0 ▶ if ( !defined($id) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $id) 0 0 0
616 0 return;
617 }
618  
619 0 $self->_request( 'DELETE', $self->_endpoint . '/' . $id );
620  
621 0 return;
622 } ## end sub _unban_ip
623  
624 =head2 unban
625  
626 Unbans an IP. The value of ban is validated as being a IPv4 or IPv6 address
627 and lowercased. The matching access rule is then found via a GET filtering
628 on mode, notes, and the IP, and deleted by its ID. A rule that can not be
629 found is treated as already unbanned. Unbanning an IP that is not banned is
630 a noop.
631  
632 $backend->unban(ban => $ip);
633  
634 =cut
635  
636 1 ▶sub unban {
Subroutine unban: called CC=10 SCAR=38.2
Pod documented
637 1 my ( $self, %opts ) = @_;
638  
639 1 $self->errorblank;
640  
641 1 ▶ if ( !$self->{inited} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"inited"}) 0 1 1
642 0 $self->{error} = 1;
643 0 $self->{errorString} = 'backend has not been inited';
644 0 $self->warn;
645 0 return;
646 }
647  
648 1 ▶ if ( !defined( $opts{ban} ) ) {
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $opts{'ban'}) { } 0 1 1
elsif (ref $opts{'ban'} ne '') { } 0 1 1
elsif (not $opts{'ban'} =~ /\A$Net::Firewall::BlockerHelper::backends::cloudflare::IPv4_re\z/ || $opts{'ban'} =~ /\A$Net::Firewall::BlockerHelper::backends::cloudflare::IPv6_re\z/) { } 0 1 1
649 0 $self->{error} = 9;
650 0 $self->{errorString} = 'Nothing specified for the value ban';
651 0 $self->warn;
652 0 return;
653 } elsif ( ref( $opts{ban} ) ne '' ) {
654 0 $self->{error} = 10;
655 0 $self->{errorString} = 'Bad ref type for ban... ref is "' . ref( $opts{ban} ) . '"';
656 0 $self->warn;
657 0 return;
658 ▶ } elsif ( $opts{ban} !~ /\A$IPv4_re\z/
Condition33%1/3
$opts{'ban'} =~ /\A$Net::Firewall::BlockerHelper::backends::cloudflare::IPv4_re\z/ || $opts{'ban'} =~ /\A$Net::Firewall::BlockerHelper::backends::cloudflare::IPv6_re\z/
l!l&&r!l&&!r
100
MC/DC0%0/2
$opts{'ban'} =~ /\A$Net::Firewall::BlockerHelper::backends::cloudflare::IPv4_re\z/ || $opts{'ban'} =~ /\A$Net::Firewall::BlockerHelper::backends::cloudflare::IPv6_re\z/
$opts{'ban'} =~ /\A$Net::Firewall::BlockerHelper::backends::cloudflare::IPv4_re\z/ $opts{'ban'} =~ /\A$Net::Firewall::BlockerHelper::backends::cloudflare::IPv6_re\z/
Truth table33%1/3
A || B
A= $opts{'ban'} =~ /\A$Net::Firewall::BlockerHelper::backends::cloudflare::IPv4_re\z/B= $opts{'ban'} =~ /\A$Net::Firewall::BlockerHelper::backends::cloudflare::IPv6_re\z/
ABresult
1X1
011
000
659 && $opts{ban} !~ /\A$IPv6_re\z/ )
660 {
661 0 $self->{error} = 10;
662 0 $self->{errorString} = 'ban item,"' . $opts{ban} . '", does not appear to be a IPv4 or IPv6 IP';
663 0 $self->warn;
664 0 return;
665 }
666  
667 # lowercase so the same IPv6 IP in differing cases can't result in duplicate entries
668 1 $opts{ban} = lc( $opts{ban} );
669  
670 1 ▶ if ( !$self->{banned}{ $opts{ban} } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"banned"}{$opts{"ban"}}) 0 1 1
671 0 ▶ if ( $self->{testing} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"testing"}) 0 0 0
672 0 $self->{frontend_obj}->{test_data} = 'not banned';
673 }
674 0 return;
675 }
676  
677 1 ▶ if ( $self->{testing} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'testing'}) { } 1 0 1
678 $self->{frontend_obj}->{test_data} = [
679 1 { method => 'GET', url => $self->_unban_lookup_url( $opts{ban} ) },
680 { method => 'DELETE', url => $self->_endpoint . '/<id>' },
681 ];
682 } else {
683 0 local $@;
684 0 ▶ eval { $self->_unban_ip( $opts{ban} ); 1; } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $self->_unban_ip($opts{"ban"}); 1 } } or do { $self->{"error"} = 14; $self->{"errorString"} = 'unbanning "' . $opts{"ban"} . '" failed... ' . $@; $self->warn; return } 0 0 0
685 0 $self->{error} = 14;
686 0 $self->{errorString} = 'unbanning "' . $opts{ban} . '" failed... ' . $@;
687 0 $self->warn;
688 0 return;
689 };
690 }
691  
692 1 delete( $self->{banned}{ $opts{ban} } );
693 } ## end sub unban
694  
695 =head2 ban_cidr
696  
697 Bans a CIDR range by creating an access rule for it. Cloudflare access rules
698 accept a network prefix as the configuration value in the same manner as a
699 single address. The value of ban is validated as being a IPv4 or IPv6 CIDR
700 range and lowercased. Banning an already banned range is a noop.
701  
702 $backend->ban_cidr(ban => '1.2.3.0/24');
703  
704 =cut
705  
706 1 ▶sub ban_cidr {
Subroutine ban_cidr: called CC=10 SCAR=37.2
Pod documented
707 1 my ( $self, %opts ) = @_;
708  
709 1 $self->errorblank;
710  
711 1 ▶ if ( !$self->{inited} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"inited"}) 0 1 1
712 0 $self->{error} = 1;
713 0 $self->{errorString} = 'backend has not been inited';
714 0 $self->warn;
715 0 return;
716 }
717  
718 1 ▶ if ( !defined( $opts{ban} ) ) {
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $opts{'ban'}) { } 0 1 1
elsif (ref $opts{'ban'} ne '') { } 0 1 1
elsif (not $self->_valid_cidr($opts{'ban'})) { } 0 1 1
719 0 $self->{error} = 9;
720 0 $self->{errorString} = 'Nothing specified for the value ban';
721 0 $self->warn;
722 0 return;
723 } elsif ( ref( $opts{ban} ) ne '' ) {
724 0 $self->{error} = 31;
725 0 $self->{errorString} = 'Bad ref type for ban... ref is "' . ref( $opts{ban} ) . '"';
726 0 $self->warn;
727 0 return;
728 } elsif ( !$self->_valid_cidr( $opts{ban} ) ) {
729 0 $self->{error} = 31;
730 0 $self->{errorString} = 'ban item,"' . $opts{ban} . '", does not appear to be a IPv4 or IPv6 CIDR';
731 0 $self->warn;
732 0 return;
733 }
734  
735 # lowercase so the same IPv6 CIDR in differing cases can't result in duplicate entries
736 1 $opts{ban} = lc( $opts{ban} );
737  
738 1 ▶ if ( $self->{banned_cidr}{ $opts{ban} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"banned_cidr"}{$opts{"ban"}}) 0 1 1
739 0 ▶ if ( $self->{testing} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"testing"}) 0 0 0
740 0 $self->{frontend_obj}->{test_data} = 'already banned';
741 }
742 0 return;
743 }
744  
745 # the address portion of the CIDR determines the family, and thus the target
746 1 ▶ my $target = ( $opts{ban} =~ m!\A$IPv4_re/! ) ? 'ip' : 'ip6';
Branch: 1 branch
BranchTrueFalseTotal
$opts{'ban'} =~ m[\A$Net::Firewall::BlockerHelper::backends::cloudflare::IPv4_re/] ? : 1 0 1
747 my $body = $self->_json->encode(
748 {
749 mode => $self->{options}{mode},
750 configuration => { target => $target, value => $opts{ban} },
751 notes => $self->{options}{notes},
752 }
753 1 );
754  
755 1 ▶ if ( $self->{testing} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'testing'}) { } 1 0 1
756 1 $self->{frontend_obj}->{test_data} = [ { method => 'POST', url => $self->_endpoint, content => $body } ];
757 } else {
758 0 local $@;
759 0 ▶ eval { $self->_request( 'POST', $self->_endpoint, $body ); 1; } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $self->_request("POST", $self->_endpoint, $body); 1 } } or do { $self->{"error"} = 29; $self->{"errorString"} = 'banning "' . $opts{"ban"} . '" failed... ' . $@; $self->warn; return } 0 0 0
760 0 $self->{error} = 29;
761 0 $self->{errorString} = 'banning "' . $opts{ban} . '" failed... ' . $@;
762 0 $self->warn;
763 0 return;
764 };
765 }
766  
767 1 $self->{banned_cidr}{ $opts{ban} } = 1;
768 } ## end sub ban_cidr
769  
770 # Internal helper. Returns the URL that finds the access rule for one CIDR
771 # range, the range counterpart of _unban_lookup_url.
772 #
773 # The query is built the same way and filters on the same four things. The one
774 # difference is how the family is decided: the match is anchored against
775 # $IPv4_re followed by a literal slash, rather than against the whole string,
776 # because a range never matches the plain anchored address pattern.
777 #
778 # The range goes into the value as it stands, since that is what Cloudflare
779 # stored when it was banned.
780 #
781 # Args:
782 #
783 # cidr - The range whose rule is wanted, as a plain string. Expected to be
784 # an already validated and lowercased CIDR range such as
785 # "10.0.0.0/8" or "2001:db8::/32".
786 #
787 # Returns the URL as a string, for a GET whose result key holds an array of
788 # matching rules.
789 #
790 # $self->_unban_cidr_lookup_url('10.0.0.0/8');
791 # # <endpoint>?mode=block&notes=<notes>&configuration.target=ip&configuration.value=10.0.0.0%2F8
792 1 ▶sub _unban_cidr_lookup_url {
Subroutine _unban_cidr_lookup_url: called CC=2 SCAR=7.1
793 1 my ( $self, $cidr ) = @_;
794  
795 1 ▶ my $target = ( $cidr =~ m!\A$IPv4_re/! ) ? 'ip' : 'ip6';
Branch: 1 branch
BranchTrueFalseTotal
$cidr =~ m[\A$Net::Firewall::BlockerHelper::backends::cloudflare::IPv4_re/] ? : 1 0 1
796  
797 return
798 $self->_endpoint
799 . '?mode='
800 . $self->{options}{mode}
801 . '&notes='
802 . $self->_uri_escape( $self->{options}{notes} )
803 1 . '&configuration.target='
804 . $target
805 . '&configuration.value='
806 . $self->_uri_escape($cidr);
807 } ## end sub _unban_cidr_lookup_url
808  
809 =head2 unban_cidr
810  
811 Unbans a CIDR range by finding and deleting its access rule, the same way
812 L</unban> does for a single IP. A rule that can not be found is treated as
813 already unbanned. Unbanning a range that is not banned is a noop.
814  
815 $backend->unban_cidr(ban => '1.2.3.0/24');
816  
817 =cut
818  
819 1 ▶sub unban_cidr {
Subroutine unban_cidr: called CC=12 SCAR=43.4
Pod documented
820 1 my ( $self, %opts ) = @_;
821  
822 1 $self->errorblank;
823  
824 1 ▶ if ( !$self->{inited} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"inited"}) 0 1 1
825 0 $self->{error} = 1;
826 0 $self->{errorString} = 'backend has not been inited';
827 0 $self->warn;
828 0 return;
829 }
830  
831 1 ▶ if ( !defined( $opts{ban} ) ) {
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $opts{'ban'}) { } 0 1 1
elsif (ref $opts{'ban'} ne '') { } 0 1 1
elsif (not $self->_valid_cidr($opts{'ban'})) { } 0 1 1
832 0 $self->{error} = 9;
833 0 $self->{errorString} = 'Nothing specified for the value ban';
834 0 $self->warn;
835 0 return;
836 } elsif ( ref( $opts{ban} ) ne '' ) {
837 0 $self->{error} = 31;
838 0 $self->{errorString} = 'Bad ref type for ban... ref is "' . ref( $opts{ban} ) . '"';
839 0 $self->warn;
840 0 return;
841 } elsif ( !$self->_valid_cidr( $opts{ban} ) ) {
842 0 $self->{error} = 31;
843 0 $self->{errorString} = 'ban item,"' . $opts{ban} . '", does not appear to be a IPv4 or IPv6 CIDR';
844 0 $self->warn;
845 0 return;
846 }
847  
848 # lowercase so the same IPv6 CIDR in differing cases can't result in duplicate entries
849 1 $opts{ban} = lc( $opts{ban} );
850  
851 1 ▶ if ( !$self->{banned_cidr}{ $opts{ban} } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"banned_cidr"}{$opts{"ban"}}) 0 1 1
852 0 ▶ if ( $self->{testing} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"testing"}) 0 0 0
853 0 $self->{frontend_obj}->{test_data} = 'not banned';
854 }
855 0 return;
856 }
857  
858 1 ▶ if ( $self->{testing} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'testing'}) { } 1 0 1
859 $self->{frontend_obj}->{test_data} = [
860 1 { method => 'GET', url => $self->_unban_cidr_lookup_url( $opts{ban} ) },
861 { method => 'DELETE', url => $self->_endpoint . '/<id>' },
862 ];
863 } else {
864 0 local $@;
865 eval {
866 0 my $decoded = $self->_request( 'GET', $self->_unban_cidr_lookup_url( $opts{ban} ) );
867  
868 0 my $id;
869 0 ▶ if ( ref( $decoded->{result} ) eq 'ARRAY' && defined( $decoded->{result}[0] ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $decoded->{"result"} eq "ARRAY" and defined $decoded->{"result"}[0]) 0 0 0
Condition0%0/3
ref $decoded->{"result"} eq "ARRAY" and defined $decoded->{"result"}[0]
!ll&&!rl&&r
000
MC/DC0%0/2
ref $decoded->{"result"} eq "ARRAY" and defined $decoded->{"result"}[0]
ref $decoded->{"result"} eq "ARRAY" defined $decoded->{"result"}[0]
Truth table0%0/3
A and B
A= ref $decoded->{"result"} eq "ARRAY"B= defined $decoded->{"result"}[0]
ABresult
0X0
100
111
870 0 $id = $decoded->{result}[0]{id};
871 }
872  
873 # no rule found means something else removed it already, which is fine
874 0 ▶ if ( defined($id) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $id) 0 0 0
875 0 $self->_request( 'DELETE', $self->_endpoint . '/' . $id );
876 }
877 0 1;
878 0 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { my $decoded = $self->_request("GET", $self->_unban_cidr_lookup_url($opts{"ban"})); my $id; if (ref $decoded->{"result"} eq "ARRAY" and defined $decoded->{"result"}[0]) { $id = $decoded->{"result"}[0]{"id"}; } ; if (defined $id) { $self->_request("DELETE", $self->_endpoint . '/' . $id); } ; 1 } } or do { $self->{"error"} = 30; $self->{"errorString"} = 'unbanning "' . $opts{"ban"} . '" failed... ' . $@; $self->warn; return } 0 0 0
879 0 $self->{error} = 30;
880 0 $self->{errorString} = 'unbanning "' . $opts{ban} . '" failed... ' . $@;
881 0 $self->warn;
882 0 return;
883 };
884 } ## end else [ if ( $self->{testing} ) ]
885  
886 1 delete( $self->{banned_cidr}{ $opts{ban} } );
887 } ## end sub unban_cidr
888  
889 =head2 list_cidr
890  
891 List banned CIDR ranges. Returns an array of the currently banned CIDR
892 ranges. Single IPs are not included; for those see L</list>.
893  
894 my @banned_cidrs = $backend->list_cidr;
895  
896 =cut
897  
898 2 ▶sub list_cidr {
Subroutine list_cidr: called CC=2 SCAR=7.0
Pod documented
899 2 my ( $self, %opts ) = @_;
900  
901 2 $self->errorblank;
902  
903 2 ▶ if ( $self->{testing} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"testing"}) 2 0 2
904 2 $self->{frontend_obj}->{test_data} = 'list_cidr';
905 }
906  
907 2 return keys( %{ $self->{banned_cidr} } );
908 }
909  
910 =head2 list
911  
912 List banned IPs. Returns an array of the currently banned single IPs. CIDR
913 ranges are not included; for those see L</list_cidr>.
914  
915 my @banned = $backend->list;
916  
917 =cut
918  
919 1 ▶sub list {
Subroutine list: called CC=2 SCAR=7.0
Pod documented
920 1 my ( $self, %opts ) = @_;
921  
922 1 $self->errorblank;
923  
924 1 ▶ if ( $self->{testing} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"testing"}) 1 0 1
925 1 $self->{frontend_obj}->{test_data} = 'list';
926 }
927  
928 1 return keys( %{ $self->{banned} } );
929 }
930  
931 =head2 re_init
932  
933 Tells the backend to re-init it's self.
934  
935 This will call teardown and init again. After that it will
936 re-added all previously added bans.
937  
938 $backend->re_init;
939  
940 =cut
941  
942 1 ▶sub re_init {
Subroutine re_init: called CC=10 SCAR=32.7
Pod documented
943 1 my ( $self, %opts ) = @_;
944  
945 1 $self->errorblank;
946  
947 # teardown is best effort here as a partially or fully wiped setup is
948 # exactly what re_init needs to recover from; init cleans up any remnants
949 {
950 1 local $@;
951 1 eval { $self->teardown; };
952 }
953 1 $self->init;
954  
955 1 my @to_ban = keys( %{ $self->{banned} } );
956  
957 1 my @re_init_test_data;
958 1 foreach my $item (@to_ban) {
959 1 ▶ my $target = ( $item =~ /\A$IPv4_re\z/ ) ? 'ip' : 'ip6';
Branch: 1 branch
BranchTrueFalseTotal
$item =~ /\A$Net::Firewall::BlockerHelper::backends::cloudflare::IPv4_re\z/ ? : 0 1 1
960 my $body = $self->_json->encode(
961 {
962 mode => $self->{options}{mode},
963 configuration => { target => $target, value => $item },
964 notes => $self->{options}{notes},
965 }
966 1 );
967  
968 1 ▶ if ( $self->{testing} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'testing'}) { } 1 0 1
969 1 push( @re_init_test_data, { method => 'POST', url => $self->_endpoint, content => $body } );
970 } else {
971 0 local $@;
972 0 ▶ eval { $self->_request( 'POST', $self->_endpoint, $body ); 1; } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $self->_request("POST", $self->_endpoint, $body); 1 } } or do { $self->{"error"} = 13; $self->{"errorString"} = 'banning "' . $item . '" failed... ' . $@; $self->warn } 0 0 0
973 0 $self->{error} = 13;
974 0 $self->{errorString} = 'banning "' . $item . '" failed... ' . $@;
975 0 $self->warn;
976 };
977 }
978 } ## end foreach my $item (@to_ban)
979  
980 # CIDR ranges are re-added the same way, the address portion of the CIDR
981 # determining the target
982 1 my @to_ban_cidr = keys( %{ $self->{banned_cidr} } );
983  
984 1 foreach my $item (@to_ban_cidr) {
985 0 ▶ my $target = ( $item =~ m!\A$IPv4_re/! ) ? 'ip' : 'ip6';
Branch: 1 branch
BranchTrueFalseTotal
$item =~ m[\A$Net::Firewall::BlockerHelper::backends::cloudflare::IPv4_re/] ? : 0 0 0
986 my $body = $self->_json->encode(
987 {
988 mode => $self->{options}{mode},
989 configuration => { target => $target, value => $item },
990 notes => $self->{options}{notes},
991 }
992 0 );
993  
994 0 ▶ if ( $self->{testing} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'testing'}) { } 0 0 0
995 0 push( @re_init_test_data, { method => 'POST', url => $self->_endpoint, content => $body } );
996 } else {
997 0 local $@;
998 0 ▶ eval { $self->_request( 'POST', $self->_endpoint, $body ); 1; } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $self->_request("POST", $self->_endpoint, $body); 1 } } or do { $self->{"error"} = 29; $self->{"errorString"} = 'banning "' . $item . '" failed... ' . $@; $self->warn } 0 0 0
999 0 $self->{error} = 29;
1000 0 $self->{errorString} = 'banning "' . $item . '" failed... ' . $@;
1001 0 $self->warn;
1002 };
1003 }
1004 } ## end foreach my $item (@to_ban_cidr)
1005  
1006 1 ▶ if ( $self->{testing} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"testing"}) 1 0 1
1007 1 $self->{frontend_obj}->{test_data} = \@re_init_test_data;
1008 }
1009  
1010 1 $self->{inited} = 1;
1011 } ## end sub re_init
1012  
1013 =head2 teardown
1014  
1015 Tears down the setup for the backend by removing the access rule for each
1016 currently banned IP. The internal list of bans is kept, so a following
1017 re_init will re-add them.
1018  
1019 $backend->teardown;
1020  
1021 =cut
1022  
1023 1 ▶sub teardown {
Subroutine teardown: called CC=5 SCAR=20.5
Pod documented
1024 1 my ( $self, %opts ) = @_;
1025  
1026 1 $self->errorblank;
1027  
1028 1 $self->{inited} = 0;
1029  
1030 1 my @requests;
1031 1 foreach my $item ( sort( keys( %{ $self->{banned} } ) ) ) {
1032 1 ▶ if ( $self->{testing} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'testing'}) { } 1 0 1
1033 1 push(
1034 @requests,
1035 { method => 'GET', url => $self->_unban_lookup_url($item) },
1036 { method => 'DELETE', url => $self->_endpoint . '/<id>' }
1037 );
1038 } else {
1039 0 local $@;
1040 0 ▶ eval { $self->_unban_ip($item); 1; } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $self->_unban_ip($item); 1 } } or do { $self->{"error"} = 17; $self->{"errorString"} = 'teardown failed removing the rule for "' . $item . '"... ' . $@; $self->warn } 0 0 0
1041 0 $self->{error} = 17;
1042 0 $self->{errorString} = 'teardown failed removing the rule for "' . $item . '"... ' . $@;
1043 0 $self->warn;
1044 };
1045 }
1046 } ## end foreach my $item ( sort( keys( %{ $self->{banned...})))
1047  
1048 1 ▶ if ( $self->{testing} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"testing"}) 1 0 1
1049 1 $self->{frontend_obj}->{test_data} = \@requests;
1050 }
1051 } ## end sub teardown
1052  
1053 =head2 stop
1054  
1055 Alias for L</teardown>, provided for parity with the fail2ban C<actionstop>
1056 concept.
1057  
1058 $backend->stop;
1059  
1060 =cut
1061  
1062 0 ▶sub stop {
Subroutine stop: not called CC=1 SCAR=6.9
Pod documented
1063 0 my ( $self, %opts ) = @_;
1064  
1065 0 return $self->teardown(%opts);
1066 }
1067  
1068 =head2 check
1069  
1070 Verifies the endpoint and credentials are still usable by listing a few
1071 rules. Returns a true value if so and a false value otherwise. This is the
1072 equivalent of fail2ban's C<actioncheck>.
1073  
1074 if ( !$backend->check ) {
1075 $backend->re_init;
1076 }
1077  
1078 =cut
1079  
1080 8 ▶sub check {
Subroutine check: called CC=3 SCAR=14.7
Pod documented
1081 8 my ( $self, %opts ) = @_;
1082  
1083 8 $self->errorblank;
1084  
1085 8 my $url = $self->_endpoint . '?per_page=5';
1086  
1087 8 ▶ if ( $self->{testing} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"testing"}) 8 0 8
1088 8 $self->{frontend_obj}->{test_data} = [ { method => 'GET', url => $url } ];
1089 8 return 1;
1090 }
1091  
1092 0 local $@;
1093 0 ▶ eval { $self->_request( 'GET', $url ); 1; } or return 0;
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $self->_request("GET", $url); 1 } } or return 0 0 0 0
1094  
1095 0 return 1;
1096 } ## end sub check
1097  
1098 =head2 flush
1099  
1100 Removes all currently banned IPs and CIDR ranges at once by removing their
1101 access rules and forgetting them. This is the equivalent of fail2ban's
1102 C<actionflush>.
1103  
1104 $backend->flush;
1105  
1106 =cut
1107  
1108 1 ▶sub flush {
Subroutine flush: called CC=12 SCAR=41.4
Pod documented
1109 1 my ( $self, %opts ) = @_;
1110  
1111 1 $self->errorblank;
1112  
1113 1 ▶ if ( !$self->{inited} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"inited"}) 0 1 1
1114 0 $self->{error} = 1;
1115 0 $self->{errorString} = 'backend has not been inited';
1116 0 $self->warn;
1117 0 return;
1118 }
1119  
1120 1 my @requests;
1121 1 foreach my $item ( sort( keys( %{ $self->{banned} } ) ) ) {
1122 1 ▶ if ( $self->{testing} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'testing'}) { } 1 0 1
1123 1 push(
1124 @requests,
1125 { method => 'GET', url => $self->_unban_lookup_url($item) },
1126 { method => 'DELETE', url => $self->_endpoint . '/<id>' }
1127 );
1128 } else {
1129 0 local $@;
1130 0 ▶ eval { $self->_unban_ip($item); 1; } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $self->_unban_ip($item); 1 } } or do { $self->{"error"} = 25; $self->{"errorString"} = 'flush failed removing the rule for "' . $item . '"... ' . $@; $self->warn } 0 0 0
1131 0 $self->{error} = 25;
1132 0 $self->{errorString} = 'flush failed removing the rule for "' . $item . '"... ' . $@;
1133 0 $self->warn;
1134 };
1135 }
1136 } ## end foreach my $item ( sort( keys( %{ $self->{banned...})))
1137  
1138 # CIDR ranges are removed the same way, looked up by their own lookup URL
1139 1 foreach my $item ( sort( keys( %{ $self->{banned_cidr} } ) ) ) {
1140 0 ▶ if ( $self->{testing} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'testing'}) { } 0 0 0
1141 0 push(
1142 @requests,
1143 { method => 'GET', url => $self->_unban_cidr_lookup_url($item) },
1144 { method => 'DELETE', url => $self->_endpoint . '/<id>' }
1145 );
1146 } else {
1147 0 local $@;
1148 eval {
1149 0 my $decoded = $self->_request( 'GET', $self->_unban_cidr_lookup_url($item) );
1150  
1151 0 my $id;
1152 0 ▶ if ( ref( $decoded->{result} ) eq 'ARRAY' && defined( $decoded->{result}[0] ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $decoded->{"result"} eq "ARRAY" and defined $decoded->{"result"}[0]) 0 0 0
Condition0%0/3
ref $decoded->{"result"} eq "ARRAY" and defined $decoded->{"result"}[0]
!ll&&!rl&&r
000
MC/DC0%0/2
ref $decoded->{"result"} eq "ARRAY" and defined $decoded->{"result"}[0]
ref $decoded->{"result"} eq "ARRAY" defined $decoded->{"result"}[0]
Truth table0%0/3
A and B
A= ref $decoded->{"result"} eq "ARRAY"B= defined $decoded->{"result"}[0]
ABresult
0X0
100
111
1153 0 $id = $decoded->{result}[0]{id};
1154 }
1155  
1156 0 ▶ if ( defined($id) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $id) 0 0 0
1157 0 $self->_request( 'DELETE', $self->_endpoint . '/' . $id );
1158 }
1159 0 1;
1160 0 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { my $decoded = $self->_request("GET", $self->_unban_cidr_lookup_url($item)); my $id; if (ref $decoded->{"result"} eq "ARRAY" and defined $decoded->{"result"}[0]) { $id = $decoded->{"result"}[0]{"id"}; } ; if (defined $id) { $self->_request("DELETE", $self->_endpoint . '/' . $id); } ; 1 } } or do { $self->{"error"} = 25; $self->{"errorString"} = 'flush failed removing the rule for "' . $item . '"... ' . $@; $self->warn } 0 0 0
1161 0 $self->{error} = 25;
1162 0 $self->{errorString} = 'flush failed removing the rule for "' . $item . '"... ' . $@;
1163 0 $self->warn;
1164 };
1165 } ## end else [ if ( $self->{testing} ) ]
1166 } ## end foreach my $item ( sort( keys( %{ $self->{banned_cidr...})))
1167  
1168 1 ▶ if ( $self->{testing} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"testing"}) 1 0 1
1169 1 $self->{frontend_obj}->{test_data} = \@requests;
1170 }
1171  
1172 1 $self->{banned} = {};
1173 1 $self->{banned_cidr} = {};
1174 } ## end sub flush
1175  
1176 =head1 ERROR CODES / FLAGS
1177  
1178 Error handling is provided by L<Error::Helper>. All
1179 errors are considered fatal.
1180  
1181 =head2 1, notInited
1182  
1183 The backend has not been inited yet.
1184  
1185 =head2 6, invalidPrefixSpecified
1186  
1187 The specified prefix did not match /^[a-zA-Z0-9]+$/.
1188  
1189 =head2 7, invalidName
1190  
1191 The name is either undef or does not match /^[a-zA-Z0-9\-]+$/.
1192  
1193 =head2 8, optionsNotHash
1194  
1195 The item passed to new for options is not a hash.
1196  
1197 =head2 9, noBanItem
1198  
1199 No IP or CIDR range specified to ban or unban.
1200  
1201 =head2 10, banItemNotIP
1202  
1203 The item to ban is not an IP. Either wrong ref type or regexp
1204 test using L<Regexp::IPv4> and L<Regexp::IPv6> failed.
1205  
1206 =head2 12, backendInitError
1207  
1208 Failed to init the backend.
1209  
1210 =head2 13, banFailed
1211  
1212 Failed to ban the item.
1213  
1214 =head2 14, unbanFailed
1215  
1216 Failed to unban the item.
1217  
1218 =head2 15, listFailed
1219  
1220 Failed to get a list of bans.
1221  
1222 =head2 16, reInitFailed
1223  
1224 Failed to re_init the backend.
1225  
1226 =head2 17, teardownFailed
1227  
1228 Failed to teardown the backend.
1229  
1230 =head2 18, alreadyInited
1231  
1232 init called, but the backend has already been inited.
1233  
1234 =head2 20, modeInvalid
1235  
1236 The option mode is not 'block', 'challenge', 'js_challenge', or
1237 'managed_challenge'.
1238  
1239 =head2 23, initFailed
1240  
1241 init failed. Probing the access rules endpoint failed.
1242  
1243 =head2 24, checkFailed
1244  
1245 The backend check raised an error.
1246  
1247 =head2 25, flushFailed
1248  
1249 Failed to flush the bans.
1250  
1251 =head2 26, portsNotSupported
1252  
1253 The cloudflare backend blocks whole IPs and does not support ports.
1254  
1255 =head2 27, protocolsNotSupported
1256  
1257 The cloudflare backend blocks whole IPs and does not support protocols.
1258  
1259 =head2 28, optionInvalid
1260  
1261 An option is invalid. Auth requires either the option token or both the
1262 options email and key, zone must be a zone ID, and timeout must be an int.
1263  
1264 =head2 29, banCidrFailed
1265  
1266 Failed to ban the CIDR range.
1267  
1268 =head2 30, unbanCidrFailed
1269  
1270 Failed to unban the CIDR range.
1271  
1272 =head2 31, cidrItemNotCidr
1273  
1274 The item to ban is not a CIDR range. Either wrong ref type or it is not an
1275 IPv4 or IPv6 address followed by a prefix length valid for its family.
1276  
1277 =head2 32, cidrNotSupported
1278  
1279 The backend does not support CIDR bans.
1280  
1281 =head2 33, listCidrFailed
1282  
1283 Failed to get a list of CIDR bans.
1284  
1285 =head1 AUTHOR
1286  
1287 Zane C. Bowers-Hadley, C<< <vvelox at vvelox.ent> >>
1288  
1289 =head1 BUGS
1290  
1291 Please report any bugs or feature requests to C<bug-net-firewall-blockerhelper at rt.cpan.org>, or through
1292 the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-Firewall-BlockerHelper>.
1293  
1294 =head1 LICENSE AND COPYRIGHT
1295  
1296 This software is Copyright (c) 2023 by Zane C. Bowers-Hadley.
1297  
1298 This is free software, licensed under:
1299  
1300 The GNU Lesser General Public License, Version 2.1, February 1999
1301  
1302  
1303 =cut
1304  
1305 1 1; # End of Net::Firewall::BlockerHelper
« BlockerHelper/backends/fastly.pm ↑ Summary BlockerHelper/backends/checkpoint.pm »