Commit 11857d9f authored by Xavier Guimard's avatar Xavier Guimard

make tidy

parent 81a364cc
......@@ -257,7 +257,7 @@ sub getApacheSession {
$self->error( $apacheSession->error );
return undef;
}
$self->logger->debug("Get session $id from Common::Session::REST") if ( $id );
$self->logger->debug("Get session $id from Common::Session::REST") if ($id);
return $apacheSession;
}
......
......@@ -107,7 +107,7 @@ sub statusInit {
exec $perl_exec, '-MLemonldap::NG::Handler::Lib::Status',
# Insert @INC in Perl path
map( {"-I$_"} @INC ),
map( { "-I$_" } @INC ),
# Command to launch
'-e', '&Lemonldap::NG::Handler::Lib::Status::run()',
......
......@@ -197,7 +197,7 @@ sub defaultValuesInit {
cookieExpiration cookieName customFunctions httpOnly
securedCookie timeout timeoutActivity
timeoutActivityInterval useRedirectOnError useRedirectOnForbidden
useSafeJail whatToTrace handlerInternalCache
useSafeJail whatToTrace handlerInternalCache
)
);
......
......@@ -21,7 +21,7 @@ ok(
cookieName => 'lemonldap',
securedCookie => 0,
https => 0,
userLogger => 'Lemonldap::NG::Common::Logger::Null',
userLogger => 'Lemonldap::NG::Common::Logger::Null',
}
),
'initialization'
......
......@@ -29,7 +29,7 @@ sub init {
cookieName => 'lemonldap',
securedCookie => 0,
https => 0,
logger => 'Lemonldap::NG::Common::Logger::Std',
logger => 'Lemonldap::NG::Common::Logger::Std',
%$prms
);
ok(
......
......@@ -8,17 +8,17 @@ sub types {
'array' => {
'test' => sub {
1;
}
}
},
'authParamsText' => {
'test' => sub {
1;
}
}
},
'blackWhiteList' => {
'test' => sub {
1;
}
}
},
'bool' => {
'msgFail' => '__notABoolean__',
......@@ -36,17 +36,17 @@ sub types {
split( /\n/, $@, 0 ) )
);
return $err ? ( 1, "__badExpression__: $err" ) : 1;
}
}
},
'catAndAppList' => {
'test' => sub {
1;
}
}
},
'file' => {
'test' => sub {
1;
}
}
},
'hostname' => {
'form' => 'text',
......@@ -80,48 +80,48 @@ qr/^(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-
if $_ =~ /exportedvars$/i and defined $conf->{$_}{$val};
}
return 1, "__unknownAttrOrMacro__: $val";
}
}
},
'longtext' => {
'test' => sub {
1;
}
}
},
'menuApp' => {
'test' => sub {
1;
}
}
},
'menuCat' => {
'test' => sub {
1;
}
}
},
'oidcmetadatajson' => {
'test' => sub {
1;
}
}
},
'oidcmetadatajwks' => {
'test' => sub {
1;
}
}
},
'oidcOPMetaDataNode' => {
'test' => sub {
1;
}
}
},
'oidcRPMetaDataNode' => {
'test' => sub {
1;
}
}
},
'password' => {
'msgFail' => '__malformedValue__',
'test' => sub {
1;
}
}
},
'pcre' => {
'form' => 'text',
......@@ -132,7 +132,7 @@ qr/^(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-
}
};
return $@ ? ( 0, "__badRegexp__: $@" ) : 1;
}
}
},
'PerlModule' => {
'form' => 'text',
......@@ -142,17 +142,17 @@ qr/^(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-
'portalskin' => {
'test' => sub {
1;
}
}
},
'portalskinbackground' => {
'test' => sub {
1;
}
}
},
'post' => {
'test' => sub {
1;
}
}
},
'RSAPrivateKey' => {
'test' => sub {
......@@ -160,7 +160,7 @@ qr/^(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-
m[^(?:(?:\-+\s*BEGIN\s+(?:RSA\s+)?PRIVATE\s+KEY\s*\-+\r?\n)?(?:Proc-Type:.*\r?\nDEK-Info:.*\r?\n[\r\n]*)?[a-zA-Z0-9/\+\r\n]+={0,2}(?:\r?\n\-+\s*END\s+(?:RSA\s+)PRIVATE\s+KEY\s*\-+)?[\r\n]*)?$]s
? 1
: ( 1, '__badPemEncoding__' );
}
}
},
'RSAPublicKey' => {
'test' => sub {
......@@ -168,7 +168,7 @@ m[^(?:(?:\-+\s*BEGIN\s+(?:RSA\s+)?PRIVATE\s+KEY\s*\-+\r?\n)?(?:Proc-Type:.*\r?\n
m[^(?:(?:\-+\s*BEGIN\s+PUBLIC\s+KEY\s*\-+\r?\n)?[a-zA-Z0-9/\+\r\n]+={0,2}(?:\r?\n\-+\s*END\s+PUBLIC\s+KEY\s*\-+)?[\r\n]*)?$]s
? 1
: ( 1, '__badPemEncoding__' );
}
}
},
'RSAPublicKeyOrCertificate' => {
'test' => sub {
......@@ -176,37 +176,37 @@ m[^(?:(?:\-+\s*BEGIN\s+PUBLIC\s+KEY\s*\-+\r?\n)?[a-zA-Z0-9/\+\r\n]+={0,2}(?:\r?\
m[^(?:(?:\-+\s*BEGIN\s+(?:PUBLIC\s+KEY|CERTIFICATE)\s*\-+\r?\n)?[a-zA-Z0-9/\+\r\n]+={0,2}(?:\r?\n\-+\s*END\s+(?:PUBLIC\s+KEY|CERTIFICATE)\s*\-+)?[\r\n]*)?$]s
? 1
: ( 1, '__badPemEncoding__' );
}
}
},
'rule' => {
'test' => sub {
1;
}
}
},
'samlAssertion' => {
'test' => sub {
1;
}
}
},
'samlAttribute' => {
'test' => sub {
1;
}
}
},
'samlIDPMetaDataNode' => {
'test' => sub {
1;
}
}
},
'samlService' => {
'test' => sub {
1;
}
}
},
'samlSPMetaDataNode' => {
'test' => sub {
1;
}
}
},
'select' => {
'test' => sub {
......@@ -216,19 +216,19 @@ m[^(?:(?:\-+\s*BEGIN\s+(?:PUBLIC\s+KEY|CERTIFICATE)\s*\-+\r?\n)?[a-zA-Z0-9/\+\r\
return $test
? 1
: ( 1, "Invalid value '$_[0]' for this select" );
}
}
},
'subContainer' => {
'keyTest' => qr/\w/,
'test' => sub {
1;
}
}
},
'text' => {
'msgFail' => '__malformedValue__',
'test' => sub {
1;
}
}
},
'trool' => {
'msgFail' => '__authorizedValues__: -1, 0, 1',
......@@ -1054,7 +1054,7 @@ qr/^(?:\*\.)?(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][
split( /\n/, $@, 0 ) )
);
return $err ? ( 1, "__badExpression__: $err" ) : 1;
}
}
},
'type' => 'keyTextContainer'
},
......@@ -1227,7 +1227,7 @@ qr/^(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-
and defined $conf->{$_}{$val};
}
return 1, "__unknownAttrOrMacro__: $val";
}
}
},
'type' => 'doubleHash'
},
......@@ -1510,7 +1510,7 @@ qr/^(?:\*\.)?(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][
split( /\n/, $@, 0 ) )
);
return $err ? ( 1, "__badExpression__: $err" ) : 1;
}
}
},
'type' => 'ruleContainer'
},
......
......@@ -1526,7 +1526,7 @@ sub attributes {
grep { $_ =~ /Undefined subroutine/ ? () : $_ }
split( /\n/, $@ ) );
return $err ? ( 1, "__badExpression__: $err" ) : (1);
}
}
},
documentation => 'Virtualhost headers',
flags => 'h',
......
......@@ -69,7 +69,9 @@ sub diff {
}
elsif ( exists $conf[1]->{$key} ) {
if ( $conf[0]->{$key} ne $conf[1]->{$key} ) {
$self->logger->debug( "Key $key has changed : " . $conf[0]->{$key} . " -> " . $conf[1]->{$key} );
$self->logger->debug( "Key $key has changed : "
. $conf[0]->{$key} . " -> "
. $conf[1]->{$key} );
$res[0]->{$key} = $conf[0]->{$key};
$res[1]->{$key} = $conf[1]->{$key};
}
......
......@@ -69,7 +69,7 @@ has confChanged => (
);
# Properties required during build
has refConf => ( is => 'ro', isa => 'HashRef', required => 1 );
has refConf => ( is => 'ro', isa => 'HashRef', required => 1 );
has req => ( is => 'ro', required => 1 );
has newConf => ( is => 'rw', isa => 'HashRef' );
has tree => ( is => 'rw', isa => 'ArrayRef' );
......@@ -158,7 +158,7 @@ sub _scanNodes {
hdebug("Looking to $name");
# subnode
my $subNodes = $leaf->{nodes} // $leaf->{_nodes};
my $subNodes = $leaf->{nodes} // $leaf->{_nodes};
my $subNodesCond = $leaf->{nodes_cond} // $leaf->{_nodes_cond};
##################################
......@@ -1060,15 +1060,15 @@ sub _unitTest {
or $attr->{type} =~ /Container$/ )
{
my $keyMsg = $attr->{keyMsgFail} // $type->{keyMsgFail};
my $msg = $attr->{msgFail} // $type->{msgFail};
my $msg = $attr->{msgFail} // $type->{msgFail};
$res = 0
unless (
$self->_execTest(
{
keyTest => $attr->{keyTest} // $type->{keyTest},
keyTest => $attr->{keyTest} // $type->{keyTest},
keyMsgFail => $attr->{keyMsgFail}
// $type->{keyMsgFail},
test => $attr->{test} // $type->{test},
test => $attr->{test} // $type->{test},
msgFail => $attr->{msgFail} // $type->{msgFail},
},
$conf->{$key},
......
......@@ -24,7 +24,7 @@ delete $forms{restore};
my ( @types, $attr, $tree, $ctrees );
ok( $tree = Lemonldap::NG::Manager::Build::Tree::tree(), 'Get tree' );
ok( $ctrees = Lemonldap::NG::Manager::Build::CTrees::cTrees(), 'Get cTrees' );
ok( $attr = Lemonldap::NG::Manager::Build::Attributes::attributes(),
ok( $attr = Lemonldap::NG::Manager::Build::Attributes::attributes(),
'Get attributes' );
$count += 4;
......
......@@ -49,7 +49,7 @@ my @notManagedAttributes = (
# Other ini-only prms
'configStorage', 'status', 'localStorageOptions', 'localStorage',
'max2FDevices', 'max2FDevicesNameLength', 'checkTime',
'max2FDevices', 'max2FDevicesNameLength', 'checkTime',
'mySessionAuthorizedRWKeys', 'handlerInternalCache'
);
......
......@@ -11,8 +11,8 @@ sub new {
eval $self->{p}->loadModule( $self->{conf}->{customAuth} );
($@)
? return $self->{p}->loadModule( $self->{conf}->{customAuth} )
: die 'Unable to load Auth module ' . $self->{conf}->{customAuth};
? return $self->{p}->loadModule( $self->{conf}->{customAuth} )
: die 'Unable to load Auth module ' . $self->{conf}->{customAuth};
}
sub getDisplayType {
......@@ -28,7 +28,7 @@ sub getDisplayType {
{
$self->logger->debug("CustomAuth $logo.png found");
return "logo";
};
}
return "standardform";
}
......
......@@ -16,7 +16,7 @@ extends 'Lemonldap::NG::Portal::Main::Auth',
# INTERFACE
has opList => ( is => 'rw', default => sub { [] } );
has opList => ( is => 'rw', default => sub { [] } );
has opNumber => ( is => 'rw', default => 0 );
has path => ( is => 'rw', default => 'oauth2' );
......
......@@ -793,7 +793,7 @@ sub extractFormInfo {
my $res = $self->p->deleteSession($req);
return (
$res eq PE_LOGOUT_OK ? PE_SENDRESPONSE : $res );
}
}
]
);
......
......@@ -63,8 +63,8 @@ sub setAuthSessionInfo {
}
sub getDisplayType {
my ( $self ) = @_;
return ( $self->{conf}->{sslByAjax} ? "sslform" : "logo") ;
my ($self) = @_;
return ( $self->{conf}->{sslByAjax} ? "sslform" : "logo" );
}
1;
......@@ -1540,7 +1540,8 @@ sub _convertOldFormatConsents {
# Update persistent session
$self->p->updatePersistentSession( $req,
{ _oidcConsents => to_json( \@oidcConsents ) } ) if $count;
{ _oidcConsents => to_json( \@oidcConsents ) } )
if $count;
return $count;
}
......
......@@ -39,12 +39,11 @@ sub init {
}
foreach my $name ( keys %{ $self->conf->{authChoiceModules} } ) {
my @mods
= split( /[;\|]/, $self->conf->{authChoiceModules}->{$name} );
my $module
= '::'
. [ 'Auth', 'UserDB', 'Password' ]->[$type] . '::'
. $mods[$type];
my @mods =
split( /[;\|]/, $self->conf->{authChoiceModules}->{$name} );
my $module = '::'
. [ 'Auth', 'UserDB', 'Password' ]->[$type] . '::'
. $mods[$type];
my $over;
if ( $mods[5] ) {
eval { $over = JSON::from_json( $mods[5] ) };
......@@ -56,12 +55,11 @@ sub init {
$self->modules->{$name} = $module;
$self->logger->debug(
[qw(Authentication User Password)]->[$type]
. " module $name selected" );
. " module $name selected" );
}
else {
$self->logger->error(
"Choice: unable to load $name, disabling it: "
. $self->error );
"Choice: unable to load $name, disabling it: " . $self->error );
$self->error('');
}
......@@ -77,8 +75,8 @@ sub init {
my $cond = $mods[4];
if ( defined $cond and $cond !~ /^$/ ) {
$self->logger->debug("Found rule $cond for $name");
$_choiceRules->{$name}
= $safe->reval("sub{my(\$env)=\@_;return ($cond)}");
$_choiceRules->{$name} =
$safe->reval("sub{my(\$env)=\@_;return ($cond)}");
if ($@) {
$self->logger->error("Bad condition $cond: $@");
return 0;
......@@ -86,7 +84,7 @@ sub init {
}
else {
$self->logger->debug("No rule for $name");
$_choiceRules->{$name} = sub {1};
$_choiceRules->{$name} = sub { 1 };
}
}
unless ( keys %{ $self->modules } ) {
......@@ -125,11 +123,11 @@ sub checkChoice {
unless ($name) {
# Check with other methods
$name
||= $req->param( $self->conf->{authChoiceParam} )
|| $req->userData->{_choice}
|| $req->sessionInfo->{_choice}
or return 0;
$name ||=
$req->param( $self->conf->{authChoiceParam} )
|| $req->userData->{_choice}
|| $req->sessionInfo->{_choice}
or return 0;
$self->logger->debug("Choice $name selected");
}
......@@ -186,16 +184,16 @@ sub _buildAuthLoop {
$name =~ s/\_/ /g;
# Find modules associated to authChoice
my ( $auth, $userDB, $passwordDB, $url, $condition )
= split( /[;\|]/, $self->conf->{authChoiceModules}->{$_} );
my ( $auth, $userDB, $passwordDB, $url, $condition ) =
split( /[;\|]/, $self->conf->{authChoiceModules}->{$_} );
unless ( $_choiceRules->{$_} ) {
$self->logger->error("$_ has no rule !!!");
$_choiceRules->{$_} = sub {1};
$_choiceRules->{$_} = sub { 1 };
}
unless ( $_choiceRules->{$_}->( $req->env ) ) {
$self->logger->debug(
"Condition returns false, authentication choice $_ will not be displayed"
"Condition returns false, authentication choice $_ will not be displayed"
);
}
else {
......@@ -204,19 +202,19 @@ sub _buildAuthLoop {
# Default URL
$req->{cspFormAction} ||= '';
if (defined $url
and not $self->checkXSSAttack(
'URI', $req->env->{'REQUEST_URI'}
)
and $url
=~ q%^(https?://)?[^\s/.?#$].[^\s]+$% # URL must be well formatted
)
if (
defined $url
and not $self->checkXSSAttack( 'URI',
$req->env->{'REQUEST_URI'} )
and $url =~
q%^(https?://)?[^\s/.?#$].[^\s]+$% # URL must be well formatted
)
{
#$url .= $req->env->{'REQUEST_URI'};
# Avoid append same URL
$req->{cspFormAction} .= " $url"
unless $req->{cspFormAction} =~ qr%\b$url\b%;
unless $req->{cspFormAction} =~ qr%\b$url\b%;
}
else {
$url .= '#';
......@@ -234,15 +232,15 @@ sub _buildAuthLoop {
# Get displayType for this module
no strict 'refs';
my $displayType = "Lemonldap::NG::Portal::Auth::${auth}"
->can('getDisplayType')->( $self, $req );
->can('getDisplayType')->( $self, $req );
$self->logger->debug(
"Display type $displayType for module $auth");
$optionsLoop->{$displayType} = 1;
my $logo = $_;
if ( $auth eq 'Custom' ) {
$logo
= ( $self->{conf}->{customAuth} =~ /::(\w+)$/ )[0];
$logo =
( $self->{conf}->{customAuth} =~ /::(\w+)$/ )[0];
}
# If displayType is logo, check if key.png is available
......
......@@ -28,17 +28,16 @@ has stylesheet => (
builder => sub {
my $self = $_[0];
my $xslt = XML::LibXSLT->new();
my $styleFile
= ( $self->conf->{notificationXSLTfile}
and -e $self->conf->{notificationXSLTfile} )
? $self->conf->{notificationXSLTfile}
: $self->conf->{templatesDir} . '/common/notification.xsl';
my $styleFile =
( $self->conf->{notificationXSLTfile}
and -e $self->conf->{notificationXSLTfile} )
? $self->conf->{notificationXSLTfile}
: $self->conf->{templatesDir} . '/common/notification.xsl';
unless ( -e $styleFile ) {
$self->{logger}->error("$styleFile not found, aborting");
die "$styleFile not found";
}
return $xslt->parse_stylesheet(
$self->parser->parse_file($styleFile) );
return $xslt->parse_stylesheet( $self->parser->parse_file($styleFile) );
}
);
......@@ -66,11 +65,11 @@ sub checkForNotifications {
foreach my $file ( values %$notifs ) {
my $xml = $self->parser->parse_string($file);
my $j = 0; #Notifications count
LOOP: foreach my $notif (
LOOP: foreach my $notif (
eval {
$xml->documentElement->getElementsByTagName('notification');
}
)
)
{
# Get the reference
......@@ -97,11 +96,10 @@ sub checkForNotifications {
$self->logger->debug("Get condition $condition");
$condition = $self->p->HANDLER->substitute($condition);
unless ( $condition
= $self->p->HANDLER->buildSub($condition) )
unless ( $condition = $self->p->HANDLER->buildSub($condition) )
{
$self->logger->error( 'Notification condition error: '
. $self->p->HANDLER->tsv->{jail}->error );
. $self->p->HANDLER->tsv->{jail}->error );
$notif->unbindNode();
next LOOP;
}
......@@ -152,11 +150,11 @@ sub getNotifBack {
return $self->p->sendError( $req, 'No cookie found', 401 );
}
$id = $self->p->HANDLER->tsv->{cipher}->decrypt($id)
or return $self->sendError( $req, 'Unable to decrypt', 500 );
or return $self->sendError( $req, 'Unable to decrypt', 500 );
# Verify that session exists
$req->userData( $self->p->HANDLER->retrieveSession( $req, $id ) )
or return $self->sendError( $req, 'Unknown session', 401 );
or return $self->sendError( $req, 'Unknown session', 401 );
# Restore data
$self->p->importHandlerData($req);
......@@ -173,8 +171,7 @@ sub getNotifBack {
if (s/^reference//) {
$refs->{$v} = $_;
}
elsif ( s/^check// and /^(\d+x\d+)x(\d+)$/ and $v eq 'accepted' )
{
elsif ( s/^check// and /^(\d+x\d+)x(\d+)$/ and $v eq 'accepted' ) {
push @{ $checks->{$1} }, $2;
}
}
......@@ -185,7 +182,7 @@ sub getNotifBack {
my $fileResult = 1;
my $xml = $self->parser->parse_string($file);
# Get pending notifications and verify that they have been accepted
# Get pending notifications and verify that they have been accepted
foreach my $notif (
$xml->documentElement->getElementsByTagName('notification') )
{
......@@ -223,11 +220,10 @@ sub getNotifBack {
$self->p->updatePersistentSession( $req,
{ "notification_$reference" => time() } );
$self->logger->debug(
"Notification $reference registered in persistent session"
);
"Notification $reference registered in persistent session");
}
# Notifications accepted for this file, delete it unless it's a wildcard
# Notifications accepted for this file, delete it unless it's a wildcard
if ( $fileResult and exists $forUser->{$fileName} ) {
$self->logger->debug("Notification file deleted");
$self->notifObject->delete($fileName);
......
......@@ -174,7 +174,7 @@ sub send_mail {
foreach ( keys %cid ) {
$message->attach(
Type => "image/" . ( $cid{$_} =~ m/\.(\w+)/ )[0],
Id => $_,
Id => $_,
Path => $self->p->{templateDir} . "/" . $cid{$_},
);
}
......
......@@ -113,7 +113,7 @@ sub display {
&& $req->data->{login},
ASK_LOGINS => $req->param('checkLogins') || 0,
CONFIRMKEY => $self->stamp(),
LIST => $req->data->{list} || [],
LIST => $req->data->{list} || [],
REMEMBER => $req->data->{confirmRemember},
(