blib/lib/WWW/Shopify/Liquid/Security.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 9 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 13 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 64 CC 4 SCAR 14.8
CC
4
Cov
0%
check_operate
12.0
new
6.0
verify
2.0
CRAP 4.4
1 #!/usr/bin/perl
2  
3 use strict;
4 use warnings;
5  
6 use WWW::Shopify::Liquid;
7  
8 # Designed to verify objects for possible malicious uses.
9 package WWW::Shopify::Liquid::Security;
10 sub new {
11 my ($package) = @_;
12 $package = 'WWW::Shopify::Liquid::Security::None' if $package eq 'WWW::Shopify::Liquid::Security';
13 return bless { }, $package;
14 }
15 sub verify { }
16 sub check_tag { }
17 sub check_operate { }
18  
19 package WWW::Shopify::Liquid::Exception::Security;
20 use base 'WWW::Shopify::Liquid::Exception';
21  
22 # No checking.
23 package WWW::Shopify::Liquid::Security::None;
24 use base 'WWW::Shopify::Liquid::Security';
25  
26 package WWW::Shopify::Liquid::Security::Strict;
27 use base 'WWW::Shopify::Liquid::Security';
28 use Scalar::Util qw(looks_like_number);
29  
30 sub check_tag {
31 my ($self, $ast, @rest) = @_;
32 }
33  
34 sub check_operate {
35 my ($self, $ast, @rest) = @_;
36 my %types = (
37 'WWW::Shopify::Liquid::Operator::Array' => sub {
38 my ($self, $hash, $type, $op1, $op2) = @_;
39 die new WWW::Shopify::Liquid::Exception::Security($self, "Array generation operands are too large.") if looks_like_number($op2) && looks_like_number($op1) && ($op2 - $op1) > 1000;
40 }
41 );
42
43 $types{ref($ast)}->($ast, @rest) if ref($ast) && $types{ref($ast)};
44 }
45  
46 1;