blib/lib/Lemonldap/NG/Manager/Conf/Tests.pm

filter: Statementstmt 60.0% 353 / 588 Branchbran 41.0% 207 / 504 Conditioncond 33.0% 86 / 260 MC/DCmcdc 10.1% 16 / 158 Subroutinesub 100% 91 / 91 Podpod 0.0% 0 / 1 totaltotal 47.0% 753 / 1602 CC 385 SCAR 32.0
CC
385
Cov
48%
__ANON__
128.2
__ANON__
111.3
__ANON__
102.7
CRAP 24.5
« blib/lib/Lemonldap/NG/Manager.pm ↑ Summary blib/lib/Lemonldap/NG/Manager/Build/OpenApi.pm »
1 package Lemonldap::NG::Manager::Conf::Tests;
2  
3 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 13 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 13 ▶use Lemonldap::NG::Common::Regexp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 13 ▶use Lemonldap::NG::Handler::Main;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 13 ▶use Lemonldap::NG::Common::Util qw(getSameSite);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 13 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 13 our $VERSION = '2.23.0';
12  
13 13 ▶use constant validPartnerName => qr/^[\w-]+$/;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 ## @method hashref tests(hashref conf)
16 # Return a hash ref where keys are the names of the tests and values
17 # subroutines to execute.
18 #
19 # Subroutines can return one of the followings :
20 # - (1) : everything is OK
21 # - (1,message) : OK with a warning
22 # - (0,message) : NOK
23 # - (-1,message) : OK, but must be confirmed (ignored if confirm parameter is
24 # set)
25 #
26 # Those subroutines can also modify configuration.
27 #
28 # @param $conf Configuration to test
29 # @return hash ref where keys are the names of the tests and values
30 sub tests {
31 47 ▶ my $conf = shift;
Subroutine tests: called CC=1 SCAR=1.4
Pod undocumented
32 return {
33  
34 # 1. CHECKS
35  
36 # Check if portal is in domain
37 portalIsInDomain => sub {
38  
39 # Looks like a sub, user knows what they are doing
40 47 ▶ if ( $conf->{portal} =~ /[\$\(&\|"']/ ) {
Subroutine __ANON__: called CC=3 SCAR=13.1
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"portal"} =~ /[\$\(&\|"']/) 0 47 47
41 0 return 1;
42 }
43  
44 return (
45 1,
46 (
47 47 ▶ index( $conf->{portal}, $conf->{domain} ) > 0
Branch: 1 branch
BranchTrueFalseTotal
index($conf->{'portal'}, $conf->{'domain'}) > 0 ? : 47 0 47
48 ? ''
49 : "Portal seems not to be in the domain $conf->{domain}"
50 )
51 );
52 },
53  
54 # Check if portal URL is well formated
55 portalURL => sub {
56 47 ▶ my $url = $conf->{portal};
Subroutine __ANON__: called CC=3 SCAR=12.5
57  
58 # Looks like a sub, user knows what they are doing
59 47 ▶ if ( $url =~ /[\$\(&\|"']/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($url =~ /[\$\(&\|"']/) { } 0 47 47
60 0 return 1;
61 }
62 else {
63 return (
64 47 ▶ 1,
Branch: 1 branch
BranchTrueFalseTotal
$url =~ m[/$] ? : 47 0 47
65 (
66 ( $url =~ m%/$% )
67 ? ''
68 : "Portal URL should end with a /"
69 )
70 );
71 }
72 },
73  
74 # Check if virtual hosts are in the domain
75 vhostInDomainOrCDA => sub {
76 47 ▶ return 1 if ( $conf->{cda} );
Subroutine __ANON__: called CC=5 SCAR=16.1
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"cda"} 0 47 47
77 47 my @pb;
78 47 foreach my $vh ( keys %{ $conf->{locationRules} } ) {
79 144 ▶ push @pb, $vh unless ( index( $vh, $conf->{domain} ) >= 0 );
Branch: 1 branch
BranchTrueFalseTotal
unless (index($vh, $conf->{"domain"}) != -1) 3 141 144
80 }
81 return (
82 47 ▶ 1,
Branch: 1 branch
BranchTrueFalseTotal
@pb ? : 3 44 47
83 (
84 @pb
85 ? 'Virtual hosts '
86 . join( ', ', @pb )
87 . " are not in $conf->{domain} and cross-domain-authentication is not set"
88 : undef
89 )
90 );
91 },
92  
93 # Check if automatically displayed menu applications have VH configuration
94 menuAutoDisplayedVhostsHaveConf => sub {
95 47 ▶ my @pb;
Subroutine __ANON__: called CC=11 SCAR=25.4
96  
97 # Known hosts: locationRules keys + every vhostAliases entry
98 my %known;
99 47 ▶ $known{ lc $_ } = 1 for keys %{ $conf->{locationRules} || {} };
Branch: 1 branch
BranchTrueFalseTotal
$conf->{"locationRules"} or {} 0 47 47
100 47 ▶ foreach my $vh ( keys %{ $conf->{vhostOptions} || {} } ) {
Branch: 1 branch
BranchTrueFalseTotal
$conf->{"vhostOptions"} or {} 3 44 47
101 22 my $aliases = $conf->{vhostOptions}->{$vh}->{vhostAliases};
102 22 ▶ next unless defined $aliases and length $aliases;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $aliases and length $aliases 22 0 22
Condition33%1/3
defined $aliases and length $aliases
!ll&&!rl&&r
2200
MC/DC0%0/2
defined $aliases and length $aliases
defined $aliases length $aliases
Truth table33%1/3
A and B
A= defined $aliasesB= length $aliases
ABresult
0X0
100
111
103 0 $known{ lc $_ } = 1 for split /\s+/, $aliases;
104 }
105  
106 # Walk applicationList recursively (categories may be nested)
107 47 my %entries;
108 my $walk;
109 $walk = sub {
110 203 ▶ my $node = shift;
Subroutine __ANON__: called CC=14 SCAR=28.9
111 203 ▶ return unless ref $node eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $node eq "HASH" 0 203 203
112 203 foreach my $key ( keys %$node ) {
113 960 ▶ next if $key =~ /^(?:catname|type|options|order)$/;
Branch: 1 branch
BranchTrueFalseTotal
if $key =~ /^(?:catname|type|options|order)$/ 462 498 960
114 498 my $child = $node->{$key};
115 498 ▶ next unless ref $child eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $child eq "HASH" 0 498 498
116 498 ▶ if ( ( $child->{type} // '' ) eq 'category' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (($child->{'type'} // '') eq 'category') { } 156 342 498
elsif (($child->{'options'}{'display'} // '') eq 'auto') { } 241 101 342
Condition50%1/2
$child->{"type"} // ""
l!l
4980
MC/DC0%0/1
$child->{"type"} // ""
$child->{"type"}
Truth table50%1/2
A
A= $child->{"type"}
Aresult
11
00
117 156 $walk->($child);
118 }
119 ▶ elsif ( ( $child->{options}->{display} // '' ) eq 'auto' ) {
Condition50%1/2
$child->{"options"}{"display"} // ""
l!l
3420
MC/DC0%0/1
$child->{"options"}{"display"} // ""
$child->{"options"}{"display"}
Truth table50%1/2
A
A= $child->{"options"}{"display"}
Aresult
11
00
120 241 my $uri = $child->{options}->{uri};
121 241 ▶ next unless defined $uri and length $uri;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $uri and length $uri 0 241 241
Condition33%1/3
defined $uri and length $uri
!ll&&!rl&&r
00241
MC/DC0%0/2
defined $uri and length $uri
defined $uri length $uri
Truth table33%1/3
A and B
A= defined $uriB= length $uri
ABresult
0X0
100
111
122 241 my $u = URI->new($uri);
123 241 ▶ next unless $u->can('host');
Branch: 1 branch
BranchTrueFalseTotal
unless $u->can("host") 0 241 241
124 241 my $h = $u->host;
125 241 ▶ $entries{ lc $h } = 1 if defined $h and length $h;
Branch: 1 branch
BranchTrueFalseTotal
if defined $h and length $h 241 0 241
Condition33%1/3
defined $h and length $h
!ll&&!rl&&r
00241
MC/DC0%0/2
defined $h and length $h
defined $h length $h
Truth table33%1/3
A and B
A= defined $hB= length $h
ABresult
0X0
100
111
126 }
127 }
128 47 };
129 47 $walk->( $conf->{applicationList} );
130  
131 47 foreach ( sort keys %entries ) {
132 147 ▶ push @pb, $_ unless $known{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless $known{$_} 11 136 147
133 }
134  
135 return (
136 47 ▶ 1,
Branch: 1 branch
BranchTrueFalseTotal
@pb ? : 8 39 47
137 (
138 @pb
139 ? 'Menu applications '
140 . join( ', ', @pb )
141 . ' are automatically displayed but have no configuration'
142 : undef
143 )
144 );
145 },
146  
147 # Check if virtual host do not contain a port
148 vhostWithPort => sub {
149 47 ▶ my @pb;
Subroutine __ANON__: called CC=4 SCAR=14.3
150 47 foreach my $vh ( keys %{ $conf->{locationRules} } ) {
151 144 ▶ push @pb, $vh if ( $vh =~ /:/ );
Branch: 1 branch
BranchTrueFalseTotal
if $vh =~ /:/ 0 144 144
152 }
153 return @pb
154 47 ▶ ? (
Branch: 1 branch
BranchTrueFalseTotal
@pb ? : 0 47 47
155 0,
156 'Virtual hosts '
157 . join( ', ', @pb )
158 . ' contain a port, this is not allowed'
159 )
160 : 1;
161 },
162  
163 # Force vhost to be lowercase
164 vhostUpperCase => sub {
165 47 ▶ my @pb;
Subroutine __ANON__: called CC=4 SCAR=14.3
166 47 foreach my $vh ( keys %{ $conf->{locationRules} } ) {
167 144 ▶ push @pb, $vh if ( $vh ne lc $vh );
Branch: 1 branch
BranchTrueFalseTotal
if $vh ne lc $vh 0 144 144
168 }
169 return @pb
170 47 ▶ ? (
Branch: 1 branch
BranchTrueFalseTotal
@pb ? : 0 47 47
171 0,
172 'Virtual hosts ' . join( ', ', @pb ) . ' must be in lower case'
173 )
174 : 1;
175 },
176  
177 vhostNotAnAlias => sub {
178 47 ▶ my ( @pb, @aliases, @all_aliases );
Subroutine __ANON__: called CC=5 SCAR=16.5
179  
180 @aliases =
181 22 map { $conf->{vhostOptions}->{$_}->{vhostAliases} }
182 47 keys %{ $conf->{vhostOptions} };
183  
184 47 foreach my $alias (@aliases) {
185 22 push @all_aliases, split( /\s+/, $alias );
186 }
187  
188 47 foreach my $vh ( keys %{ $conf->{locationRules} } ) {
189 144 ▶ push @pb, $vh if ( grep { lc($_) eq lc($vh) } @all_aliases );
Branch: 1 branch
BranchTrueFalseTotal
if grep {lc $_ eq lc $vh;} @all_aliases 0 144 144
190 }
191 return @pb
192 47 ▶ ? ( 0, 'Virtual hosts ' . join( ', ', @pb ) . ' match an alias' )
Branch: 1 branch
BranchTrueFalseTotal
@pb ? : 0 47 47
193 : 1;
194 },
195  
196 # Check if "userDB" and "authentication" are consistent
197 authAndUserDBConsistency => sub {
198 47 ▶ foreach
Subroutine __ANON__: called CC=4 SCAR=15.8
199 my $type (qw(Facebook Google OpenID OpenIDConnect SAML WebID))
200 {
201 return ( 0,
202 "\"$type\" can not be used as user database without using \"$type\" for authentication"
203 )
204 if ( $conf->{userDB} =~ /$type/
205 282 ▶ and $conf->{authentication} !~ /$type/ );
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"userDB"} =~ /$type/ and not $conf->{"authentication"} =~ /$type/ 0 282 282
Condition33%1/3
$conf->{"userDB"} =~ /$type/ and not $conf->{"authentication"} =~ /$type/
!ll&&!rl&&r
28200
MC/DC0%0/2
$conf->{"userDB"} =~ /$type/ and not $conf->{"authentication"} =~ /$type/
$conf->{"userDB"} =~ /$type/ not $conf->{"authentication"} =~ /$type/
Truth table33%1/3
A and not(B)
A= $conf->{"userDB"} =~ /$type/B= not $conf->{"authentication"} =~ /$type/
ABresult
0X0
100
111
206 }
207 47 return 1;
208 },
209  
210 # Check that OpenID macros exists
211 checkAttrAndMacros => sub {
212 47 ▶ my @tmp;
Subroutine __ANON__: called CC=7 SCAR=20.1
213 47 foreach my $k ( keys %$conf ) {
214 10294 ▶ if ( $k =~
Branch: 1 branch
BranchTrueFalseTotal
if ($k =~ /^(?:openIdSreg_(?:(?:(?:full|nick)nam|languag|postcod|timezon)e|country|gender|email|dob)|whatToTrace)$/) 83 10211 10294
215 /^(?:openIdSreg_(?:(?:(?:full|nick)nam|languag|postcod|timezon)e|country|gender|email|dob)|whatToTrace)$/
216 )
217 {
218 83 my $v = $conf->{$k};
219 83 $v =~ s/^$//;
220 83 ▶ next if ( $v =~ /^_/ );
Branch: 1 branch
BranchTrueFalseTotal
if $v =~ /^_/ 56 27 83
221 push @tmp,
222 $k
223 unless (
224 defined(
225 $conf->{exportedVars}->{$v}
226 27 ▶ or defined( $conf->{macros}->{$v} )
Branch: 1 branch
BranchTrueFalseTotal
unless defined($conf->{"exportedVars"}{$v} || defined $conf->{"macros"}{$v}) 0 27 27
Condition33%1/3
$conf->{'exportedVars'}{$v} || defined $conf->{'macros'}{$v}
l!l&&r!l&&!r
0027
MC/DC0%0/2
$conf->{'exportedVars'}{$v} || defined $conf->{'macros'}{$v}
$conf->{'exportedVars'}{$v} defined $conf->{'macros'}{$v}
Truth table33%1/3
A || B
A= $conf->{'exportedVars'}{$v}B= defined $conf->{'macros'}{$v}
ABresult
1X1
011
000
227 )
228 );
229 }
230 }
231 return (
232 47 ▶ 1,
Branch: 1 branch
BranchTrueFalseTotal
@tmp ? : 0 47 47
233 (
234 @tmp
235 ? 'Values of parameter(s) "'
236 . join( ', ', @tmp )
237 . '" are not defined in exported attributes or macros'
238 : ''
239 )
240 );
241 },
242  
243 # Test that variables are exported if Google is used as UserDB
244 checkUserDBGoogleAXParams => sub {
245 47 ▶ my @tmp;
Subroutine __ANON__: called CC=5 SCAR=24.5
246 47 ▶ if ( $conf->{userDB} =~ /^Google$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"userDB"} =~ /^Google$/) 0 47 47
247 0 foreach my $k ( keys %{ $conf->{exportedVars} } ) {
248 0 my $v = $conf->{exportedVars}->{$k};
249 0 ▶ if ( $v !~ Lemonldap::NG::Common::Regexp::GOOGLEAXATTR() ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($v =~ Lemonldap::NG::Common::Regexp::GOOGLEAXATTR()) 0 0 0
250 0 push @tmp, $v;
251 }
252 }
253 }
254 return (
255 47 ▶ 1,
Branch: 1 branch
BranchTrueFalseTotal
@tmp ? : 0 47 47
256 (
257 @tmp
258 ? 'Values of parameter(s) "'
259 . join( ', ', @tmp )
260 . '" are not exported by Google'
261 : ''
262 )
263 );
264 },
265  
266 # Test that variables are exported if OpenID is used as UserDB
267 checkUserDBOpenIDParams => sub {
268 47 ▶ my @tmp;
Subroutine __ANON__: called CC=5 SCAR=24.5
269 47 ▶ if ( $conf->{userDB} =~ /^OpenID$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"userDB"} =~ /^OpenID$/) 0 47 47
270 0 foreach my $k ( keys %{ $conf->{exportedVars} } ) {
271 0 my $v = $conf->{exportedVars}->{$k};
272 0 ▶ if ( $v !~ Lemonldap::NG::Common::Regexp::OPENIDSREGATTR() )
Branch: 1 branch
BranchTrueFalseTotal
unless ($v =~ Lemonldap::NG::Common::Regexp::OPENIDSREGATTR()) 0 0 0
273 {
274 0 push @tmp, $v;
275 }
276 }
277 }
278 return (
279 47 ▶ 1,
Branch: 1 branch
BranchTrueFalseTotal
@tmp ? : 0 47 47
280 (
281 @tmp
282 ? 'Values of parameter(s) "'
283 . join( ', ', @tmp )
284 . '" are not exported by OpenID SREG'
285 : ''
286 )
287 );
288 },
289  
290 # Try to use Apache::Session module
291 testApacheSession => sub {
292 47 ▶ my ( $id, %h );
Subroutine __ANON__: called CC=13 SCAR=48.5
293 47 my $gc = Lemonldap::NG::Handler::Main->tsv->{sessionStorageModule};
294 return 1
295 if ( ( $gc and $gc eq $conf->{globalStorage} )
296 or $conf->{globalStorage} =~
297 47 ▶ /^Lemonldap::NG::Common::Apache::Session::/ );
Branch: 1 branch
BranchTrueFalseTotal
if $gc and $gc eq $conf->{"globalStorage"} or $conf->{"globalStorage"} =~ /^Lemonldap::NG::Common::Apache::Session::/ 47 0 47
Condition33%2/6
$gc and $gc eq $conf->{"globalStorage"} or $conf->{"globalStorage"} =~ /^Lemonldap::NG::Common::Apache::Session::/
l!l&&r!l&&!r
4700
$gc and $gc eq $conf->{"globalStorage"}
!ll&&!rl&&r
0047
MC/DC0%0/3
$gc and $gc eq $conf->{"globalStorage"} or $conf->{"globalStorage"} =~ /^Lemonldap::NG::Common::Apache::Session::/
$gc $gc eq $conf->{"globalStorage"} $conf->{"globalStorage"} =~ /^Lemonldap::NG::Common::Apache::Session::/
Truth table20%1/5
A and B or C
A= $gcB= $gc eq $conf->{"globalStorage"}C= $conf->{"globalStorage"} =~ /^Lemonldap::NG::Common::Apache::Session::/
ABCresult
11X1
0X11
1011
0X00
1000
298 0 eval "use $conf->{globalStorage}";
299 0 ▶ return ( -1, "Unknown package $conf->{globalStorage}" ) if ($@);
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
300 0 eval {
301 tie %h, 'Lemonldap::NG::Common::Apache::Session', undef,
302 {
303 0 %{ $conf->{globalStorageOptions} },
304 backend => $conf->{globalStorage}
305 0 };
306 };
307 0 ▶ return ( -1, "Unable to create a session ($@)" )
Branch: 1 branch
BranchTrueFalseTotal
if $@ or not tied %h 0 0 0
Condition0%0/3
$@ or not tied %h
l!l&&r!l&&!r
000
MC/DC0%0/2
$@ or not tied %h
$@ not tied %h
Truth table0%0/3
A or not(B)
A= $@B= not tied %h
ABresult
1X1
011
000
308 if ( $@ or not tied(%h) );
309 0 eval {
310 0 $h{a} = 1;
311 0 ▶ $id = $h{_session_id} or return ( -1, 'No _session_id' );
Branch: 1 branch
BranchTrueFalseTotal
$id = $h{"_session_id"} or return -1, "No _session_id" 0 0 0
312 0 untie(%h);
313 tie %h, 'Lemonldap::NG::Common::Apache::Session', $id,
314 {
315 0 %{ $conf->{globalStorageOptions} },
316 backend => $conf->{globalStorage}
317 0 };
318 };
319 0 ▶ return ( -1, "Unable to insert data ($@)" ) if ($@);
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
320 return ( -1, "Unable to recover data stored" )
321 0 ▶ unless ( $h{a} == 1 );
Branch: 1 branch
BranchTrueFalseTotal
unless $h{"a"} == 1 0 0 0
322 0 eval { tied(%h)->delete; };
323 0 ▶ return ( -1, "Unable to delete session ($@)" ) if ($@);
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
324 return ( -1,
325 'All sessions may be lost and you must restart all your web servers'
326 0 ▶ ) if ( $gc and $conf->{globalStorage} ne $gc );
Branch: 1 branch
BranchTrueFalseTotal
if $gc and $conf->{"globalStorage"} ne $gc 0 0 0
Condition0%0/3
$gc and $conf->{"globalStorage"} ne $gc
!ll&&!rl&&r
000
MC/DC0%0/2
$gc and $conf->{"globalStorage"} ne $gc
$gc $conf->{"globalStorage"} ne $gc
Truth table0%0/3
A and B
A= $gcB= $conf->{"globalStorage"} ne $gc
ABresult
0X0
100
111
327 0 return 1;
328 },
329  
330 # Warn if cookie name has changed
331 cookieNameChanged => sub {
332 47 ▶ my $cn = Lemonldap::NG::Handler::Main->tsv->{cookieName};
Subroutine __ANON__: called CC=3 SCAR=13.1
333 return (
334 1,
335 (
336 $cn
337 and $cn ne $conf->{cookieName}
338 47 ▶ ? 'Cookie name has changed, you must restart all your web servers'
Branch: 1 branch
BranchTrueFalseTotal
$cn ne $conf->{'cookieName'} ? : 0 47 47
Condition33%1/3
$cn && ($cn ne $conf->{'cookieName'} ? 'Cookie name has changed, you must restart all your web servers' : ())
!ll&&!rl&&r
0047
MC/DC0%0/2
$cn && ($cn ne $conf->{'cookieName'} ? 'Cookie name has changed, you must restart all your web servers' : ())
$cn ($cn ne $conf->{'cookieName'} ? 'Cookie name has changed, you must restart all your web servers' : ())
Truth table33%1/3
A && B
A= $cnB= ($cn ne $conf->{'cookieName'} ? 'Cookie name has changed, you must restart all your web servers' : ())
ABresult
0X0
100
111
339 : ()
340 )
341 );
342 },
343  
344 # Warn if cookie TTL is equal or lower than one hour
345 cookieTTL => sub {
346 1 ▶ return 1 unless ( defined $conf->{cookieExpiration} );
Subroutine __ANON__: called CC=6 SCAR=34.1
Branch: 1 branch
BranchTrueFalseTotal
unless defined $conf->{"cookieExpiration"} 1 0 1
347 return ( 0, "Cookie TTL must be higher than one minute" )
348 unless ( $conf->{cookieExpiration} == 0
349 0 ▶ || $conf->{cookieExpiration} > 60 );
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"cookieExpiration"} == 0 or $conf->{"cookieExpiration"} > 60 0 0 0
Condition0%0/3
$conf->{"cookieExpiration"} == 0 or $conf->{"cookieExpiration"} > 60
l!l&&r!l&&!r
000
MC/DC0%0/2
$conf->{"cookieExpiration"} == 0 or $conf->{"cookieExpiration"} > 60
$conf->{"cookieExpiration"} == 0 $conf->{"cookieExpiration"} > 60
Truth table0%0/3
A or B
A= $conf->{"cookieExpiration"} == 0B= $conf->{"cookieExpiration"} > 60
ABresult
1X1
011
000
350 return ( 1, "Cookie TTL should be higher or equal than one hour" )
351 unless ( $conf->{cookieExpiration} >= 3600
352 0 ▶ || $conf->{cookieExpiration} == 0 );
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"cookieExpiration"} >= 3600 or $conf->{"cookieExpiration"} == 0 0 0 0
Condition0%0/3
$conf->{"cookieExpiration"} >= 3600 or $conf->{"cookieExpiration"} == 0
l!l&&r!l&&!r
000
MC/DC0%0/2
$conf->{"cookieExpiration"} >= 3600 or $conf->{"cookieExpiration"} == 0
$conf->{"cookieExpiration"} >= 3600 $conf->{"cookieExpiration"} == 0
Truth table0%0/3
A or B
A= $conf->{"cookieExpiration"} >= 3600B= $conf->{"cookieExpiration"} == 0
ABresult
1X1
011
000
353 0 return 1;
354 },
355  
356 # Warn if session timeout is lower than 10 minutes
357 sessionTimeout => sub {
358 47 ▶ return 1 unless ( defined $conf->{timeout} );
Subroutine __ANON__: called CC=4 SCAR=16.1
Branch: 1 branch
BranchTrueFalseTotal
unless defined $conf->{"timeout"} 0 47 47
359 return ( -1, "Session timeout should be higher than ten minutes" )
360 unless ( $conf->{timeout} > 600
361 47 ▶ || $conf->{timeout} == 0 );
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"timeout"} > 600 or $conf->{"timeout"} == 0 0 47 47
Condition33%1/3
$conf->{"timeout"} > 600 or $conf->{"timeout"} == 0
l!l&&r!l&&!r
4700
MC/DC0%0/2
$conf->{"timeout"} > 600 or $conf->{"timeout"} == 0
$conf->{"timeout"} > 600 $conf->{"timeout"} == 0
Truth table33%1/3
A or B
A= $conf->{"timeout"} > 600B= $conf->{"timeout"} == 0
ABresult
1X1
011
000
362 47 return 1;
363 },
364  
365 # Error if session Activity Timeout is equal or lower than one minute
366 sessionTimeoutActivity => sub {
367 47 ▶ return 1 unless ( defined $conf->{timeoutActivity} );
Subroutine __ANON__: called CC=4 SCAR=16.1
Branch: 1 branch
BranchTrueFalseTotal
unless defined $conf->{"timeoutActivity"} 0 47 47
368 return ( 0,
369 "Session activity timeout must be higher or equal than one minute"
370 )
371 unless ( $conf->{timeoutActivity} > 59
372 47 ▶ || $conf->{timeoutActivity} == 0 );
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"timeoutActivity"} > 59 or $conf->{"timeoutActivity"} == 0 0 47 47
Condition33%1/3
$conf->{"timeoutActivity"} > 59 or $conf->{"timeoutActivity"} == 0
l!l&&r!l&&!r
0470
MC/DC0%0/2
$conf->{"timeoutActivity"} > 59 or $conf->{"timeoutActivity"} == 0
$conf->{"timeoutActivity"} > 59 $conf->{"timeoutActivity"} == 0
Truth table33%1/3
A or B
A= $conf->{"timeoutActivity"} > 59B= $conf->{"timeoutActivity"} == 0
ABresult
1X1
011
000
373 47 return 1;
374 },
375  
376 # Error if activity timeout interval is higher than session activity timeout
377 timeoutActivityInterval => sub {
378 47 ▶ return 1 unless ( defined $conf->{timeoutActivityInterval} );
Subroutine __ANON__: called CC=4 SCAR=14.9
Branch: 1 branch
BranchTrueFalseTotal
unless defined $conf->{"timeoutActivityInterval"} 13 34 47
379 return ( 0,
380 "Activity timeout interval must be lower than session activity timeout"
381 )
382 if ( $conf->{timeoutActivity}
383 and $conf->{timeoutActivity} <=
384 34 ▶ $conf->{timeoutActivityInterval} );
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"timeoutActivity"} and $conf->{"timeoutActivity"} <= $conf->{"timeoutActivityInterval"} 0 34 34
Condition33%1/3
$conf->{"timeoutActivity"} and $conf->{"timeoutActivity"} <= $conf->{"timeoutActivityInterval"}
!ll&&!rl&&r
3400
MC/DC0%0/2
$conf->{"timeoutActivity"} and $conf->{"timeoutActivity"} <= $conf->{"timeoutActivityInterval"}
$conf->{"timeoutActivity"} $conf->{"timeoutActivity"} <= $conf->{"timeoutActivityInterval"}
Truth table33%1/3
A and B
A= $conf->{"timeoutActivity"}B= $conf->{"timeoutActivity"} <= $conf->{"timeoutActivityInterval"}
ABresult
0X0
100
111
385 34 return 1;
386 },
387  
388 # Warn if manager seems to be unprotected
389 managerProtection => sub {
390 return (
391 1,
392 (
393 47 ▶ $conf->{cfgAuthor} eq 'anonymous'
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$conf->{'cfgAuthor'} eq 'anonymous' ? : 15 32 47
394 ? 'Your manager seems to be unprotected'
395 : ''
396 )
397 );
398 },
399  
400 # Test support of timeouts for LDAPS connections
401 ldapsNoTimeout => sub {
402  
403 # Skip test if no SMTP configuration
404 47 ▶ return (1) unless ( $conf->{ldapServer} );
Subroutine __ANON__: called CC=6 SCAR=28.1
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"ldapServer"} 42 5 47
405  
406 5 ▶ if ( $conf->{ldapServer} =~ /ldaps:/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"ldapServer"} =~ /ldaps:/) 0 5 5
407  
408 0 ▶ if ( eval "require IO::Socket::SSL; require IO::Socket::IP;" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval "require IO::Socket::SSL; require IO::Socket::IP;") 0 0 0
409 0 ▶ if ( IO::Socket::SSL->isa('IO::Socket::IP') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ("IO::Socket::SSL"->isa("IO::Socket::IP")) 0 0 0
410 0 ▶ unless ( eval { IO::Socket::IP->VERSION(0.31) } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { "IO::Socket::IP"->VERSION("0.31") } }) 0 0 0
411 0 return ( 1,
412 "Your version of IO::Socket::IP is too old to enforce "
413 . "connection timeouts on ldaps:// URLs. Use ldap+tls:// instead"
414 );
415 }
416 }
417 }
418 }
419 5 return (1);
420 },
421  
422 # Test SMTP connection and authentication (warning only)
423 smtpConfiguration => sub {
424  
425 # Skip test if no SMTP configuration
426 47 ▶ return 1 unless ( $conf->{SMTPServer} );
Subroutine __ANON__: called CC=3 SCAR=19.2
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"SMTPServer"} 47 0 47
427  
428 # Use SMTP
429 0 eval "use Lemonldap::NG::Common::EmailTransport";
430 0 ▶ return ( 1, "Could not load Lemonldap::NG::Common::EmailTransport" )
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
431 if ($@);
432  
433 0 return Lemonldap::NG::Common::EmailTransport->configTest($conf);
434 },
435  
436 # SAML entity ID must be unique
437 samlIDPEntityIdUniqueness => sub {
438 return 1
439 unless ( $conf->{samlIDPMetaDataXML}
440 47 ▶ and %{ $conf->{samlIDPMetaDataXML} } );
Subroutine __ANON__: called CC=6 SCAR=31.7
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"samlIDPMetaDataXML"} and %{$conf->{"samlIDPMetaDataXML"};} 47 0 47
Condition66%2/3
$conf->{"samlIDPMetaDataXML"} and %{$conf->{"samlIDPMetaDataXML"};}
!ll&&!rl&&r
4430
MC/DC0%0/2
$conf->{"samlIDPMetaDataXML"} and %{$conf->{"samlIDPMetaDataXML"};}
$conf->{"samlIDPMetaDataXML"} %{$conf->{"samlIDPMetaDataXML"};}
Truth table66%2/3
A and B
A= $conf->{"samlIDPMetaDataXML"}B= %{$conf->{"samlIDPMetaDataXML"};}
ABresult
0X0
100
111
441 0 my @msg;
442 0 my $res = 1;
443 0 my %entityIds;
444 0 foreach my $idpId ( keys %{ $conf->{samlIDPMetaDataXML} } ) {
445 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"samlIDPMetaDataXML"}{$idpId}{"samlIDPMetaDataXML"} =~ /entityID=(['"])(.+?)\1/is) 0 0 0
446 $conf->{samlIDPMetaDataXML}->{$idpId}->{samlIDPMetaDataXML}
447 =~ /entityID=(['"])(.+?)\1/si )
448 {
449 0 my $eid = $2;
450 0 ▶ if ( defined $entityIds{$eid} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $entityIds{$eid}) 0 0 0
451 0 push @msg,
452 "$idpId and $entityIds{$eid} have the same SAML EntityID";
453 0 $res = 0;
454 0 next;
455 }
456 0 $entityIds{$eid} = $idpId;
457 }
458 }
459 0 return ( $res, join( ', ', @msg ) );
460 },
461 samlSPEntityIdUniqueness => sub {
462 return 1
463 unless ( $conf->{samlSPMetaDataXML}
464 47 ▶ and %{ $conf->{samlSPMetaDataXML} } );
Subroutine __ANON__: called CC=6 SCAR=18.2
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"samlSPMetaDataXML"} and %{$conf->{"samlSPMetaDataXML"};} 37 10 47
Condition100%3/3
$conf->{"samlSPMetaDataXML"} and %{$conf->{"samlSPMetaDataXML"};}
!ll&&!rl&&r
32510
MC/DC100%2/2
$conf->{"samlSPMetaDataXML"} and %{$conf->{"samlSPMetaDataXML"};}
$conf->{"samlSPMetaDataXML"} %{$conf->{"samlSPMetaDataXML"};}
Truth table100%3/3
A and B
A= $conf->{"samlSPMetaDataXML"}B= %{$conf->{"samlSPMetaDataXML"};}
ABresult
0X0
100
111
465 10 my @msg;
466 10 my $res = 1;
467 10 my %entityIds;
468 10 foreach my $spId ( keys %{ $conf->{samlSPMetaDataXML} } ) {
469 14 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"samlSPMetaDataXML"}{$spId}{"samlSPMetaDataXML"} =~ /entityID=(['"])(.+?)\1/is) 8 6 14
470 $conf->{samlSPMetaDataXML}->{$spId}->{samlSPMetaDataXML} =~
471 /entityID=(['"])(.+?)\1/si )
472 {
473 8 my $eid = $2;
474 8 ▶ if ( defined $entityIds{$eid} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $entityIds{$eid}) 0 8 8
475 0 push @msg,
476 "$spId and $entityIds{$eid} have the same SAML EntityID";
477 0 $res = 0;
478 0 next;
479 }
480 8 $entityIds{$eid} = $spId;
481 }
482 }
483 10 return ( $res, join( ', ', @msg ) );
484 },
485  
486 # Test if SAML private and public keys signature keys are set
487 samlSecretKeys => sub {
488 47 ▶ return 1 unless ( $conf->{issuerDBSAMLActivation} );
Subroutine __ANON__: called CC=6 SCAR=34.4
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"issuerDBSAMLActivation"} 47 0 47
489  
490 0 ▶ if ( $conf->{samlServicePrivateKeySig}
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{'samlServicePrivateKeySig'} and $conf->{'samlServicePublicKeySig'}) { } 0 0 0
Condition0%0/3
$conf->{"samlServicePrivateKeySig"} and $conf->{"samlServicePublicKeySig"}
!ll&&!rl&&r
000
MC/DC0%0/2
$conf->{"samlServicePrivateKeySig"} and $conf->{"samlServicePublicKeySig"}
$conf->{"samlServicePrivateKeySig"} $conf->{"samlServicePublicKeySig"}
Truth table0%0/3
A and B
A= $conf->{"samlServicePrivateKeySig"}B= $conf->{"samlServicePublicKeySig"}
ABresult
0X0
100
111
491 && $conf->{samlServicePublicKeySig} )
492 {
493 0 return 1;
494 }
495 else {
496 my ($key) = split( /\s*,\s*/,
497 0 ▶ ( $conf->{samlServiceSignatureKey} || "" ) );
Condition0%0/2
$conf->{'samlServiceSignatureKey'} || ''
l!l
00
MC/DC0%0/1
$conf->{'samlServiceSignatureKey'} || ''
$conf->{'samlServiceSignatureKey'}
Truth table0%0/2
A
A= $conf->{'samlServiceSignatureKey'}
Aresult
11
00
498 0 ▶ if ( $conf->{keys}->{$key} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"keys"}{$key}) 0 0 0
499 0 return 1;
500 }
501 }
502  
503 0 return ( 0,
504 'SAML service private and public keys signature must be set' );
505 },
506  
507 samlSignatureUnsupportedAlg => sub {
508 1 ▶ return 1 unless $conf->{issuerDBSAMLActivation};
Subroutine __ANON__: called CC=11 SCAR=47.1
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"issuerDBSAMLActivation"} 1 0 1
509 0 ▶ return 1
Branch: 1 branch
BranchTrueFalseTotal
unless eval "use Lasso; Lasso::check_version( 2, 5, 1, Lasso::Constants::CHECK_VERSION_NUMERIC) ? 0 : 1" 0 0 0
510 unless eval
511 'use Lasso; Lasso::check_version( 2, 5, 1, Lasso::Constants::CHECK_VERSION_NUMERIC) ? 0 : 1';
512  
513 0 my $allsha1 = 1;
514 undef $allsha1
515 0 ▶ unless $conf->{samlServiceSignatureMethod} eq "RSA_SHA1";
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"samlServiceSignatureMethod"} eq "RSA_SHA1" 0 0 0
516  
517 0 for my $idp ( keys %{ $conf->{samlIDPMetaDataOptions} } ) {
518 0 ▶ if ( $conf->{samlIDPMetaDataOptions}->{$idp}
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"samlIDPMetaDataOptions"}{$idp}{"samlIDPMetaDataOptionsSignatureMethod"}) 0 0 0
519 ->{samlIDPMetaDataOptionsSignatureMethod} )
520 {
521 0 ▶ if ( $conf->{samlIDPMetaDataOptions}->{$idp}
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"samlIDPMetaDataOptions"}{$idp}{"samlIDPMetaDataOptionsSignatureMethod"} ne "RSA_SHA1") 0 0 0
522 ->{samlIDPMetaDataOptionsSignatureMethod} ne
523 "RSA_SHA1" )
524 {
525 0 undef $allsha1;
526 0 last;
527 }
528 }
529 }
530 0 for my $sp ( keys %{ $conf->{samlSPMetaDataOptions} } ) {
531 0 ▶ if ( $conf->{samlSPMetaDataOptions}->{$sp}
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"samlSPMetaDataOptions"}{$sp}{"samlSPMetaDataOptionsSignatureMethod"}) 0 0 0
532 ->{samlSPMetaDataOptionsSignatureMethod} )
533 {
534 0 ▶ if ( $conf->{samlSPMetaDataOptions}->{$sp}
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"samlSPMetaDataOptions"}{$sp}{"samlSPMetaDataOptionsSignatureMethod"} ne "RSA_SHA1") 0 0 0
535 ->{samlSPMetaDataOptionsSignatureMethod} ne "RSA_SHA1" )
536 {
537 0 undef $allsha1;
538 0 last;
539 }
540 }
541 }
542 0 ▶ return $allsha1
Branch: 1 branch
BranchTrueFalseTotal
$allsha1 ? : 0 0 0
543 ? 1
544 : (
545 0,
546 "Algorithms other than SHA1 are only supported on Lasso>=2.5.1"
547 );
548 },
549  
550 samlIssuerNotEnabled => sub {
551 47 ▶ if ( keys %{ $conf->{samlSPMetaDataXML} || {} } ) {
Subroutine __ANON__: called CC=4 SCAR=14.0
Branch: 2 branches
BranchTrueFalseTotal
if (keys %{$conf->{"samlSPMetaDataXML"} or {};}) 10 37 47
$conf->{"samlSPMetaDataXML"} or {} 32 15 47
552 10 ▶ if ( $conf->{issuerDBSAMLActivation} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{'issuerDBSAMLActivation'}) { } 0 10 10
553 0 return 1;
554 }
555 else {
556 10 return ( 1,
557 "SAML service providers require enabling the SAML Issuer in General Parameters"
558 );
559 }
560 }
561 37 return 1;
562 },
563  
564 # Try to parse combination with declared modules
565 checkCombinations => sub {
566 47 ▶ return 1 unless ( $conf->{authentication} eq 'Combination' );
Subroutine __ANON__: called CC=8 SCAR=21.7
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"authentication"} eq "Combination" 46 1 47
567 1 require Lemonldap::NG::Common::Combination::Parser;
568 return ( 0, 'No module declared for combination' )
569 1 ▶ unless ( $conf->{combModules} and %{ $conf->{combModules} } );
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"combModules"} and %{$conf->{"combModules"};} 0 1 1
Condition33%1/3
$conf->{"combModules"} and %{$conf->{"combModules"};}
!ll&&!rl&&r
001
MC/DC0%0/2
$conf->{"combModules"} and %{$conf->{"combModules"};}
$conf->{"combModules"} %{$conf->{"combModules"};}
Truth table33%1/3
A and B
A= $conf->{"combModules"}B= %{$conf->{"combModules"};}
ABresult
0X0
100
111
570 1 my $moduleList;
571 1 foreach my $md ( keys %{ $conf->{combModules} } ) {
572 2 my $entry = $conf->{combModules}->{$md};
573 $moduleList->{$md} = (
574 $entry->{for} == 2 ? [ undef, {} ]
575 2 ▶ : $entry->{for} == 1 ? [ {}, undef ]
Branch: 2 branches
BranchTrueFalseTotal
$entry->{'for'} == 2 ? : 0 2 2
$entry->{'for'} == 1 ? : 0 2 2
576 : [ {}, {} ]
577 );
578 }
579 1 eval {
580 Lemonldap::NG::Common::Combination::Parser->parse( $moduleList,
581 1 $conf->{combination} );
582 };
583 1 ▶ return ( 0, $@ ) if ($@);
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 1 1
584  
585 # Return
586 1 return 1;
587 },
588  
589 # Check Combination parameters
590 combinationParameters => sub {
591 47 ▶ return 1 unless ( $conf->{authentication} eq "Combination" );
Subroutine __ANON__: called CC=4 SCAR=14.2
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"authentication"} eq "Combination" 46 1 47
592 return ( 0, "Combination rule must be defined" )
593 1 ▶ unless ( $conf->{combination} );
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"combination"} 0 1 1
594 return ( 0, 'userDB must be set to "Same" to enable Combination' )
595 1 ▶ unless ( $conf->{userDB} eq "Same" );
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"userDB"} eq "Same" 0 1 1
596 1 return 1;
597 },
598  
599 # Warn if 2F dependencies seem missing
600 sfaDependencies => sub {
601 47 ▶ my $ok = 0;
Subroutine __ANON__: called CC=13 SCAR=46.3
602 47 foreach (qw(totp yubikey)) {
603 94 ▶ $ok ||= $conf->{ $_ . '2fActivation' };
Condition33%1/3
$ok ||= $$conf{$_ . '2fActivation'}
l!l&&r!l&&!r
0094
MC/DC0%0/2
$ok ||= $$conf{$_ . '2fActivation'}
$ok $$conf{$_ . '2fActivation'}
Truth table33%1/3
A ||= B
A= $okB= $$conf{$_ . '2fActivation'}
ABresult
1X1
011
000
604 94 ▶ last if ($ok);
Branch: 1 branch
BranchTrueFalseTotal
if $ok 0 94 94
605 }
606 47 ▶ return 1 unless ($ok);
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 47 0 47
607  
608 # Use TOTP
609 0 ▶ if ( $conf->{totp2fActivation} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"totp2fActivation"}) 0 0 0
610 0 eval "use Convert::Base32";
611 0 ▶ return ( 1,
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
612 "Convert::Base32 module is required to enable TOTP" )
613 if ($@);
614 }
615  
616 # Use WebAuthn
617 0 ▶ if ( $conf->{webauthn2fActivation} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"webauthn2fActivation"}) 0 0 0
618 0 eval "use Authen::WebAuthn";
619 0 ▶ return ( 1,
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
620 "Authen::WebAuthn module is required to enable WebAuthn" )
621 if ($@);
622 }
623  
624 # WebAuthn requires https://
625 0 ▶ if ( $conf->{webauthn2fActivation} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"webauthn2fActivation"}) 0 0 0
626 0 my $portal_uri = URI->new( $conf->{portal} );
627 0 ▶ unless ( $portal_uri->scheme eq "https" ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($portal_uri->scheme eq "https") 0 0 0
628 0 return ( 1, "WebAuthn requires HTTPS" );
629 }
630 }
631  
632 # Use Yubikey
633 0 ▶ if ( $conf->{yubikey2fActivation} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"yubikey2fActivation"}) 0 0 0
634 0 eval "use Auth::Yubikey_WebClient";
635 0 ▶ return ( 1,
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
636 "Auth::Yubikey_WebClient module is required to enable Yubikey"
637 ) if ($@);
638 }
639 0 return 1;
640 },
641  
642 # Warn if TOTP not 6 or 8 digits long
643 totp2fDigits => sub {
644 47 ▶ return 1 unless ( $conf->{totp2fActivation} );
Subroutine __ANON__: called CC=5 SCAR=29.7
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"totp2fActivation"} 47 0 47
645 0 ▶ return 1 unless ( defined $conf->{totp2fDigits} );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $conf->{"totp2fDigits"} 0 0 0
646 return (
647 1,
648 ( (
649 $conf->{totp2fDigits} == 6
650 0 ▶ or $conf->{totp2fDigits} == 8
Branch: 1 branch
BranchTrueFalseTotal
$conf->{'totp2fDigits'} == 6 || $conf->{'totp2fDigits'} == 8 ? : 0 0 0
Condition0%0/3
$conf->{"totp2fDigits"} == 6 or $conf->{"totp2fDigits"} == 8
l!l&&r!l&&!r
000
MC/DC0%0/2
$conf->{"totp2fDigits"} == 6 or $conf->{"totp2fDigits"} == 8
$conf->{"totp2fDigits"} == 6 $conf->{"totp2fDigits"} == 8
Truth table0%0/3
A or B
A= $conf->{"totp2fDigits"} == 6B= $conf->{"totp2fDigits"} == 8
ABresult
1X1
011
000
651 )
652 ? ''
653 : 'TOTP should be 6 or 8 digits long'
654 )
655 );
656 },
657  
658 # Test TOTP params
659 totp2fParams => sub {
660 47 ▶ return 1 unless ( $conf->{totp2fActivation} );
Subroutine __ANON__: called CC=4 SCAR=25.0
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"totp2fActivation"} 47 0 47
661 return ( 0, 'TOTP range must be defined' )
662 0 ▶ unless ( $conf->{totp2fRange} );
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"totp2fRange"} 0 0 0
663 return ( 1, "TOTP interval should be higher than 10s" )
664 0 ▶ unless ( $conf->{totp2fInterval} > 10 );
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"totp2fInterval"} > 10 0 0 0
665 0 return 1;
666 },
667  
668 # Error if Yubikey client ID and secret key are missing
669 # Warn if Yubikey public ID size is not 12 digits long
670 yubikey2fParams => sub {
671 47 ▶ return 1 unless ( $conf->{yubikey2fActivation} );
Subroutine __ANON__: called CC=5 SCAR=29.7
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"yubikey2fActivation"} 47 0 47
672 return ( 0, "Yubikey client ID and secret key must be set" )
673 unless ( defined $conf->{yubikey2fSecretKey}
674 0 ▶ && defined $conf->{yubikey2fClientID} );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $conf->{"yubikey2fSecretKey"} and defined $conf->{"yubikey2fClientID"} 0 0 0
Condition0%0/3
defined $conf->{"yubikey2fSecretKey"} and defined $conf->{"yubikey2fClientID"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $conf->{"yubikey2fSecretKey"} and defined $conf->{"yubikey2fClientID"}
defined $conf->{"yubikey2fSecretKey"} defined $conf->{"yubikey2fClientID"}
Truth table0%0/3
A and B
A= defined $conf->{"yubikey2fSecretKey"}B= defined $conf->{"yubikey2fClientID"}
ABresult
0X0
100
111
675 return (
676 1,
677 (
678 0 ▶ ( $conf->{yubikey2fPublicIDSize} == 12 )
Branch: 1 branch
BranchTrueFalseTotal
$conf->{'yubikey2fPublicIDSize'} == 12 ? : 0 0 0
679 ? ''
680 : 'Yubikey public ID size should be 12 digits long'
681 )
682 );
683 },
684  
685 # Error if REST 2F verify URL is missing
686 rest2fVerifyUrl => sub {
687 47 ▶ return 1 unless ( $conf->{rest2fActivation} );
Subroutine __ANON__: called CC=3 SCAR=18.4
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"rest2fActivation"} 47 0 47
688 return ( 0, "REST 2F Verify URL must be set" )
689 0 ▶ unless ( defined $conf->{rest2fVerifyUrl} );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $conf->{"rest2fVerifyUrl"} 0 0 0
690  
691 # Return
692 0 return 1;
693 },
694  
695 # Warn if 2FA is required without a registrable 2F module enabled
696 required2FA => sub {
697 47 ▶ return 1 unless ( $conf->{sfRequired} );
Subroutine __ANON__: called CC=6 SCAR=34.3
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"sfRequired"} 47 0 47
698  
699 0 my $msg = '';
700 0 my $ok = 0;
701 0 foreach (qw(u totp yubikey webauthn)) {
702 $ok ||= $conf->{ $_ . '2fActivation' }
703 0 ▶ && $conf->{ $_ . '2fSelfRegistration' };
Condition0%0/6
$ok ||= $$conf{$_ . '2fActivation'} && $$conf{$_ . '2fSelfRegistration'}
l!l&&r!l&&!r
000
$$conf{$_ . '2fActivation'} && $$conf{$_ . '2fSelfRegistration'}
!ll&&!rl&&r
000
MC/DC0%0/3
$ok ||= $$conf{$_ . '2fActivation'} && $$conf{$_ . '2fSelfRegistration'}
$ok $$conf{$_ . '2fActivation'} $$conf{$_ . '2fSelfRegistration'}
Truth table0%0/4
A ||= B && C
A= $okB= $$conf{$_ . '2fActivation'}C= $$conf{$_ . '2fSelfRegistration'}
ABCresult
1XX1
0111
00X0
0100
704 0 ▶ last if ($ok);
Branch: 1 branch
BranchTrueFalseTotal
if $ok 0 0 0
705 }
706 0 return ( 1, $msg );
707 },
708  
709 # Error if external 2F Send or Validate command is missing
710 ext2fCommands => sub {
711 47 ▶ return 1 unless ( $conf->{ext2fActivation} );
Subroutine __ANON__: called CC=5 SCAR=30.0
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"ext2fActivation"} 47 0 47
712 return ( 0, "External 2F Send command must be set" )
713 0 ▶ unless ( defined $conf->{ext2FSendCommand} );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $conf->{"ext2FSendCommand"} 0 0 0
714 0 ▶ unless ( defined $conf->{ext2fCodeActivation} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $conf->{"ext2fCodeActivation"}) 0 0 0
715 return ( 0, "External 2F Validate command must be set" )
716 0 ▶ unless ( defined $conf->{ext2FValidateCommand} );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $conf->{"ext2FValidateCommand"} 0 0 0
717 }
718 0 return 1;
719 },
720  
721 # Warn if XSRF token TTL is higher than 30s
722 formTimeout => sub {
723 47 ▶ return 1 unless ( defined $conf->{formTimeout} );
Subroutine __ANON__: called CC=4 SCAR=14.2
Branch: 1 branch
BranchTrueFalseTotal
unless defined $conf->{"formTimeout"} 13 34 47
724 return ( 0, "XSRF form token TTL must be higher than 30s" )
725 34 ▶ unless ( $conf->{formTimeout} > 30 );
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"formTimeout"} > 30 0 34 34
726 return ( 1, "XSRF form token TTL should not be higher than 2mn" )
727 34 ▶ if ( $conf->{formTimeout} > 120 );
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"formTimeout"} > 120 0 34 34
728 34 return 1;
729 },
730  
731 # Warn if issuers token TTL is higher than 30s
732 issuersTimeout => sub {
733 47 ▶ return 1 unless ( defined $conf->{issuersTimeout} );
Subroutine __ANON__: called CC=4 SCAR=14.2
Branch: 1 branch
BranchTrueFalseTotal
unless defined $conf->{"issuersTimeout"} 15 32 47
734 return ( 0, "Issuers token TTL must be higher than 30s" )
735 32 ▶ unless ( $conf->{issuersTimeout} > 30 );
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"issuersTimeout"} > 30 0 32 32
736  
737 # because of issue #2186
738 return ( 1, "Issuers token TTL should not be higher than 10mn" )
739 32 ▶ if ( $conf->{issuersTimeout} > 600 );
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"issuersTimeout"} > 600 0 32 32
740 32 return 1;
741 },
742  
743 # Warn if number of password reset retries is null
744 passwordResetRetries => sub {
745 47 ▶ return 1 unless ( $conf->{portalDisplayResetPassword} );
Subroutine __ANON__: called CC=3 SCAR=11.7
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"portalDisplayResetPassword"} 45 2 47
746 return ( 1, "Number of reset password retries should not be null" )
747 2 ▶ unless ( $conf->{passwordResetAllowedRetries} );
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"passwordResetAllowedRetries"} 2 0 2
748 0 return 1;
749 },
750  
751 # Warn if ldapPpolicyControl is used with AD (#2007)
752 ppolicyAd => sub {
753 return ( 1,
754 "LDAP password policy control should be disabled when using AD authentication"
755 )
756 if ( $conf->{ldapPpolicyControl}
757 47 ▶ and $conf->{authentication} eq "AD" );
Subroutine __ANON__: called CC=3 SCAR=13.1
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"ldapPpolicyControl"} and $conf->{"authentication"} eq "AD" 0 47 47
Condition33%1/3
$conf->{"ldapPpolicyControl"} and $conf->{"authentication"} eq "AD"
!ll&&!rl&&r
4700
MC/DC0%0/2
$conf->{"ldapPpolicyControl"} and $conf->{"authentication"} eq "AD"
$conf->{"ldapPpolicyControl"} $conf->{"authentication"} eq "AD"
Truth table33%1/3
A and B
A= $conf->{"ldapPpolicyControl"}B= $conf->{"authentication"} eq "AD"
ABresult
0X0
100
111
758 47 return 1;
759 },
760  
761 # Warn if bruteForceProtection enabled without History
762 bruteForceProtection => sub {
763 my @lockTimes =
764 256 sort { $a <=> $b }
765 160 map { abs(s/\D//r) }
766 160 ▶ grep { /\d+/ }
Condition100%2/2
$conf->{'bruteForceProtectionLockTimes'} || ''
l!l
3215
MC/DC100%1/1
$conf->{'bruteForceProtectionLockTimes'} || ''
$conf->{'bruteForceProtectionLockTimes'}
Truth table100%2/2
A
A= $conf->{'bruteForceProtectionLockTimes'}
Aresult
11
00
767 47 ▶ split /\s*,\s*/, $conf->{bruteForceProtectionLockTimes} || '';
Subroutine __ANON__: called CC=10 SCAR=40.2
768 47 ▶ $conf->{bruteForceProtectionLockTimes} = join ', ', @lockTimes
Branch: 1 branch
BranchTrueFalseTotal
if scalar @lockTimes 32 15 47
769 if scalar @lockTimes;
770 47 ▶ return 1 unless ( $conf->{bruteForceProtection} );
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"bruteForceProtection"} 47 0 47
771 return ( 0,
772 '"History" plugin is required to enable "BruteForceProtection" plugin'
773 0 ▶ ) unless ( $conf->{loginHistoryEnabled} );
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"loginHistoryEnabled"} 0 0 0
774 return ( 0,
775 'Number of failed logins must be higher than 1 to enable "BruteForceProtection" plugin'
776 0 ▶ ) unless ( $conf->{failedLoginNumber} > 1 );
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"failedLoginNumber"} > 1 0 0 0
777 return ( 0,
778 'Number of allowed failed logins must be higher than 0 to enable "BruteForceProtection" plugin'
779 0 ▶ ) unless ( $conf->{bruteForceProtectionMaxFailed} > 0 );
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"bruteForceProtectionMaxFailed"} > 0 0 0 0
780 return ( 0,
781 'Number of failed logins history must be higher or equal than allowed failed logins plus lock time values'
782 )
783 if ( $conf->{bruteForceProtectionIncrementalTempo}
784 && $conf->{failedLoginNumber} <
785 0 ▶ $conf->{bruteForceProtectionMaxFailed} + scalar @lockTimes );
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"bruteForceProtectionIncrementalTempo"} and $conf->{"failedLoginNumber"} < $conf->{"bruteForceProtectionMaxFailed"} + scalar(@lockTimes) 0 0 0
Condition0%0/3
$conf->{"bruteForceProtectionIncrementalTempo"} and $conf->{"failedLoginNumber"} < $conf->{"bruteForceProtectionMaxFailed"} + scalar(@lockTimes)
!ll&&!rl&&r
000
MC/DC0%0/2
$conf->{"bruteForceProtectionIncrementalTempo"} and $conf->{"failedLoginNumber"} < $conf->{"bruteForceProtectionMaxFailed"} + scalar(@lockTimes)
$conf->{"bruteForceProtectionIncrementalTempo"} $conf->{"failedLoginNumber"} < $conf->{"bruteForceProtectionMaxFailed"} + scalar(@lockTimes)
Truth table0%0/3
A and B
A= $conf->{"bruteForceProtectionIncrementalTempo"}B= $conf->{"failedLoginNumber"} < $conf->{"bruteForceProtectionMaxFailed"} + scalar(@lockTimes)
ABresult
0X0
100
111
786 return ( 0,
787 'Number of failed logins history must be higher or equal than allowed failed logins'
788 )
789 unless ( $conf->{failedLoginNumber} >=
790 0 ▶ $conf->{bruteForceProtectionMaxFailed} );
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"failedLoginNumber"} >= $conf->{"bruteForceProtectionMaxFailed"} 0 0 0
791 0 return 1;
792 },
793  
794 # Warn if Mailrest plugin is enabled without Token or Captcha
795 checkMailResetSecurity => sub {
796 47 ▶ return 1 unless ( $conf->{portalDisplayResetPassword} );
Subroutine __ANON__: called CC=4 SCAR=16.1
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"portalDisplayResetPassword"} 45 2 47
797 return ( -1,
798 '"passwordMailReset" plugin is enabled without CSRF Token neither Captcha required'
799 )
800 unless ( $conf->{requireToken}
801 2 ▶ or $conf->{captcha_mail_enabled} );
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"requireToken"} or $conf->{"captcha_mail_enabled"} 2 0 2
Condition33%1/3
$conf->{"requireToken"} or $conf->{"captcha_mail_enabled"}
l!l&&r!l&&!r
002
MC/DC0%0/2
$conf->{"requireToken"} or $conf->{"captcha_mail_enabled"}
$conf->{"requireToken"} $conf->{"captcha_mail_enabled"}
Truth table33%1/3
A or B
A= $conf->{"requireToken"}B= $conf->{"captcha_mail_enabled"}
ABresult
1X1
011
000
802 0 return 1;
803 },
804  
805 # Warn if Impersonation and ContextSwitching are simultaneously enabled
806 impersonation => sub {
807 return ( 1,
808 "Impersonation and ContextSwitching are simultaneously enabled"
809 )
810 if ( $conf->{impersonationRule}
811 47 ▶ and $conf->{contextSwitchingRule} );
Subroutine __ANON__: called CC=3 SCAR=13.1
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"impersonationRule"} and $conf->{"contextSwitchingRule"} 0 47 47
Condition33%1/3
$conf->{"impersonationRule"} and $conf->{"contextSwitchingRule"}
!ll&&!rl&&r
4700
MC/DC0%0/2
$conf->{"impersonationRule"} and $conf->{"contextSwitchingRule"}
$conf->{"impersonationRule"} $conf->{"contextSwitchingRule"}
Truth table33%1/3
A and B
A= $conf->{"impersonationRule"}B= $conf->{"contextSwitchingRule"}
ABresult
0X0
100
111
812 47 return 1;
813 },
814  
815 # Warn if persistent storage is disabled with 2FA, History, OIDCConsents, Notifications or BruteForce protection
816 persistentStorage => sub {
817 47 ▶ return 1 unless ( $conf->{disablePersistentStorage} );
Subroutine __ANON__: called CC=8 SCAR=40.3
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"disablePersistentStorage"} 47 0 47
818 return ( 1, "2FA enabled WITHOUT persistent session storage" )
819 if ( $conf->{totp2fActivation}
820 0 ▶ || $conf->{yubikey2fActivation} );
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"totp2fActivation"} or $conf->{"yubikey2fActivation"} 0 0 0
Condition0%0/3
$conf->{"totp2fActivation"} or $conf->{"yubikey2fActivation"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$conf->{"totp2fActivation"} or $conf->{"yubikey2fActivation"}
$conf->{"totp2fActivation"} $conf->{"yubikey2fActivation"}
Truth table0%0/3
A or B
A= $conf->{"totp2fActivation"}B= $conf->{"yubikey2fActivation"}
ABresult
1X1
011
000
821 return ( 1,
822 "History plugin enabled WITHOUT persistent session storage" )
823 0 ▶ if ( $conf->{loginHistoryEnabled} );
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"loginHistoryEnabled"} 0 0 0
824 return ( 1,
825 "OIDC consents enabled WITHOUT persistent session storage" )
826 0 ▶ if ( $conf->{portalDisplayOidcConsents} );
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"portalDisplayOidcConsents"} 0 0 0
827 return ( 1,
828 "Notifications enabled WITHOUT persistent session storage" )
829 0 ▶ if ( $conf->{notification} );
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"notification"} 0 0 0
830 return ( 1,
831 "BruteForceProtection plugin enabled WITHOUT persistent session storage"
832 0 ▶ ) if ( $conf->{bruteForceProtection} );
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"bruteForceProtection"} 0 0 0
833 0 return 1;
834 },
835  
836 # Warn if XML dependencies seem missing
837 xmlDependencies => sub {
838 47 ▶ return 1 unless ( $conf->{oldNotifFormat} );
Subroutine __ANON__: called CC=4 SCAR=25.8
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"oldNotifFormat"} 47 0 47
839 0 eval "use XML::LibXML";
840 0 ▶ return ( 1,
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
841 "XML::LibXML module is required to enable old format notifications"
842 ) if ($@);
843 0 eval "use XML::LibXSLT";
844 0 ▶ return ( 1,
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
845 "XML::LibXSLT module is required to enable old format notifications"
846 ) if ($@);
847 0 return 1;
848 },
849  
850 # Warn if CertificateResetByMail dependencies seem missing
851 certResetByMailDependencies => sub {
852 47 ▶ return 1 unless ( $conf->{portalDisplayCertificateResetByMail} );
Subroutine __ANON__: called CC=4 SCAR=25.5
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"portalDisplayCertificateResetByMail"} 47 0 47
853 return ( 0,
854 "LDAP RegisterDB is required to enable CertificateResetByMail plugin"
855 0 ▶ ) unless ( $conf->{registerDB} eq 'LDAP' );
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"registerDB"} eq "LDAP" 0 0 0
856 0 eval "use DateTime::Format::RFC3339";
857 0 ▶ return ( 1,
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
858 "DateTime::Format::RFC3339 module is required to enable CertificateResetByMail plugin"
859 ) if ($@);
860 0 return 1;
861 },
862  
863 # OIDC redirect URI must not be empty
864 oidcRPRedirectURINotEmpty => sub {
865 return 1
866 unless ( $conf->{oidcRPMetaDataOptions}
867 47 ▶ and %{ $conf->{oidcRPMetaDataOptions} } );
Subroutine __ANON__: called CC=5 SCAR=16.6
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"oidcRPMetaDataOptions"} and %{$conf->{"oidcRPMetaDataOptions"};} 43 4 47
Condition100%3/3
$conf->{"oidcRPMetaDataOptions"} and %{$conf->{"oidcRPMetaDataOptions"};}
!ll&&!rl&&r
31124
MC/DC100%2/2
$conf->{"oidcRPMetaDataOptions"} and %{$conf->{"oidcRPMetaDataOptions"};}
$conf->{"oidcRPMetaDataOptions"} %{$conf->{"oidcRPMetaDataOptions"};}
Truth table100%3/3
A and B
A= $conf->{"oidcRPMetaDataOptions"}B= %{$conf->{"oidcRPMetaDataOptions"};}
ABresult
0X0
100
111
868 4 my @msg;
869 4 my $res = 1;
870 4 foreach my $oidcRpId ( keys %{ $conf->{oidcRPMetaDataOptions} } ) {
871 6 ▶ unless ( $conf->{oidcRPMetaDataOptions}->{$oidcRpId}
Branch: 1 branch
BranchTrueFalseTotal
unless ($conf->{"oidcRPMetaDataOptions"}{$oidcRpId}{"oidcRPMetaDataOptionsRedirectUris"}) 0 6 6
872 ->{oidcRPMetaDataOptionsRedirectUris} )
873 {
874 0 push @msg,
875 "$oidcRpId: OIDC Relying Party has no redirect URI defined";
876 0 $res = 0;
877 0 next;
878 }
879 }
880 4 return ( $res, join( ', ', @msg ) );
881 },
882  
883 # OIDC public RP should implement PKCE
884 oidcRPpublicClientWithPKCE => sub {
885 return 1
886 unless ( $conf->{oidcRPMetaDataOptions}
887 47 ▶ and %{ $conf->{oidcRPMetaDataOptions} } );
Subroutine __ANON__: called CC=6 SCAR=19.1
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"oidcRPMetaDataOptions"} and %{$conf->{"oidcRPMetaDataOptions"};} 43 4 47
Condition100%3/3
$conf->{"oidcRPMetaDataOptions"} and %{$conf->{"oidcRPMetaDataOptions"};}
!ll&&!rl&&r
31124
MC/DC100%2/2
$conf->{"oidcRPMetaDataOptions"} and %{$conf->{"oidcRPMetaDataOptions"};}
$conf->{"oidcRPMetaDataOptions"} %{$conf->{"oidcRPMetaDataOptions"};}
Truth table100%3/3
A and B
A= $conf->{"oidcRPMetaDataOptions"}B= %{$conf->{"oidcRPMetaDataOptions"};}
ABresult
0X0
100
111
888 4 my @msg;
889 4 foreach my $oidcRpId ( keys %{ $conf->{oidcRPMetaDataOptions} } ) {
890 6 ▶ if ( $conf->{oidcRPMetaDataOptions}->{$oidcRpId}
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"oidcRPMetaDataOptions"}{$oidcRpId}{"oidcRPMetaDataOptionsPublic"}) 0 6 6
891 ->{oidcRPMetaDataOptionsPublic} )
892 {
893 push @msg,
894 "$oidcRpId: requiring PKCE is recommended for public OIDC Relying Parties"
895 unless $conf->{oidcRPMetaDataOptions}->{$oidcRpId}
896 0 ▶ ->{oidcRPMetaDataOptionsRequirePKCE};
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"oidcRPMetaDataOptions"}{$oidcRpId}{"oidcRPMetaDataOptionsRequirePKCE"} 0 0 0
897 0 next;
898 }
899 }
900 4 return ( 1, join( ', ', @msg ) );
901 },
902  
903 # Test if OIDC private and public keys signature keys are set
904 oidcSecretKeys => sub {
905 47 ▶ return 1 unless ( $conf->{issuerDBOpenIDConnectActivation} );
Subroutine __ANON__: called CC=6 SCAR=34.4
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"issuerDBOpenIDConnectActivation"} 47 0 47
906  
907 0 ▶ if ( $conf->{oidcServicePrivateKeySig}
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{'oidcServicePrivateKeySig'} and $conf->{'oidcServicePublicKeySig'}) { } 0 0 0
Condition0%0/3
$conf->{"oidcServicePrivateKeySig"} and $conf->{"oidcServicePublicKeySig"}
!ll&&!rl&&r
000
MC/DC0%0/2
$conf->{"oidcServicePrivateKeySig"} and $conf->{"oidcServicePublicKeySig"}
$conf->{"oidcServicePrivateKeySig"} $conf->{"oidcServicePublicKeySig"}
Truth table0%0/3
A and B
A= $conf->{"oidcServicePrivateKeySig"}B= $conf->{"oidcServicePublicKeySig"}
ABresult
0X0
100
111
908 && $conf->{oidcServicePublicKeySig} )
909 {
910 0 return 1;
911 }
912 else {
913 my ($key) = split( /\s*,\s*/,
914 0 ▶ ( $conf->{oidcServiceSignatureKey} || "" ) );
Condition0%0/2
$conf->{'oidcServiceSignatureKey'} || ''
l!l
00
MC/DC0%0/1
$conf->{'oidcServiceSignatureKey'} || ''
$conf->{'oidcServiceSignatureKey'}
Truth table0%0/2
A
A= $conf->{'oidcServiceSignatureKey'}
Aresult
11
00
915 0 ▶ if ( $conf->{keys}->{$key} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"keys"}{$key}) 0 0 0
916 0 return 1;
917 }
918 }
919  
920 0 return ( 1,
921 'OIDC service private and public keys signature should be set'
922 );
923 },
924  
925 # RS* OIDC algs require a signing key
926 oidcRPNeedRSAKey => sub {
927 return 1
928 unless ( $conf->{oidcRPMetaDataOptions}
929 1 ▶ and %{ $conf->{oidcRPMetaDataOptions} } );
Subroutine __ANON__: called CC=10 SCAR=44.5
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"oidcRPMetaDataOptions"} and %{$conf->{"oidcRPMetaDataOptions"};} 1 0 1
Condition33%1/3
$conf->{"oidcRPMetaDataOptions"} and %{$conf->{"oidcRPMetaDataOptions"};}
!ll&&!rl&&r
100
MC/DC0%0/2
$conf->{"oidcRPMetaDataOptions"} and %{$conf->{"oidcRPMetaDataOptions"};}
$conf->{"oidcRPMetaDataOptions"} %{$conf->{"oidcRPMetaDataOptions"};}
Truth table33%1/3
A and B
A= $conf->{"oidcRPMetaDataOptions"}B= %{$conf->{"oidcRPMetaDataOptions"};}
ABresult
0X0
100
111
930 my @usingRSA =
931 grep {
932 $conf->{oidcRPMetaDataOptions}->{$_}
933 ->{oidcRPMetaDataOptionsIDTokenSignAlg}
934 and $conf->{oidcRPMetaDataOptions}->{$_}
935 0 ▶ ->{oidcRPMetaDataOptionsIDTokenSignAlg} =~ /^RS/
Branch: 1 branch
BranchTrueFalseTotal
$conf->{"oidcRPMetaDataOptions"}{$_}{"oidcRPMetaDataOptionsIDTokenSignAlg"} and $conf->{"oidcRPMetaDataOptions"}{$_}{"oidcRPMetaDataOptionsIDTokenSignAlg"} =~ /^RS/ 0 0 0
936 0 } keys %{ $conf->{oidcRPMetaDataOptions} }, grep {
937 $conf->{oidcRPMetaDataOptions}->{$_}
938 ->{oidcRPMetaDataOptionsAccessTokenSignAlg}
939 and $conf->{oidcRPMetaDataOptions}->{$_}
940 ->{oidcRPMetaDataOptionsAccessTokenSignAlg} =~ /^RS/
941 and $conf->{oidcRPMetaDataOptions}->{$_}
942 ->{oidcRPMetaDataOptionsAccessTokenJWT}
943 0 ▶ } keys %{ $conf->{oidcRPMetaDataOptions} };
Branch: 1 branch
BranchTrueFalseTotal
$conf->{"oidcRPMetaDataOptions"}{$_}{"oidcRPMetaDataOptionsAccessTokenSignAlg"} and $conf->{"oidcRPMetaDataOptions"}{$_}{"oidcRPMetaDataOptionsAccessTokenSignAlg"} =~ /^RS/ and $conf->{"oidcRPMetaDataOptions"}{$_}{"oidcRPMetaDataOptionsAccessTokenJWT"} 0 0 0
Condition0%0/3
$conf->{"oidcRPMetaDataOptions"}{$_}{"oidcRPMetaDataOptionsAccessTokenSignAlg"} and $conf->{"oidcRPMetaDataOptions"}{$_}{"oidcRPMetaDataOptionsAccessTokenSignAlg"} =~ /^RS/
!ll&&!rl&&r
000
MC/DC0%0/2
$conf->{"oidcRPMetaDataOptions"}{$_}{"oidcRPMetaDataOptionsAccessTokenSignAlg"} and $conf->{"oidcRPMetaDataOptions"}{$_}{"oidcRPMetaDataOptionsAccessTokenSignAlg"} =~ /^RS/
$conf->{"oidcRPMetaDataOptions"}{$_}{"oidcRPMetaDataOptionsAccessTokenSignAlg"} $conf->{"oidcRPMetaDataOptions"}{$_}{"oidcRPMetaDataOptionsAccessTokenSignAlg"} =~ /^RS/
Truth table0%0/3
A and B
A= $conf->{"oidcRPMetaDataOptions"}{$_}{"oidcRPMetaDataOptionsAccessTokenSignAlg"}B= $conf->{"oidcRPMetaDataOptions"}{$_}{"oidcRPMetaDataOptionsAccessTokenSignAlg"} =~ /^RS/
ABresult
0X0
100
111
944  
945 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (@usingRSA and not $conf->{"oidcServicePrivateKeySig"} || %{$conf->{"keys"} or {};}) 0 0 0
Condition0%0/6
@usingRSA and not $conf->{"oidcServicePrivateKeySig"} || %{$conf->{"keys"} or {};}
!ll&&!rl&&r
000
$conf->{'oidcServicePrivateKeySig'} || %{$conf->{'keys'} or {};}
l!l&&r!l&&!r
000
MC/DC0%0/3
@usingRSA and not $conf->{"oidcServicePrivateKeySig"} || %{$conf->{"keys"} or {};}
@usingRSA $conf->{'oidcServicePrivateKeySig'} %{$conf->{'keys'} or {};}
Truth table0%0/4
A and not(B || C)
A= @usingRSAB= $conf->{'oidcServicePrivateKeySig'}C= %{$conf->{'keys'} or {};}
ABCresult
0XX0
11X0
1010
1001
946 @usingRSA
947 and not( $conf->{oidcServicePrivateKeySig}
948 0 ▶ or %{ $conf->{keys} || {} } )
Branch: 1 branch
BranchTrueFalseTotal
$conf->{"keys"} or {} 0 0 0
949 )
950 {
951 0 my $msg =
952 join( ", ", @usingRSA )
953 . ": using RS-type encryption, but no RSA key is defined in global OIDC configuration";
954 0 return ( 0, $msg );
955 }
956 0 return 1;
957 },
958  
959 # Public OIDC clients require a public key algorithm
960 oidcRPPublicNeedPubAlg => sub {
961 return 1
962 unless ( $conf->{oidcRPMetaDataOptions}
963 47 ▶ and %{ $conf->{oidcRPMetaDataOptions} || {} } );
Subroutine __ANON__: called CC=9 SCAR=24.8
Branch: 2 branches
BranchTrueFalseTotal
unless $conf->{"oidcRPMetaDataOptions"} and %{$conf->{"oidcRPMetaDataOptions"} or {};} 43 4 47
$conf->{"oidcRPMetaDataOptions"} or {} 0 16 16
Condition100%3/3
$conf->{"oidcRPMetaDataOptions"} and %{$conf->{"oidcRPMetaDataOptions"} or {};}
!ll&&!rl&&r
31124
MC/DC100%2/2
$conf->{"oidcRPMetaDataOptions"} and %{$conf->{"oidcRPMetaDataOptions"} or {};}
$conf->{"oidcRPMetaDataOptions"} %{$conf->{"oidcRPMetaDataOptions"} or {};}
Truth table100%3/3
A and B
A= $conf->{"oidcRPMetaDataOptions"}B= %{$conf->{"oidcRPMetaDataOptions"} or {};}
ABresult
0X0
100
111
964 4 my @clients;
965 4 ▶ for ( keys %{ $conf->{oidcRPMetaDataOptions} || {} } ) {
Branch: 1 branch
BranchTrueFalseTotal
$conf->{"oidcRPMetaDataOptions"} or {} 0 4 4
966 6 ▶ if ( $conf->{oidcRPMetaDataOptions}->{$_}
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"oidcRPMetaDataOptions"}{$_}{"oidcRPMetaDataOptionsPublic"} and $conf->{"oidcRPMetaDataOptions"}{$_}{"oidcRPMetaDataOptionsIDTokenSignAlg"} =~ /^HS/) 0 6 6
Condition33%1/3
$conf->{"oidcRPMetaDataOptions"}{$_}{"oidcRPMetaDataOptionsPublic"} and $conf->{"oidcRPMetaDataOptions"}{$_}{"oidcRPMetaDataOptionsIDTokenSignAlg"} =~ /^HS/
!ll&&!rl&&r
600
MC/DC0%0/2
$conf->{"oidcRPMetaDataOptions"}{$_}{"oidcRPMetaDataOptionsPublic"} and $conf->{"oidcRPMetaDataOptions"}{$_}{"oidcRPMetaDataOptionsIDTokenSignAlg"} =~ /^HS/
$conf->{"oidcRPMetaDataOptions"}{$_}{"oidcRPMetaDataOptionsPublic"} $conf->{"oidcRPMetaDataOptions"}{$_}{"oidcRPMetaDataOptionsIDTokenSignAlg"} =~ /^HS/
Truth table33%1/3
A and B
A= $conf->{"oidcRPMetaDataOptions"}{$_}{"oidcRPMetaDataOptionsPublic"}B= $conf->{"oidcRPMetaDataOptions"}{$_}{"oidcRPMetaDataOptionsIDTokenSignAlg"} =~ /^HS/
ABresult
0X0
100
111
967 ->{oidcRPMetaDataOptionsPublic}
968 and $conf->{oidcRPMetaDataOptions}->{$_}
969 ->{oidcRPMetaDataOptionsIDTokenSignAlg} =~ /^HS/ )
970 {
971 0 push @clients, $_;
972 }
973 }
974 4 ▶ if (@clients) {
Branch: 1 branch
BranchTrueFalseTotal
if (@clients) { } 0 4 4
975 0 my $msg =
976 join( ", ", @clients )
977 . ": public clients should use a public key algorithm"
978 . " for ID token signature";
979 0 return 1, $msg;
980 }
981 else {
982 4 return 1;
983 }
984 },
985  
986 # OIDC RP Client ID must exist and be unique
987 oidcRPClientIdUniqueness => sub {
988 return 1
989 unless ( $conf->{oidcRPMetaDataOptions}
990 47 ▶ and %{ $conf->{oidcRPMetaDataOptions} } );
Subroutine __ANON__: called CC=6 SCAR=19.4
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"oidcRPMetaDataOptions"} and %{$conf->{"oidcRPMetaDataOptions"};} 43 4 47
Condition100%3/3
$conf->{"oidcRPMetaDataOptions"} and %{$conf->{"oidcRPMetaDataOptions"};}
!ll&&!rl&&r
31124
MC/DC100%2/2
$conf->{"oidcRPMetaDataOptions"} and %{$conf->{"oidcRPMetaDataOptions"};}
$conf->{"oidcRPMetaDataOptions"} %{$conf->{"oidcRPMetaDataOptions"};}
Truth table100%3/3
A and B
A= $conf->{"oidcRPMetaDataOptions"}B= %{$conf->{"oidcRPMetaDataOptions"};}
ABresult
0X0
100
111
991 4 my @msg;
992 4 my $res = 1;
993 4 my %clientIds;
994 4 foreach
995 4 my $clientConfKey ( keys %{ $conf->{oidcRPMetaDataOptions} } )
996 {
997 my $clientId =
998 $conf->{oidcRPMetaDataOptions}->{$clientConfKey}
999 6 ->{oidcRPMetaDataOptionsClientID};
1000 6 ▶ unless ($clientId) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($clientId) 0 6 6
1001 0 push @msg,
1002 "$clientConfKey: OIDC Relying Party has no Client ID";
1003 0 $res = 0;
1004 0 next;
1005 }
1006  
1007 6 ▶ if ( defined $clientIds{$clientId} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $clientIds{$clientId}) 0 6 6
1008 0 push @msg,
1009 "$clientConfKey and $clientIds{$clientId} have the same Client ID";
1010 0 $res = 0;
1011 0 next;
1012 }
1013 6 $clientIds{$clientId} = $clientConfKey;
1014 }
1015 4 return ( $res, join( ', ', @msg ) );
1016 },
1017  
1018 oidcIssuerNotEnabled => sub {
1019 47 ▶ if ( keys %{ $conf->{oidcRPMetaDataOptions} || {} } ) {
Subroutine __ANON__: called CC=4 SCAR=14.0
Branch: 2 branches
BranchTrueFalseTotal
if (keys %{$conf->{"oidcRPMetaDataOptions"} or {};}) 4 43 47
$conf->{"oidcRPMetaDataOptions"} or {} 31 16 47
1020 4 ▶ if ( $conf->{issuerDBOpenIDConnectActivation} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{'issuerDBOpenIDConnectActivation'}) { } 0 4 4
1021 0 return 1;
1022 }
1023 else {
1024 4 return ( 1,
1025 "OIDC relying parties require enabling the OpenID Connect Issuer in General Parameters"
1026 );
1027 }
1028 }
1029 43 return 1;
1030 },
1031  
1032 # CAS APP URL must be defined and unique
1033 casAppHostnameUniqueness => sub {
1034 return 1
1035 unless ( $conf->{casAppMetaDataOptions}
1036 47 ▶ and %{ $conf->{casAppMetaDataOptions} } );
Subroutine __ANON__: called CC=8 SCAR=21.1
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"casAppMetaDataOptions"} and %{$conf->{"casAppMetaDataOptions"};} 42 5 47
Condition100%3/3
$conf->{"casAppMetaDataOptions"} and %{$conf->{"casAppMetaDataOptions"};}
!ll&&!rl&&r
4115
MC/DC100%2/2
$conf->{"casAppMetaDataOptions"} and %{$conf->{"casAppMetaDataOptions"};}
$conf->{"casAppMetaDataOptions"} %{$conf->{"casAppMetaDataOptions"};}
Truth table100%3/3
A and B
A= $conf->{"casAppMetaDataOptions"}B= %{$conf->{"casAppMetaDataOptions"};}
ABresult
0X0
100
111
1037 5 my @msg;
1038 5 my $res = 1;
1039 5 my %casUrl;
1040 5 foreach my $casConfKey ( keys %{ $conf->{casAppMetaDataOptions} } )
1041 {
1042 8 for my $appUrl (
1043 split(
1044 /\s+/,
1045 $conf->{casAppMetaDataOptions}->{$casConfKey}
1046 ->{casAppMetaDataOptionsService}
1047 )
1048 )
1049 {
1050 9 ▶ $appUrl ||= "";
Condition50%1/2
$appUrl ||= ""
l!l
90
MC/DC0%0/1
$appUrl ||= ""
$appUrl
Truth table50%1/2
A
A= $appUrl
Aresult
11
00
1051 9 my ($appHost) = $appUrl =~ m#^(https?://[^/]+)(/.*)?$#;
1052 9 ▶ unless ($appHost) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($appHost) 1 8 9
1053 1 push @msg,
1054 "$casConfKey: CAS Application has no Service URL";
1055 1 $res = 0;
1056 1 next;
1057 }
1058  
1059 8 ▶ if ( defined $casUrl{$appUrl} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $casUrl{$appUrl}) 0 8 8
1060 0 push @msg,
1061 "$casConfKey and $casUrl{$appUrl} have the same Service URL";
1062 0 $res = 0;
1063 0 next;
1064 }
1065 8 $casUrl{$appUrl} = $casConfKey;
1066 }
1067 }
1068 5 return ( $res, join( ', ', @msg ) );
1069 },
1070  
1071 casIssuerNotEnabled => sub {
1072 47 ▶ if ( keys %{ $conf->{casAppMetaDataOptions} || {} } ) {
Subroutine __ANON__: called CC=4 SCAR=14.0
Branch: 2 branches
BranchTrueFalseTotal
if (keys %{$conf->{"casAppMetaDataOptions"} or {};}) 5 42 47
$conf->{"casAppMetaDataOptions"} or {} 41 6 47
1073 5 ▶ if ( $conf->{issuerDBCASActivation} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{'issuerDBCASActivation'}) { } 0 5 5
1074 0 return 1;
1075 }
1076 else {
1077 5 return ( 1,
1078 "CAS applications require enabling the CAS Issuer in General Parameters"
1079 );
1080 }
1081 }
1082 42 return 1;
1083 },
1084  
1085 # Relying Party / Service Provider / CAS Application names must
1086 # contain only word characters (letters, digits, underscore)
1087 spNameNoWhitespace => sub {
1088 47 ▶ my @msg;
Subroutine __ANON__: called CC=11 SCAR=25.6
1089 47 ▶ foreach my $rpId ( keys %{ $conf->{oidcRPMetaDataOptions} || {} } )
Branch: 1 branch
BranchTrueFalseTotal
$conf->{"oidcRPMetaDataOptions"} or {} 31 16 47
1090 {
1091 6 ▶ if ( $rpId !~ validPartnerName ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($rpId =~ /^[\w-]+$/) 0 6 6
1092 0 push @msg,
1093 "OIDC Relying Party name '$rpId' must contain only word characters (letters, digits, underscore)";
1094 }
1095 }
1096 47 ▶ foreach my $spId ( keys %{ $conf->{samlSPMetaDataXML} || {} } ) {
Branch: 1 branch
BranchTrueFalseTotal
$conf->{"samlSPMetaDataXML"} or {} 32 15 47
1097 14 ▶ if ( $spId !~ validPartnerName ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($spId =~ /^[\w-]+$/) 0 14 14
1098 0 push @msg,
1099 "SAML Service Provider name '$spId' must contain only word characters (letters, digits, underscore)";
1100 }
1101 }
1102 47 ▶ foreach my $casId ( keys %{ $conf->{casAppMetaDataOptions} || {} } )
Branch: 1 branch
BranchTrueFalseTotal
$conf->{"casAppMetaDataOptions"} or {} 41 6 47
1103 {
1104 8 ▶ if ( $casId !~ validPartnerName ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($casId =~ /^[\w-]+$/) 0 8 8
1105 0 push @msg,
1106 "CAS Application name '$casId' must contain only word characters (letters, digits, underscore)";
1107 }
1108 }
1109 47 ▶ return @msg ? ( 0, join( ', ', @msg ) ) : 1;
Branch: 1 branch
BranchTrueFalseTotal
@msg ? : 0 47 47
1110 },
1111  
1112 # Identity Provider / OpenID Provider / CAS Server names must
1113 # contain only word characters (letters, digits, underscore)
1114 idpNameNoWhitespace => sub {
1115 47 ▶ my @msg;
Subroutine __ANON__: called CC=11 SCAR=31.4
1116 47 ▶ foreach my $idpId ( keys %{ $conf->{samlIDPMetaDataXML} || {} } ) {
Branch: 1 branch
BranchTrueFalseTotal
$conf->{"samlIDPMetaDataXML"} or {} 4 43 47
1117 0 ▶ if ( $idpId !~ validPartnerName ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($idpId =~ /^[\w-]+$/) 0 0 0
1118 0 push @msg,
1119 "SAML Identity Provider name '$idpId' must contain only word characters (letters, digits, underscore)";
1120 }
1121 }
1122 47 ▶ foreach my $opId ( keys %{ $conf->{oidcOPMetaDataOptions} || {} } )
Branch: 1 branch
BranchTrueFalseTotal
$conf->{"oidcOPMetaDataOptions"} or {} 45 2 47
1123 {
1124 0 ▶ if ( $opId !~ validPartnerName ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opId =~ /^[\w-]+$/) 0 0 0
1125 0 push @msg,
1126 "OIDC OpenID Provider name '$opId' must contain only word characters (letters, digits, underscore)";
1127 }
1128 }
1129 47 foreach
1130 47 ▶ my $casSrvId ( keys %{ $conf->{casSrvMetaDataOptions} || {} } )
Branch: 1 branch
BranchTrueFalseTotal
$conf->{"casSrvMetaDataOptions"} or {} 46 1 47
1131 {
1132 0 ▶ if ( $casSrvId !~ validPartnerName ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($casSrvId =~ /^[\w-]+$/) 0 0 0
1133 0 push @msg,
1134 "CAS Server name '$casSrvId' must contain only word characters (letters, digits, underscore)";
1135 }
1136 }
1137 47 ▶ return @msg ? ( 0, join( ', ', @msg ) ) : 1;
Branch: 1 branch
BranchTrueFalseTotal
@msg ? : 0 47 47
1138 },
1139  
1140 # Notification system required with removed SF notification
1141 sfRemovedNotification => sub {
1142 47 ▶ return 1 unless ( $conf->{sfRemovedMsgRule} );
Subroutine __ANON__: called CC=4 SCAR=25.0
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"sfRemovedMsgRule"} 47 0 47
1143 return ( 1,
1144 'Notification system must be enabled to display a notification if a SF is removed'
1145 )
1146 if ( $conf->{sfRemovedUseNotif}
1147 0 ▶ and not $conf->{notification} );
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"sfRemovedUseNotif"} and not $conf->{"notification"} 0 0 0
Condition0%0/3
$conf->{"sfRemovedUseNotif"} and not $conf->{"notification"}
!ll&&!rl&&r
000
MC/DC0%0/2
$conf->{"sfRemovedUseNotif"} and not $conf->{"notification"}
$conf->{"sfRemovedUseNotif"} not $conf->{"notification"}
Truth table0%0/3
A and not(B)
A= $conf->{"sfRemovedUseNotif"}B= not $conf->{"notification"}
ABresult
0X0
100
111
1148 0 return 1;
1149 },
1150  
1151 # noAjaxHook and krbByJs are incompatible (#2237)
1152 noAjaxHookwithKrb => sub {
1153 return ( 1,
1154 'noAjaxHook is not compatible with'
1155 . ' AJAX Kerberos authentication' )
1156 47 ▶ if ( $conf->{noAjaxHook} and $conf->{krbByJs} );
Subroutine __ANON__: called CC=3 SCAR=13.1
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"noAjaxHook"} and $conf->{"krbByJs"} 0 47 47
Condition33%1/3
$conf->{"noAjaxHook"} and $conf->{"krbByJs"}
!ll&&!rl&&r
4700
MC/DC0%0/2
$conf->{"noAjaxHook"} and $conf->{"krbByJs"}
$conf->{"noAjaxHook"} $conf->{"krbByJs"}
Truth table33%1/3
A and B
A= $conf->{"noAjaxHook"}B= $conf->{"krbByJs"}
ABresult
0X0
100
111
1157 47 return 1;
1158 },
1159  
1160 # Cookie SameSite=None requires Secure flag
1161 # Same with SameSite=(auto) and SAML issuer in use
1162 SameSiteNoneWithSecure => sub {
1163 return ( -1, 'SameSite value = None requires the secured flag' )
1164 if ( getSameSite($conf) eq 'None'
1165 47 ▶ and !$conf->{securedCookie} );
Subroutine __ANON__: called CC=3 SCAR=13.1
Branch: 1 branch
BranchTrueFalseTotal
if getSameSite($conf) eq "None" and not $conf->{"securedCookie"} 0 47 47
Condition33%1/3
getSameSite($conf) eq "None" and not $conf->{"securedCookie"}
!ll&&!rl&&r
4700
MC/DC0%0/2
getSameSite($conf) eq "None" and not $conf->{"securedCookie"}
getSameSite($conf) eq "None" not $conf->{"securedCookie"}
Truth table33%1/3
A and not(B)
A= getSameSite($conf) eq "None"B= not $conf->{"securedCookie"}
ABresult
0X0
100
111
1166 47 return 1;
1167 },
1168  
1169 # Secure cookies require HTTPS
1170 SecureCookiesRequireHttps => sub {
1171 return ( -1, 'Secure cookies require a HTTPS portal URL' )
1172 if ( $conf->{securedCookie} == 1
1173 and $conf->{portal}
1174 47 ▶ and $conf->{portal} !~ /^https:/ );
Subroutine __ANON__: called CC=4 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"securedCookie"} == 1 and $conf->{"portal"} and not $conf->{"portal"} =~ /^https:/ 0 47 47
Condition33%2/6
$conf->{"securedCookie"} == 1 and $conf->{"portal"} and not $conf->{"portal"} =~ /^https:/
!ll&&!rl&&r
4700
$conf->{"securedCookie"} == 1 and $conf->{"portal"}
!ll&&!rl&&r
4700
MC/DC0%0/3
$conf->{"securedCookie"} == 1 and $conf->{"portal"} and not $conf->{"portal"} =~ /^https:/
$conf->{"securedCookie"} == 1 $conf->{"portal"} not $conf->{"portal"} =~ /^https:/
Truth table25%1/4
A and B and not(C)
A= $conf->{"securedCookie"} == 1B= $conf->{"portal"}C= not $conf->{"portal"} =~ /^https:/
ABCresult
0XX0
10X0
1100
1111
1175 47 return 1;
1176 },
1177  
1178 # Password module requires a password backend
1179 passwordModuleNeedsBackend => sub {
1180 return ( -1, 'Password module is enabled without password backend' )
1181 if ( $conf->{portalDisplayChangePassword}
1182 47 ▶ and $conf->{passwordDB} eq 'Null' );
Subroutine __ANON__: called CC=10 SCAR=38.4
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"portalDisplayChangePassword"} and $conf->{"passwordDB"} eq "Null" 0 47 47
Condition33%1/3
$conf->{"portalDisplayChangePassword"} and $conf->{"passwordDB"} eq "Null"
!ll&&!rl&&r
0470
MC/DC0%0/2
$conf->{"portalDisplayChangePassword"} and $conf->{"passwordDB"} eq "Null"
$conf->{"portalDisplayChangePassword"} $conf->{"passwordDB"} eq "Null"
Truth table33%1/3
A and B
A= $conf->{"portalDisplayChangePassword"}B= $conf->{"passwordDB"} eq "Null"
ABresult
0X0
100
111
1183 47 ▶ if ( $conf->{portalDisplayChangePassword}
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"portalDisplayChangePassword"} and $conf->{"passwordDB"} eq "Choice" and $conf->{"authChoiceModules"}) 0 47 47
Condition33%2/6
$conf->{"portalDisplayChangePassword"} and $conf->{"passwordDB"} eq "Choice" and $conf->{"authChoiceModules"}
!ll&&!rl&&r
4700
$conf->{"portalDisplayChangePassword"} and $conf->{"passwordDB"} eq "Choice"
!ll&&!rl&&r
0470
MC/DC0%0/3
$conf->{"portalDisplayChangePassword"} and $conf->{"passwordDB"} eq "Choice" and $conf->{"authChoiceModules"}
$conf->{"portalDisplayChangePassword"} $conf->{"passwordDB"} eq "Choice" $conf->{"authChoiceModules"}
Truth table25%1/4
A and B and C
A= $conf->{"portalDisplayChangePassword"}B= $conf->{"passwordDB"} eq "Choice"C= $conf->{"authChoiceModules"}
ABCresult
0XX0
10X0
1100
1111
1184 and $conf->{passwordDB} eq 'Choice'
1185 and $conf->{authChoiceModules} )
1186 {
1187 0 my $hasPwdBE = 0;
1188 0 foreach ( keys %{ $conf->{authChoiceModules} } ) {
1189 0 my @mods = split /;\s*/, $conf->{authChoiceModules}->{$_};
1190 0 ▶ $hasPwdBE ||= 1 unless $mods[2] eq 'Null';
Branch: 1 branch
BranchTrueFalseTotal
unless $mods[2] eq "Null" 0 0 0
Condition0%0/2
$hasPwdBE ||= 1
l!l
00
MC/DC0%0/1
$hasPwdBE ||= 1
$hasPwdBE
Truth table0%0/2
A
A= $hasPwdBE
Aresult
11
00
1191 }
1192 0 ▶ return ( -1,
Branch: 1 branch
BranchTrueFalseTotal
unless $hasPwdBE 0 0 0
1193 'Password module is enabled without AuthChoice password backend'
1194 ) unless $hasPwdBE;
1195 }
1196 47 return 1;
1197 },
1198  
1199 webAuthnRequiresToken => sub {
1200 47 ▶ if (
Subroutine __ANON__: called CC=4 SCAR=23.3
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_->[0] eq "WebAuthn";} map({[split(/;\s*/, $_, 0)];} values %{$$conf{"authChoiceModules"};})) 0 47 47
1201 0 grep { $_->[0] eq "WebAuthn" }
1202 0 map { [ split( /;\s*/, $_ ) ] }
1203 47 values %{ $conf->{authChoiceModules} }
1204 )
1205 {
1206 0 ▶ if ( $conf->{requireToken} == 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($conf->{'requireToken'} == 0) { } 0 0 0
elsif ($conf->{'requireToken'} == 1) { } 0 0 0
1207 0 return ( 0,
1208 "WebAuthn authentication requires using a token" );
1209 }
1210 elsif ( $conf->{requireToken} == 1 ) {
1211 0 return 1;
1212 }
1213 else {
1214 0 return ( 1,
1215 "WebAuthn authentication requires a token"
1216 . " but a rule was defined for token use."
1217 . " WebAuthn might not work in some situations" );
1218 }
1219 }
1220 47 return 1;
1221 },
1222  
1223 # FindUser requires Impersonation and attributes
1224 findUserWithoutImpersonationOrAttributes => sub {
1225 return ( -1,
1226 '"Impersonation" plugin is required to enable "FindUser" plugin'
1227 )
1228 if ( $conf->{findUser}
1229 47 ▶ and !$conf->{impersonationRule} );
Subroutine __ANON__: called CC=5 SCAR=20.9
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"findUser"} and not $conf->{"impersonationRule"} 0 47 47
Condition33%1/3
$conf->{"findUser"} and not $conf->{"impersonationRule"}
!ll&&!rl&&r
4700
MC/DC0%0/2
$conf->{"findUser"} and not $conf->{"impersonationRule"}
$conf->{"findUser"} not $conf->{"impersonationRule"}
Truth table33%1/3
A and not(B)
A= $conf->{"findUser"}B= not $conf->{"impersonationRule"}
ABresult
0X0
100
111
1230 return ( 1,
1231 '"FindUser" plugin enabled without searching attributes' )
1232 if ( $conf->{findUser}
1233 and scalar
1234 47 ▶ keys %{ $conf->{findUserSearchingAttributes} } == 0 );
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"findUser"} and scalar keys %{$$conf{"findUserSearchingAttributes"};} == 0 0 47 47
Condition33%1/3
$conf->{"findUser"} and scalar keys %{$$conf{"findUserSearchingAttributes"};} == 0
!ll&&!rl&&r
4700
MC/DC0%0/2
$conf->{"findUser"} and scalar keys %{$$conf{"findUserSearchingAttributes"};} == 0
$conf->{"findUser"} scalar keys %{$$conf{"findUserSearchingAttributes"};} == 0
Truth table33%1/3
A and B
A= $conf->{"findUser"}B= scalar keys %{$$conf{"findUserSearchingAttributes"};} == 0
ABresult
0X0
100
111
1235 47 return 1;
1236 },
1237  
1238 # FindUser wildcard must be allowed
1239 findUserWildcard => sub {
1240 return 1
1241 unless ( $conf->{findUser}
1242 and $conf->{findUserWildcard}
1243 47 ▶ and $conf->{findUserControl} );
Subroutine __ANON__: called CC=5 SCAR=28.0
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"findUser"} and $conf->{"findUserWildcard"} and $conf->{"findUserControl"} 0 0 0
Condition33%2/6
$conf->{"findUser"} and $conf->{"findUserWildcard"} and $conf->{"findUserControl"}
!ll&&!rl&&r
4700
$conf->{"findUser"} and $conf->{"findUserWildcard"}
!ll&&!rl&&r
4700
MC/DC0%0/3
$conf->{"findUser"} and $conf->{"findUserWildcard"} and $conf->{"findUserControl"}
$conf->{"findUser"} $conf->{"findUserWildcard"} $conf->{"findUserControl"}
Truth table25%1/4
A and B and C
A= $conf->{"findUser"}B= $conf->{"findUserWildcard"}C= $conf->{"findUserControl"}
ABCresult
0XX0
10X0
1100
1111
1244 return ( 1,
1245 'FindUser wildcard should be allowed by parameters control' )
1246 unless (
1247 0 ▶ $conf->{findUserWildcard} =~ /$conf->{findUserControl}/ );
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"findUserWildcard"} =~ /$conf->{"findUserControl"}/ 0 0 0
1248 0 return 1;
1249 },
1250  
1251 # AuthChoice parameters must exist
1252 AuthChoiceParams => sub {
1253 return 1
1254 unless ( $conf->{authChoiceModules}
1255 30 and %{ $conf->{authChoiceModules} }
1256 47 ▶ and $conf->{authentication} eq 'Choice' );
Subroutine __ANON__: called CC=7 SCAR=33.2
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"authChoiceModules"} and %{$conf->{"authChoiceModules"};} and $conf->{"authentication"} eq "Choice" 30 0 30
Condition50%3/6
$conf->{"authChoiceModules"} and %{$conf->{"authChoiceModules"};} and $conf->{"authentication"} eq "Choice"
!ll&&!rl&&r
4700
$conf->{"authChoiceModules"} and %{$conf->{"authChoiceModules"};}
!ll&&!rl&&r
17300
MC/DC0%0/3
$conf->{"authChoiceModules"} and %{$conf->{"authChoiceModules"};} and $conf->{"authentication"} eq "Choice"
$conf->{"authChoiceModules"} %{$conf->{"authChoiceModules"};} $conf->{"authentication"} eq "Choice"
Truth table50%2/4
A and B and C
A= $conf->{"authChoiceModules"}B= %{$conf->{"authChoiceModules"};}C= $conf->{"authentication"} eq "Choice"
ABCresult
0XX0
10X0
1100
1111
1257 0 foreach (qw(AuthBasic FindUser)) {
1258 0 ▶ if ( $conf->{"authChoice$_"} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$conf{"authChoice$_"}) 0 0 0
1259 0 my $test = $conf->{"authChoice$_"};
1260 my $param = grep /^$test$/,
1261 0 keys %{ $conf->{authChoiceModules} };
1262 0 ▶ return ( -1, "Choice $_ parameter does not exist" )
Branch: 1 branch
BranchTrueFalseTotal
unless $param 0 0 0
1263 unless $param;
1264 }
1265 }
1266 0 return 1;
1267 },
1268  
1269 # When auth is choice, userDB should be choice also
1270 userdbChoice => sub {
1271 return 1
1272 unless ( $conf->{authChoiceModules}
1273 30 and %{ $conf->{authChoiceModules} }
1274 47 ▶ and $conf->{authentication} eq 'Choice' );
Subroutine __ANON__: called CC=6 SCAR=28.7
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"authChoiceModules"} and %{$conf->{"authChoiceModules"};} and $conf->{"authentication"} eq "Choice" 30 0 30
Condition50%3/6
$conf->{"authChoiceModules"} and %{$conf->{"authChoiceModules"};} and $conf->{"authentication"} eq "Choice"
!ll&&!rl&&r
4700
$conf->{"authChoiceModules"} and %{$conf->{"authChoiceModules"};}
!ll&&!rl&&r
17300
MC/DC0%0/3
$conf->{"authChoiceModules"} and %{$conf->{"authChoiceModules"};} and $conf->{"authentication"} eq "Choice"
$conf->{"authChoiceModules"} %{$conf->{"authChoiceModules"};} $conf->{"authentication"} eq "Choice"
Truth table50%2/4
A and B and C
A= $conf->{"authChoiceModules"}B= %{$conf->{"authChoiceModules"};}C= $conf->{"authentication"} eq "Choice"
ABCresult
0XX0
10X0
1100
1111
1275 return ( 1, 'UserDB should be Same when authentication is Choice' )
1276 unless $conf->{userDB} eq 'Same'
1277 0 ▶ or $conf->{userDB} eq 'Choice';
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"userDB"} eq "Same" or $conf->{"userDB"} eq "Choice" 0 0 0
Condition0%0/3
$conf->{"userDB"} eq "Same" or $conf->{"userDB"} eq "Choice"
l!l&&r!l&&!r
000
MC/DC0%0/2
$conf->{"userDB"} eq "Same" or $conf->{"userDB"} eq "Choice"
$conf->{"userDB"} eq "Same" $conf->{"userDB"} eq "Choice"
Truth table0%0/3
A or B
A= $conf->{"userDB"} eq "Same"B= $conf->{"userDB"} eq "Choice"
ABresult
1X1
011
000
1278 0 return 1;
1279 },
1280  
1281 # FindUser authChoice parameter must be defined
1282 findUserChoiceParam => sub {
1283 return ( -1, 'FindUser choice parameter must be defined' )
1284 if ( $conf->{findUser}
1285 and $conf->{impersonationRule}
1286 and $conf->{authentication} eq 'Choice'
1287 47 ▶ and !$conf->{authChoiceFindUser} );
Subroutine __ANON__: called CC=5 SCAR=21.9
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"findUser"} and $conf->{"impersonationRule"} and $conf->{"authentication"} eq "Choice" and not $conf->{"authChoiceFindUser"} 0 47 47
Condition33%3/9
$conf->{"findUser"} and $conf->{"impersonationRule"} and $conf->{"authentication"} eq "Choice" and not $conf->{"authChoiceFindUser"}
!ll&&!rl&&r
4700
$conf->{"findUser"} and $conf->{"impersonationRule"} and $conf->{"authentication"} eq "Choice"
!ll&&!rl&&r
4700
$conf->{"findUser"} and $conf->{"impersonationRule"}
!ll&&!rl&&r
4700
MC/DC0%0/4
$conf->{"findUser"} and $conf->{"impersonationRule"} and $conf->{"authentication"} eq "Choice" and not $conf->{"authChoiceFindUser"}
$conf->{"findUser"} $conf->{"impersonationRule"} $conf->{"authentication"} eq "Choice" not $conf->{"authChoiceFindUser"}
Truth table20%1/5
A and B and C and not(D)
A= $conf->{"findUser"}B= $conf->{"impersonationRule"}C= $conf->{"authentication"} eq "Choice"D= not $conf->{"authChoiceFindUser"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
1288 47 return 1;
1289 },
1290  
1291 # Chain must be defined with AuthChoice
1292 authChoiceChains => sub {
1293 return ( -1, 'Authentication choice enabled without chain' )
1294 if ( $conf->{authentication} eq 'Choice'
1295 47 ▶ and scalar keys %{ $conf->{authChoiceModules} } == 0 );
Subroutine __ANON__: called CC=3 SCAR=14.2
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"authentication"} eq "Choice" and scalar keys %{$$conf{"authChoiceModules"};} == 0 0 47 47
Condition33%1/3
$conf->{"authentication"} eq "Choice" and scalar keys %{$$conf{"authChoiceModules"};} == 0
!ll&&!rl&&r
4700
MC/DC0%0/2
$conf->{"authentication"} eq "Choice" and scalar keys %{$$conf{"authChoiceModules"};} == 0
$conf->{"authentication"} eq "Choice" scalar keys %{$$conf{"authChoiceModules"};} == 0
Truth table33%1/3
A and B
A= $conf->{"authentication"} eq "Choice"B= scalar keys %{$$conf{"authChoiceModules"};} == 0
ABresult
0X0
100
111
1296 47 return 1;
1297 },
1298  
1299 # Internal portal URL must be defined with Proxy authentication
1300 authProxy => sub {
1301 return ( 0,
1302 'Proxy authentication enabled without internal portal URL' )
1303 if ( $conf->{authentication} eq 'Proxy'
1304 47 ▶ and !$conf->{proxyAuthService} );
Subroutine __ANON__: called CC=3 SCAR=13.1
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"authentication"} eq "Proxy" and not $conf->{"proxyAuthService"} 0 47 47
Condition33%1/3
$conf->{"authentication"} eq "Proxy" and not $conf->{"proxyAuthService"}
!ll&&!rl&&r
4700
MC/DC0%0/2
$conf->{"authentication"} eq "Proxy" and not $conf->{"proxyAuthService"}
$conf->{"authentication"} eq "Proxy" not $conf->{"proxyAuthService"}
Truth table33%1/3
A and not(B)
A= $conf->{"authentication"} eq "Proxy"B= not $conf->{"proxyAuthService"}
ABresult
0X0
100
111
1305 47 return 1;
1306 },
1307  
1308 # Warn if Impersonation and proxyAuthServiceImpersonation are simultaneously enabled
1309 impersonationProxy => sub {
1310 return ( -1,
1311 'Impersonation and internal portal Impersonation are simultaneously enabled'
1312 )
1313 if ( $conf->{impersonationRule}
1314 47 ▶ and $conf->{proxyAuthServiceImpersonation} );
Subroutine __ANON__: called CC=3 SCAR=13.1
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"impersonationRule"} and $conf->{"proxyAuthServiceImpersonation"} 0 47 47
Condition33%1/3
$conf->{"impersonationRule"} and $conf->{"proxyAuthServiceImpersonation"}
!ll&&!rl&&r
4700
MC/DC0%0/2
$conf->{"impersonationRule"} and $conf->{"proxyAuthServiceImpersonation"}
$conf->{"impersonationRule"} $conf->{"proxyAuthServiceImpersonation"}
Truth table33%1/3
A and B
A= $conf->{"impersonationRule"}B= $conf->{"proxyAuthServiceImpersonation"}
ABresult
0X0
100
111
1315 47 return 1;
1316 },
1317  
1318 # CheckDevOps requires Safe jail
1319 checkDevOpsWithSafeJail => sub {
1320 return ( 0, 'Safe jail must be enabled with CheckDevOps plugin' )
1321 if ( $conf->{checkDevOps}
1322 47 ▶ and !$conf->{useSafeJail} );
Subroutine __ANON__: called CC=3 SCAR=13.1
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"checkDevOps"} and not $conf->{"useSafeJail"} 0 47 47
Condition33%1/3
$conf->{"checkDevOps"} and not $conf->{"useSafeJail"}
!ll&&!rl&&r
4700
MC/DC0%0/2
$conf->{"checkDevOps"} and not $conf->{"useSafeJail"}
$conf->{"checkDevOps"} not $conf->{"useSafeJail"}
Truth table33%1/3
A and not(B)
A= $conf->{"checkDevOps"}B= not $conf->{"useSafeJail"}
ABresult
0X0
100
111
1323 47 return 1;
1324 },
1325  
1326 # Work around for #1740
1327 corruptApplicationConfig => sub {
1328 47 ▶ for my $cat ( keys %{ $conf->{applicationList} || {} } ) {
Subroutine __ANON__: called CC=8 SCAR=23.0
Branch: 1 branch
BranchTrueFalseTotal
$conf->{"applicationList"} or {} 0 47 47
1329 156 ▶ if ( ref( $conf->{applicationList}->{$cat} ) eq "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $conf->{"applicationList"}{$cat} eq "HASH") 156 0 156
1330 156 for my $app (
1331 156 ▶ keys %{ $conf->{applicationList}->{$cat} || {} } )
Branch: 1 branch
BranchTrueFalseTotal
$conf->{"applicationList"}{$cat} or {} 0 156 156
1332 {
1333 804 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (ref $conf->{"applicationList"}{$cat}{$app} eq "HASH" and $conf->{"applicationList"}{$cat}{$app}{"type"} eq "menuApp") 0 804 804
Condition66%2/3
ref $conf->{"applicationList"}{$cat}{$app} eq "HASH" and $conf->{"applicationList"}{$cat}{$app}{"type"} eq "menuApp"
!ll&&!rl&&r
4623420
MC/DC0%0/2
ref $conf->{"applicationList"}{$cat}{$app} eq "HASH" and $conf->{"applicationList"}{$cat}{$app}{"type"} eq "menuApp"
ref $conf->{"applicationList"}{$cat}{$app} eq "HASH" $conf->{"applicationList"}{$cat}{$app}{"type"} eq "menuApp"
Truth table66%2/3
A and B
A= ref $conf->{"applicationList"}{$cat}{$app} eq "HASH"B= $conf->{"applicationList"}{$cat}{$app}{"type"} eq "menuApp"
ABresult
0X0
100
111
1334 ref( $conf->{applicationList}->{$cat}->{$app} ) eq
1335 "HASH"
1336 and
1337 $conf->{applicationList}->{$cat}->{$app}->{type} eq
1338 "menuApp" )
1339 {
1340 0 return ( 0,
1341 'Error saving application list.'
1342 . ' Reload the manager and try again' );
1343 }
1344 }
1345 }
1346 }
1347 47 return 1;
1348 },
1349  
1350 # Warn if both oidcRPMetaDataOptionsJwks and oidcRPMetaDataOptionsJwksUri is set
1351 noJwksDuplication => sub {
1352 return 1
1353 unless $conf->{oidcRPMetaDataOptions}
1354 47 ▶ and ref $conf->{oidcRPMetaDataOptions};
Subroutine __ANON__: called CC=7 SCAR=21.5
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"oidcRPMetaDataOptions"} and ref $conf->{"oidcRPMetaDataOptions"} 31 16 47
Condition66%2/3
$conf->{"oidcRPMetaDataOptions"} and ref $conf->{"oidcRPMetaDataOptions"}
!ll&&!rl&&r
31016
MC/DC50%1/2
$conf->{"oidcRPMetaDataOptions"} and ref $conf->{"oidcRPMetaDataOptions"}
$conf->{"oidcRPMetaDataOptions"} ref $conf->{"oidcRPMetaDataOptions"}
Truth table66%2/3
A and B
A= $conf->{"oidcRPMetaDataOptions"}B= ref $conf->{"oidcRPMetaDataOptions"}
ABresult
0X0
100
111
1355 16 my @pb;
1356 16 for my $rp ( keys %{ $conf->{oidcRPMetaDataOptions} } ) {
1357 push @pb, $rp
1358 if $conf->{oidcRPMetaDataOptions}->{$rp}
1359 ->{oidcRPMetaDataOptionsJwks}
1360 and $conf->{oidcRPMetaDataOptions}->{$rp}
1361 6 ▶ ->{oidcRPMetaDataOptionsJwksUri};
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsJwks"} and $conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsJwksUri"} 0 6 6
Condition33%1/3
$conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsJwks"} and $conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsJwksUri"}
!ll&&!rl&&r
600
MC/DC0%0/2
$conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsJwks"} and $conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsJwksUri"}
$conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsJwks"} $conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsJwksUri"}
Truth table33%1/3
A and B
A= $conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsJwks"}B= $conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsJwksUri"}
ABresult
0X0
100
111
1362 }
1363 16 ▶ return 1 unless @pb;
Branch: 1 branch
BranchTrueFalseTotal
unless @pb 16 0 16
1364 0 return ( 1,
1365 "JWKS URI defined while JWKS document is fixed: "
1366 . join( ', ', @pb ) );
1367 },
1368  
1369 # If oidcRPMetaDataOptionsAuthRequiredForAuthorize is set, oidcRPMetaDataOptionsAuthMethod should be compatible
1370 oidcCompatAuth => sub {
1371 return 1
1372 unless $conf->{oidcRPMetaDataOptions}
1373 47 ▶ and ref $conf->{oidcRPMetaDataOptions};
Subroutine __ANON__: called CC=8 SCAR=24.0
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"oidcRPMetaDataOptions"} and ref $conf->{"oidcRPMetaDataOptions"} 31 16 47
Condition66%2/3
$conf->{"oidcRPMetaDataOptions"} and ref $conf->{"oidcRPMetaDataOptions"}
!ll&&!rl&&r
31016
MC/DC50%1/2
$conf->{"oidcRPMetaDataOptions"} and ref $conf->{"oidcRPMetaDataOptions"}
$conf->{"oidcRPMetaDataOptions"} ref $conf->{"oidcRPMetaDataOptions"}
Truth table66%2/3
A and B
A= $conf->{"oidcRPMetaDataOptions"}B= ref $conf->{"oidcRPMetaDataOptions"}
ABresult
0X0
100
111
1374 16 my @pb;
1375 16 for my $rp ( keys %{ $conf->{oidcRPMetaDataOptions} } ) {
1376 push @pb, $rp
1377 if $conf->{oidcRPMetaDataOptions}->{$rp}
1378 ->{oidcRPMetaDataOptionsAuthRequiredForAuthorize}
1379 and $conf->{oidcRPMetaDataOptions}->{$rp}
1380 ->{oidcRPMetaDataOptionsAuthMethod}
1381 and $conf->{oidcRPMetaDataOptions}->{$rp}
1382 ->{oidcRPMetaDataOptionsAuthMethod} !~
1383 6 ▶ /^(?:client_secret|private_key)_jwt$/;
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsAuthRequiredForAuthorize"} and $conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsAuthMethod"} and not $conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsAuthMethod"} =~ /^(?:client_secret|private_key)_jwt$/ 0 6 6
Condition33%2/6
$conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsAuthRequiredForAuthorize"} and $conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsAuthMethod"} and not $conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsAuthMethod"} =~ /^(?:client_secret|private_key)_jwt$/
!ll&&!rl&&r
600
$conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsAuthRequiredForAuthorize"} and $conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsAuthMethod"}
!ll&&!rl&&r
600
MC/DC0%0/3
$conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsAuthRequiredForAuthorize"} and $conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsAuthMethod"} and not $conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsAuthMethod"} =~ /^(?:client_secret|private_key)_jwt$/
$conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsAuthRequiredForAuthorize"} $conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsAuthMethod"} not $conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsAuthMethod"} =~ /^(?:client_secret|private_key)_jwt$/
Truth table25%1/4
A and B and not(C)
A= $conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsAuthRequiredForAuthorize"}B= $conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsAuthMethod"}C= not $conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsAuthMethod"} =~ /^(?:client_secret|private_key)_jwt$/
ABCresult
0XX0
10X0
1100
1111
1384 }
1385 16 ▶ return 1 unless @pb;
Branch: 1 branch
BranchTrueFalseTotal
unless @pb 16 0 16
1386 0 return ( 1,
1387 'Incompatible required authentication methods in RP '
1388 . '(only client_secret_jwt and private_key_jwt are allowed '
1389 . 'when authentication is required on authorization endpoint: '
1390 . join( ', ', @pb ) );
1391 },
1392  
1393 # Test password length policy if enabled
1394 ppMaxSizeGreaterThanMinSize => sub {
1395 return ( 1,
1396 'Password maximum size should be greater than minimal size' )
1397 if ( (
1398 $conf->{passwordPolicyMinSize} >=
1399 $conf->{passwordPolicyMaxSize}
1400 )
1401 and $conf->{passwordPolicyMaxSize}
1402 and $conf->{passwordPolicyActivation}
1403 47 ▶ );
Subroutine __ANON__: called CC=4 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"passwordPolicyMinSize"} >= $conf->{"passwordPolicyMaxSize"} and $conf->{"passwordPolicyMaxSize"} and $conf->{"passwordPolicyActivation"} 0 47 47
Condition33%2/6
$conf->{"passwordPolicyMinSize"} >= $conf->{"passwordPolicyMaxSize"} and $conf->{"passwordPolicyMaxSize"} and $conf->{"passwordPolicyActivation"}
!ll&&!rl&&r
4700
$conf->{"passwordPolicyMinSize"} >= $conf->{"passwordPolicyMaxSize"} and $conf->{"passwordPolicyMaxSize"}
!ll&&!rl&&r
0470
MC/DC0%0/3
$conf->{"passwordPolicyMinSize"} >= $conf->{"passwordPolicyMaxSize"} and $conf->{"passwordPolicyMaxSize"} and $conf->{"passwordPolicyActivation"}
$conf->{"passwordPolicyMinSize"} >= $conf->{"passwordPolicyMaxSize"} $conf->{"passwordPolicyMaxSize"} $conf->{"passwordPolicyActivation"}
Truth table25%1/4
A and B and C
A= $conf->{"passwordPolicyMinSize"} >= $conf->{"passwordPolicyMaxSize"}B= $conf->{"passwordPolicyMaxSize"}C= $conf->{"passwordPolicyActivation"}
ABCresult
0XX0
10X0
1100
1111
1404 47 return 1;
1405 },
1406  
1407 # Test password minimal size policy if enabled
1408 ppMinSize => sub {
1409 47 ▶ my $total;
Subroutine __ANON__: called CC=6 SCAR=21.2
1410 47 foreach (qw(Lower Upper Digit SpeChar)) {
1411 $total += $conf->{"passwordPolicyMin$_"}
1412 188 ▶ if $conf->{"passwordPolicyMin$_"} > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $$conf{"passwordPolicyMin$_"} > 0 0 188 188
1413 }
1414 return ( 1,
1415 'Password minimal size should be greater than total of minimal sizes'
1416 )
1417 if ( ( $conf->{passwordPolicyMinSize} < $total )
1418 and $conf->{passwordPolicyMinSize}
1419 47 ▶ and $conf->{passwordPolicyActivation} );
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"passwordPolicyMinSize"} < $total and $conf->{"passwordPolicyMinSize"} and $conf->{"passwordPolicyActivation"} 0 47 47
Condition33%2/6
$conf->{"passwordPolicyMinSize"} < $total and $conf->{"passwordPolicyMinSize"} and $conf->{"passwordPolicyActivation"}
!ll&&!rl&&r
4700
$conf->{"passwordPolicyMinSize"} < $total and $conf->{"passwordPolicyMinSize"}
!ll&&!rl&&r
4700
MC/DC0%0/3
$conf->{"passwordPolicyMinSize"} < $total and $conf->{"passwordPolicyMinSize"} and $conf->{"passwordPolicyActivation"}
$conf->{"passwordPolicyMinSize"} < $total $conf->{"passwordPolicyMinSize"} $conf->{"passwordPolicyActivation"}
Truth table25%1/4
A and B and C
A= $conf->{"passwordPolicyMinSize"} < $totalB= $conf->{"passwordPolicyMinSize"}C= $conf->{"passwordPolicyActivation"}
ABCresult
0XX0
10X0
1100
1111
1420 47 return 1;
1421 },
1422 accessTokenConsistency => sub {
1423 return 1
1424 47 ▶ unless $conf->{issuerDBOpenIDConnectActivation};
Subroutine __ANON__: called CC=7 SCAR=37.4
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"issuerDBOpenIDConnectActivation"} 47 0 47
1425 0 my @pb;
1426 0 ▶ foreach my $rp ( keys %{ $conf->{oidcRPMetaDataOptions} || {} } ) {
Branch: 1 branch
BranchTrueFalseTotal
$conf->{"oidcRPMetaDataOptions"} or {} 0 0 0
1427 0 my $opts = $conf->{oidcRPMetaDataOptions}->{$rp};
1428 push @pb, $rp
1429 if $opts->{oidcRPMetaDataOptionsAccessTokenClaims}
1430 0 ▶ and not $opts->{oidcRPMetaDataOptionsAccessTokenJWT};
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"oidcRPMetaDataOptionsAccessTokenClaims"} and not $opts->{"oidcRPMetaDataOptionsAccessTokenJWT"} 0 0 0
Condition0%0/3
$opts->{"oidcRPMetaDataOptionsAccessTokenClaims"} and not $opts->{"oidcRPMetaDataOptionsAccessTokenJWT"}
!ll&&!rl&&r
000
MC/DC0%0/2
$opts->{"oidcRPMetaDataOptionsAccessTokenClaims"} and not $opts->{"oidcRPMetaDataOptionsAccessTokenJWT"}
$opts->{"oidcRPMetaDataOptionsAccessTokenClaims"} not $opts->{"oidcRPMetaDataOptionsAccessTokenJWT"}
Truth table0%0/3
A and not(B)
A= $opts->{"oidcRPMetaDataOptionsAccessTokenClaims"}B= not $opts->{"oidcRPMetaDataOptionsAccessTokenJWT"}
ABresult
0X0
100
111
1431 }
1432 0 ▶ return 1 unless @pb;
Branch: 1 branch
BranchTrueFalseTotal
unless @pb 0 0 0
1433 0 return ( 0,
1434 'access_token cannot be opaque with claims in access_token ('
1435 . join( ', ', @pb )
1436 . ')' );
1437 },
1438 oidcNoneConsistency => sub {
1439 47 ▶ my @pb;
Subroutine __ANON__: called CC=7 SCAR=35.9
1440 47 ▶ return 1 unless $conf->{oidcServiceMetaDataDisallowNoneAlg};
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"oidcServiceMetaDataDisallowNoneAlg"} 47 0 47
1441 0 ▶ foreach my $rp ( keys %{ $conf->{oidcRPMetaDataOptions} || {} } ) {
Branch: 1 branch
BranchTrueFalseTotal
$conf->{"oidcRPMetaDataOptions"} or {} 0 0 0
1442 0 my $opts = $conf->{oidcRPMetaDataOptions}->{$rp};
1443 push @pb, $rp
1444 if $opts->{oidcRPMetaDataOptionsIDTokenSignAlg} eq 'none'
1445 0 ▶ or $opts->{oidcRPMetaDataOptionsUserInfoSignAlg} eq 'none';
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"oidcRPMetaDataOptionsIDTokenSignAlg"} eq "none" or $opts->{"oidcRPMetaDataOptionsUserInfoSignAlg"} eq "none" 0 0 0
Condition0%0/3
$opts->{"oidcRPMetaDataOptionsIDTokenSignAlg"} eq "none" or $opts->{"oidcRPMetaDataOptionsUserInfoSignAlg"} eq "none"
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts->{"oidcRPMetaDataOptionsIDTokenSignAlg"} eq "none" or $opts->{"oidcRPMetaDataOptionsUserInfoSignAlg"} eq "none"
$opts->{"oidcRPMetaDataOptionsIDTokenSignAlg"} eq "none" $opts->{"oidcRPMetaDataOptionsUserInfoSignAlg"} eq "none"
Truth table0%0/3
A or B
A= $opts->{"oidcRPMetaDataOptionsIDTokenSignAlg"} eq "none"B= $opts->{"oidcRPMetaDataOptionsUserInfoSignAlg"} eq "none"
ABresult
1X1
011
000
1446 }
1447 0 ▶ return 1 unless @pb;
Branch: 1 branch
BranchTrueFalseTotal
unless @pb 0 0 0
1448 0 return ( 1,
1449 'Signature algorithm is not allowed but set for: '
1450 . join( ', ', @pb ) );
1451 },
1452 oidcNativeSso => sub {
1453 return ( 0, 'Native SSO without OIDC identity service' )
1454 if $conf->{oidcServiceAllowNativeSso}
1455 47 ▶ and not $conf->{issuerDBOpenIDConnectActivation};
Subroutine __ANON__: called CC=13 SCAR=32.1
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"oidcServiceAllowNativeSso"} and not $conf->{"issuerDBOpenIDConnectActivation"} 0 47 47
Condition33%1/3
$conf->{"oidcServiceAllowNativeSso"} and not $conf->{"issuerDBOpenIDConnectActivation"}
!ll&&!rl&&r
4700
MC/DC0%0/2
$conf->{"oidcServiceAllowNativeSso"} and not $conf->{"issuerDBOpenIDConnectActivation"}
$conf->{"oidcServiceAllowNativeSso"} not $conf->{"issuerDBOpenIDConnectActivation"}
Truth table33%1/3
A and not(B)
A= $conf->{"oidcServiceAllowNativeSso"}B= not $conf->{"issuerDBOpenIDConnectActivation"}
ABresult
0X0
100
111
1456 return 1
1457 unless $conf->{oidcRPMetaDataOptions}
1458 47 ▶ and ref $conf->{oidcRPMetaDataOptions};
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"oidcRPMetaDataOptions"} and ref $conf->{"oidcRPMetaDataOptions"} 31 16 47
Condition66%2/3
$conf->{"oidcRPMetaDataOptions"} and ref $conf->{"oidcRPMetaDataOptions"}
!ll&&!rl&&r
31016
MC/DC50%1/2
$conf->{"oidcRPMetaDataOptions"} and ref $conf->{"oidcRPMetaDataOptions"}
$conf->{"oidcRPMetaDataOptions"} ref $conf->{"oidcRPMetaDataOptions"}
Truth table66%2/3
A and B
A= $conf->{"oidcRPMetaDataOptions"}B= ref $conf->{"oidcRPMetaDataOptions"}
ABresult
0X0
100
111
1459 16 my @needNativeSso;
1460 16 ▶ if ( $conf->{oidcRPMetaDataOptions}
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"oidcRPMetaDataOptions"} and ref $conf->{"oidcRPMetaDataOptions"}) 16 0 16
Condition33%1/3
$conf->{"oidcRPMetaDataOptions"} and ref $conf->{"oidcRPMetaDataOptions"}
!ll&&!rl&&r
0016
MC/DC0%0/2
$conf->{"oidcRPMetaDataOptions"} and ref $conf->{"oidcRPMetaDataOptions"}
$conf->{"oidcRPMetaDataOptions"} ref $conf->{"oidcRPMetaDataOptions"}
Truth table33%1/3
A and B
A= $conf->{"oidcRPMetaDataOptions"}B= ref $conf->{"oidcRPMetaDataOptions"}
ABresult
0X0
100
111
1461 and ref $conf->{oidcRPMetaDataOptions} )
1462 {
1463 16 for my $rp ( keys %{ $conf->{oidcRPMetaDataOptions} } ) {
1464 push @needNativeSso, $rp
1465 if $conf->{oidcRPMetaDataOptions}->{$rp}
1466 6 ▶ ->{oidcRPMetaDataOptionsAllowNativeSso};
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsAllowNativeSso"} 0 6 6
1467 }
1468 }
1469 16 ▶ if ( @needNativeSso and not $conf->{oidcServiceAllowNativeSso} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@needNativeSso and not $conf->{"oidcServiceAllowNativeSso"}) 0 16 16
Condition33%1/3
@needNativeSso and not $conf->{"oidcServiceAllowNativeSso"}
!ll&&!rl&&r
1600
MC/DC0%0/2
@needNativeSso and not $conf->{"oidcServiceAllowNativeSso"}
@needNativeSso not $conf->{"oidcServiceAllowNativeSso"}
Truth table33%1/3
A and not(B)
A= @needNativeSsoB= not $conf->{"oidcServiceAllowNativeSso"}
ABresult
0X0
100
111
1470 0 return ( 1,
1471 "Native SSO isn't enabled but needed by: "
1472 . join( ', ', @needNativeSso ) );
1473 }
1474 16 ▶ if ( !@needNativeSso and $conf->{oidcServiceAllowNativeSso} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not @needNativeSso and $conf->{"oidcServiceAllowNativeSso"}) 0 16 16
Condition33%1/3
not @needNativeSso and $conf->{"oidcServiceAllowNativeSso"}
!ll&&!rl&&r
0160
MC/DC0%0/2
not @needNativeSso and $conf->{"oidcServiceAllowNativeSso"}
not @needNativeSso $conf->{"oidcServiceAllowNativeSso"}
Truth table33%1/3
not(A) and B
A= not @needNativeSsoB= $conf->{"oidcServiceAllowNativeSso"}
ABresult
0X0
100
111
1475 0 return ( 1, 'Native SSO service enabled but useless' );
1476 }
1477 16 return 1;
1478 },
1479 crowdSecBouncer => sub {
1480 47 ▶ return 1 unless $conf->{crowdsec};
Subroutine __ANON__: called CC=3 SCAR=18.4
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"crowdsec"} 47 0 47
1481 0 ▶ return 1 if $conf->{crowdsecKey};
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"crowdsecKey"} 0 0 0
1482 0 return ( 0, 'Crowdsec Bouncer enabled without API key' );
1483 },
1484 crowdSecAgent => sub {
1485 47 ▶ return 1 unless $conf->{crowdsecAgent};
Subroutine __ANON__: called CC=4 SCAR=25.0
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"crowdsecAgent"} 47 0 47
1486 return 1
1487 0 ▶ if $conf->{crowdsecMachineId} and $conf->{crowdsecPassword};
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"crowdsecMachineId"} and $conf->{"crowdsecPassword"} 0 0 0
Condition0%0/3
$conf->{"crowdsecMachineId"} and $conf->{"crowdsecPassword"}
!ll&&!rl&&r
000
MC/DC0%0/2
$conf->{"crowdsecMachineId"} and $conf->{"crowdsecPassword"}
$conf->{"crowdsecMachineId"} $conf->{"crowdsecPassword"}
Truth table0%0/3
A and B
A= $conf->{"crowdsecMachineId"}B= $conf->{"crowdsecPassword"}
ABresult
0X0
100
111
1488 0 return ( 0,
1489 'Crowdsec Agent enabled without machine_id and password' );
1490 },
1491  
1492 # External menu URL must be a valid URL
1493 externalMenuUrl => sub {
1494 47 ▶ return 1 unless $conf->{externalMenu};
Subroutine __ANON__: called CC=3 SCAR=18.4
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"externalMenu"} 47 0 47
1495 return ( 0, 'External menu URL looks invalid' )
1496 0 ▶ unless $conf->{externalMenu} =~ m#^(\w+)://#;
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"externalMenu"} =~ m[^(\w+)://] 0 0 0
1497 0 return 1;
1498 },
1499 47 };
1500 }
1501  
1502 13 1;
« blib/lib/Lemonldap/NG/Manager.pm ↑ Summary blib/lib/Lemonldap/NG/Manager/Build/OpenApi.pm »