SPOPS/Secure/Util.pm

filter: Statementstmt 38.8% 14 / 36 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 19 MC/DCmcdc 0.0% 0 / 11 Subroutinesub 66.6% 4 / 6 Podpod 0.0% 0 / 2 totaltotal 20.4% 18 / 88 CC 16 SCAR 42.7
CC
16
Cov
20%
parse_objects_into_hashref
110.0
find_class_and_oid
56.0
BEGIN
1.0
CRAP 71.2
« SPOPS/DBI.pm ↑ Summary SPOPS/Iterator/LDAP.pm »
1 package SPOPS::Secure::Util;
2  
3 # $Id: Util.pm,v 1.6 2004/06/02 00:48:24 lachoy Exp $
4  
5 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use Data::Dumper qw( Dumper );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Log::Log4perl qw( get_logger );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use SPOPS::Secure qw( :level :scope );
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 my $log = get_logger();
11  
12 # Setup a hashref where w/u => security_level and g points to a
13 # hashref where the key is the group_id value is the security level.
14  
15 0 ▶sub parse_objects_into_hashref {
Subroutine parse_objects_into_hashref: not called CC=10 SCAR=47.0
Pod undocumented
16 0 my ( $class, $security_objects ) = @_;
17  
18 0 my %items = ( SEC_SCOPE_WORLD() => undef,
19 SEC_SCOPE_USER() => undef,
20 SEC_SCOPE_GROUP() => {} );
21 0 ▶ unless ( ref $security_objects eq 'ARRAY'
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $security_objects eq "ARRAY" and scalar @{$security_objects;} > 0) 0 0 0
Condition0%0/3
ref $security_objects eq "ARRAY" and scalar @{$security_objects;} > 0
!ll&&!rl&&r
000
MC/DC0%0/2
ref $security_objects eq "ARRAY" and scalar @{$security_objects;} > 0
ref $security_objects eq "ARRAY" scalar @{$security_objects;} > 0
Truth table0%0/3
A and B
A= ref $security_objects eq "ARRAY"B= scalar @{$security_objects;} > 0
ABresult
0X0
100
111
22 0 and scalar @{ $security_objects } > 0 ) {
23 0 return undef;
24 }
25  
26 ITEM:
27 0 foreach my $sec ( @{ $security_objects } ) {
28 0 ▶ if ( $sec->{scope} eq SEC_SCOPE_WORLD || $sec->{scope} eq SEC_SCOPE_USER ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($sec->{'scope'} eq 'w' or $sec->{'scope'} eq 'u') { } 0 0 0
elsif ($sec->{'scope'} eq 'g') { } 0 0 0
Condition0%0/3
$sec->{"scope"} eq "w" or $sec->{"scope"} eq "u"
l!l&&r!l&&!r
000
MC/DC0%0/2
$sec->{"scope"} eq "w" or $sec->{"scope"} eq "u"
$sec->{"scope"} eq "w" $sec->{"scope"} eq "u"
Truth table0%0/3
A or B
A= $sec->{"scope"} eq "w"B= $sec->{"scope"} eq "u"
ABresult
1X1
011
000
29 0 $items{ $sec->{scope} } = $sec->{security_level};
30 0 ▶ $log->is_debug &&
Branch: 1 branch
BranchTrueFalseTotal
$log->is_debug and $log->debug(qq[Assign [$sec->{"security_level"}] to [$sec->{"scope"}]]) 0 0 0
31 $log->debug( "Assign [$sec->{security_level}] to [$sec->{scope}]" );
32 }
33 elsif ( $sec->{scope} eq SEC_SCOPE_GROUP ) {
34 0 $items{ $sec->{scope} }->{ $sec->{scope_id} } = $sec->{security_level};
35 0 ▶ $log->is_debug &&
Branch: 1 branch
BranchTrueFalseTotal
$log->is_debug and $log->debug(qq[Assign [$sec->{"security_level"}] to ], qq[[$sec->{"scope"}][$sec->{"scope_id"}]]) 0 0 0
36 $log->debug( "Assign [$sec->{security_level}] to ",
37 "[$sec->{scope}][$sec->{scope_id}]" );
38 }
39 }
40 $log->is_info &&
41 0 ▶ $log->info( "All security parsed: ", Dumper( \%items ) );;
Branch: 1 branch
BranchTrueFalseTotal
$log->is_info and $log->info("All security parsed: ", Dumper(\%items)) 0 0 0
42 0 return \%items;
43 }
44  
45 0 ▶sub find_class_and_oid {
Subroutine find_class_and_oid: not called CC=7 SCAR=40.3
Pod undocumented
46 0 my ( $class, $item, $p ) = @_;
47  
48 # First assume it's a class we're passed in to check
49  
50 0 ▶ my $obj_class = $p->{class} || $item;
Condition0%0/3
$p->{'class'} || $item
l!l&&r!l&&!r
000
MC/DC0%0/2
$p->{'class'} || $item
$p->{'class'} $item
Truth table0%0/3
A || B
A= $p->{'class'}B= $item
ABresult
1X1
011
000
51 0 ▶ my $oid = $p->{object_id} || $p->{oid} || '0';
Condition0%0/5
$p->{'object_id'} || $p->{'oid'} || '0'
l!l
00
$p->{"object_id"} or $p->{"oid"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$p->{'object_id'} || $p->{'oid'} || '0'
$p->{"object_id"} $p->{"oid"}
Truth table0%0/3
A or B
A= $p->{"object_id"}B= $p->{"oid"}
ABresult
1X1
011
000
52  
53 # If this is an object, modify lines accordingly
54  
55 0 ▶ if ( ref $item and UNIVERSAL::can( $item, 'id' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $item and UNIVERSAL::can($item, "id")) 0 0 0
Condition0%0/3
ref $item and UNIVERSAL::can($item, "id")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $item and UNIVERSAL::can($item, "id")
ref $item UNIVERSAL::can($item, "id")
Truth table0%0/3
A and B
A= ref $itemB= UNIVERSAL::can($item, "id")
ABresult
0X0
100
111
56 0 ▶ $oid = eval { $item->id } || '0';
Condition0%0/2
eval { do { $item->id } } || '0'
l!l
00
MC/DC0%0/1
eval { do { $item->id } } || '0'
eval { do { $item->id } }
Truth table0%0/2
A
A= eval { do { $item->id } }
Aresult
11
00
57 0 $obj_class = ref $item;
58 }
59 0 return ( $obj_class, $oid );
60 }
61  
62  
63 3 1;
64  
65 __END__
« SPOPS/DBI.pm ↑ Summary SPOPS/Iterator/LDAP.pm »