| 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
Condition0%0/3
ref $security_objects eq "ARRAY" and scalar @{$security_objects;} > 0
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
| |||||||||||||||||||||||||||||||||
| 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
Condition0%0/3
$sec->{"scope"} eq "w" or $sec->{"scope"} eq "u"
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"
| |||||||||||||||||||||||||||||||||
| 29 | 0 | $items{ $sec->{scope} } = $sec->{security_level}; | |||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||
| 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
MC/DC0%0/2
$p->{'class'} || $item
$p->{'class'}
$item
Truth table0%0/3
A || B
A= $p->{'class'}B= $item
| |||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | my $oid = $p->{object_id} || $p->{oid} || '0'; | ||||||||||||||||||||||||||||||
|
Condition0%0/5
$p->{'object_id'} || $p->{'oid'} || '0'
$p->{"object_id"} or $p->{"oid"}
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"}
| |||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||
| 53 | # If this is an object, modify lines accordingly | ||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | if ( ref $item and UNIVERSAL::can( $item, 'id' ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $item and UNIVERSAL::can($item, "id")
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")
| |||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | $oid = eval { $item->id } || '0'; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
eval {
do {
$item->id
}
} || '0'
MC/DC0%0/1
eval {
do {
$item->id
}
} || '0'
eval {
do {
$item->id
}
}
Truth table0%0/2
A
A= eval {
do {
$item->id
}
}
| |||||||||||||||||||||||||||||||||
| 57 | 0 | $obj_class = ref $item; | |||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||
| 59 | 0 | return ( $obj_class, $oid ); | |||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||
| 63 | 3 | 1; | |||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||
| 65 | __END__ | ||||||||||||||||||||||||||||||||