Remove /o regexp flag

merge-requests/413/merge
Maxime Besson 1 year ago
parent 8168704cdc
commit 4eaa1dc006
  1. 8
      lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf.pm
  2. 4
      lemonldap-ng-common/lib/Lemonldap/NG/Common/Safelib.pm
  3. 2
      lemonldap-ng-common/lib/Lemonldap/NG/Common/Util.pm
  4. 2
      lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Lib/CDA.pm
  5. 4
      lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Main/Run.pm
  6. 2
      lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Attributes.pm
  7. 2
      lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Build/Attributes.pm
  8. 4
      lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Cli.pm
  9. 20
      lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf/Parser.pm
  10. 2
      lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf/Tests.pm
  11. 2
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Auth/Slave.pm
  12. 2
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Auth/_WebForm.pm
  13. 2
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Lib/OpenIDConnect.pm
  14. 2
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/CDA.pm
  15. 2
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/CertificateResetByMail.pm
  16. 2
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/CheckUser.pm
  17. 2
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/ContextSwitching.pm
  18. 2
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/Impersonation.pm
  19. 2
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/MailPasswordReset.pm
  20. 2
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/Register.pm
  21. 2
      scripts/findAttr.pl

@ -533,7 +533,7 @@ sub logError {
sub _substPlaceHolders { sub _substPlaceHolders {
return $_[0] unless $_[0]; return $_[0] unless $_[0];
$_[0] =~ s/$PlaceHolderRe/$ENV{$1}/geo; $_[0] =~ s/$PlaceHolderRe/$ENV{$1}/ge;
return $_[0]; return $_[0];
} }
@ -544,7 +544,7 @@ sub replacePlaceholders {
my ( $self, $conf ) = @_; my ( $self, $conf ) = @_;
if ( ref $conf eq 'HASH' ) { if ( ref $conf eq 'HASH' ) {
foreach my $key ( keys %$conf ) { foreach my $key ( keys %$conf ) {
if ( $key =~ /$PlaceHolderRe/o ) { if ( $key =~ /$PlaceHolderRe/ ) {
my $val = $conf->{$key}; my $val = $conf->{$key};
delete $conf->{$key}; delete $conf->{$key};
my $nk = _substPlaceHolders($key); my $nk = _substPlaceHolders($key);
@ -554,7 +554,7 @@ sub replacePlaceholders {
if ( ref $conf->{$key} ) { if ( ref $conf->{$key} ) {
$self->replacePlaceholders( $conf->{$key} ); $self->replacePlaceholders( $conf->{$key} );
} }
elsif ( $conf->{$key} =~ /$PlaceHolderRe/o ) { elsif ( $conf->{$key} =~ /$PlaceHolderRe/ ) {
$conf->{$key} = _substPlaceHolders( $conf->{$key} ); $conf->{$key} = _substPlaceHolders( $conf->{$key} );
} }
} }
@ -564,7 +564,7 @@ sub replacePlaceholders {
if ( ref $conf->[$i] ) { if ( ref $conf->[$i] ) {
$self->replacePlaceholders( $conf->[$i] ); $self->replacePlaceholders( $conf->[$i] );
} }
elsif ( $conf->[$i] =~ /$PlaceHolderRe/o ) { elsif ( $conf->[$i] =~ /$PlaceHolderRe/ ) {
$conf->[$i] = _substPlaceHolders( $conf->[$i] ); $conf->[$i] = _substPlaceHolders( $conf->[$i] );
} }
} }

@ -325,8 +325,8 @@ sub isInNet6 {
sub varIsInUri { sub varIsInUri {
my ( $uri, $wanteduri, $attribute, $restricted ) = @_; my ( $uri, $wanteduri, $attribute, $restricted ) = @_;
return $restricted return $restricted
? $uri =~ /$wanteduri$attribute$/o ? $uri =~ /$wanteduri$attribute$/
: $uri =~ /$wanteduri$attribute/o; : $uri =~ /$wanteduri$attribute/;
} }
my $json = JSON::XS->new; my $json = JSON::XS->new;

@ -52,7 +52,7 @@ sub isHiddenAttr {
return return
$match $match
|| $hiddenAttributes{$attr} || $hiddenAttributes{$attr}
|| ( $regex && $attr =~ m#$regex#o ); || ( $regex && $attr =~ m#$regex# );
} }
sub getSameSite { sub getSameSite {

@ -11,7 +11,7 @@ sub run {
my $uri = $req->{env}->{REQUEST_URI}; my $uri = $req->{env}->{REQUEST_URI};
my $cn = $class->tsv->{cookieName}; my $cn = $class->tsv->{cookieName};
my ( $id, $session ); my ( $id, $session );
if ( $uri =~ m/[\?&;]${cn}cda=(\w+)/oi ) { if ( $uri =~ m/[\?&;]${cn}cda=(\w+)/i ) {
if ( $id = $class->fetchId($req) if ( $id = $class->fetchId($req)
and $session = $class->retrieveSession( $req, $id ) ) and $session = $class->retrieveSession( $req, $id ) )
{ {

@ -521,8 +521,8 @@ sub fetchId {
and not $class->_isHttps( $req, $vhost ) ); and not $class->_isHttps( $req, $vhost ) );
my $cn = $class->tsv->{cookieName}; my $cn = $class->tsv->{cookieName};
my $value = $lookForHttpCookie # Avoid prefix and bad cookie name (#2417) my $value = $lookForHttpCookie # Avoid prefix and bad cookie name (#2417)
? ( $t =~ /(?<![-.~])\b${cn}http=([^,; ]+)/o ? $1 : 0 ) ? ( $t =~ /(?<![-.~])\b${cn}http=([^,; ]+)/ ? $1 : 0 )
: ( $t =~ /(?<![-.~])\b$cn=([^,; ]+)/o ? $1 : 0 ); : ( $t =~ /(?<![-.~])\b$cn=([^,; ]+)/ ? $1 : 0 );
if ( $value && $lookForHttpCookie && $class->tsv->{securedCookie} == 3 ) { if ( $value && $lookForHttpCookie && $class->tsv->{securedCookie} == 3 ) {
$value = $class->tsv->{cipher}->decryptHex( $value, "http" ); $value = $class->tsv->{cipher}->decryptHex( $value, "http" );

@ -2023,7 +2023,7 @@ qr/^(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-
foreach my $s (@s) { foreach my $s (@s) {
return 0, qq[__badLdapUri__: "$s"] return 0, qq[__badLdapUri__: "$s"]
unless $s =~ unless $s =~
m[^(?:ldapi://[^/]*/?|\w[\w\-\.]*(?::\d{1,5})?|ldap(?:s|\+tls)?://\w[\w\-\.]*(?::\d{1,5})?/?.*)$]o; m[^(?:ldapi://[^/]*/?|\w[\w\-\.]*(?::\d{1,5})?|ldap(?:s|\+tls)?://\w[\w\-\.]*(?::\d{1,5})?/?.*)$];
} }
return 1; return 1;
}, },

@ -3847,7 +3847,7 @@ sub attributes {
my (@s) = split( /[\s,]+/, $l ); my (@s) = split( /[\s,]+/, $l );
foreach my $s (@s) { foreach my $s (@s) {
$s =~ $s =~
m{^(?:ldapi://[^/]*/?|\w[\w\-\.]*(?::\d{1,5})?|ldap(?:s|\+tls)?://\w[\w\-\.]*(?::\d{1,5})?/?.*)$}o m{^(?:ldapi://[^/]*/?|\w[\w\-\.]*(?::\d{1,5})?|ldap(?:s|\+tls)?://\w[\w\-\.]*(?::\d{1,5})?/?.*)$}
or return ( 0, "__badLdapUri__: \"$s\"" ); or return ( 0, "__badLdapUri__: \"$s\"" );
} }
return 1; return 1;

@ -217,7 +217,7 @@ sub addKey {
my $root = shift; my $root = shift;
my $newKey = shift; my $newKey = shift;
my $value = shift; my $value = shift;
unless ( $root =~ /$simpleHashKeys$/o or $root =~ /$sep/o ) { unless ( $root =~ /$simpleHashKeys$/ or $root =~ /$sep/ ) {
die "$root is not a simple hash. Aborting"; die "$root is not a simple hash. Aborting";
} }
$self->logger->info("CLI: Append key $root/$newKey $value"); $self->logger->info("CLI: Append key $root/$newKey $value");
@ -258,7 +258,7 @@ sub delKey {
while (@_) { while (@_) {
my $root = shift; my $root = shift;
my $key = shift; my $key = shift;
unless ( $root =~ /$simpleHashKeys$/o or $root =~ /$sep/o ) { unless ( $root =~ /$simpleHashKeys$/ or $root =~ /$sep/ ) {
die "$root is not a simple hash. Aborting"; die "$root is not a simple hash. Aborting";
} }
$self->logger->info("CLI: Remove key $root/$key"); $self->logger->info("CLI: Remove key $root/$key");

@ -197,7 +197,7 @@ sub _scanNodes {
################################## ##################################
# Root nodes # Root nodes
if ( $leaf->{id} =~ /^($specialNodeKeys)$/io ) { if ( $leaf->{id} =~ /^($specialNodeKeys)$/i ) {
hdebug("Root special node detected $leaf->{id}"); hdebug("Root special node detected $leaf->{id}");
# If node has not been opened # If node has not been opened
@ -229,7 +229,7 @@ sub _scanNodes {
} }
# 1st sublevel # 1st sublevel
elsif ( $leaf->{id} =~ /^($specialNodeKeys)\/([^\/]+)$/io ) { elsif ( $leaf->{id} =~ /^($specialNodeKeys)\/([^\/]+)$/i ) {
hdebug("Special node chield detected $leaf->{id}"); hdebug("Special node chield detected $leaf->{id}");
my ( $base, $host ) = ( $1, $2 ); my ( $base, $host ) = ( $1, $2 );
@ -248,7 +248,7 @@ sub _scanNodes {
# Other sub levels # Other sub levels
elsif ( $leaf->{id} =~ elsif ( $leaf->{id} =~
/^($specialNodeKeys)\/([^\/]+)\/([^\/]+)(?:\/(.*))?$/io ) /^($specialNodeKeys)\/([^\/]+)\/([^\/]+)(?:\/(.*))?$/i )
{ {
my ( $base, $key, $oldName, $target, $h ) = my ( $base, $key, $oldName, $target, $h ) =
( $1, $newNames{$2}, $2, $3, $4 ); ( $1, $newNames{$2}, $2, $3, $4 );
@ -324,7 +324,7 @@ sub _scanNodes {
} }
} }
} }
elsif ( $target =~ /^$virtualHostKeys$/o ) { elsif ( $target =~ /^$virtualHostKeys$/ ) {
$self->set( 'vhostOptions', [ $oldName, $key ], $self->set( 'vhostOptions', [ $oldName, $key ],
$target, $leaf->{data} ); $target, $leaf->{data} );
} }
@ -377,7 +377,7 @@ sub _scanNodes {
my $optKey = $&; my $optKey = $&;
hdebug(" $base sub key: $target"); hdebug(" $base sub key: $target");
if ( $target =~ if ( $target =~
/^(?:$samlIDPMetaDataNodeKeys|$samlSPMetaDataNodeKeys)/o /^(?:$samlIDPMetaDataNodeKeys|$samlSPMetaDataNodeKeys)/
) )
{ {
$self->set( $self->set(
@ -494,7 +494,7 @@ sub _scanNodes {
} }
} }
elsif ( $target =~ elsif ( $target =~
/^(?:$oidcOPMetaDataNodeKeys|$oidcRPMetaDataNodeKeys)/o /^(?:$oidcOPMetaDataNodeKeys|$oidcRPMetaDataNodeKeys)/
) )
{ {
$self->set( $self->set(
@ -573,7 +573,7 @@ sub _scanNodes {
} }
} }
elsif ( $target =~ elsif ( $target =~
/^(?:$casSrvMetaDataNodeKeys|$casAppMetaDataNodeKeys)/o /^(?:$casSrvMetaDataNodeKeys|$casAppMetaDataNodeKeys)/
) )
{ {
$self->set( $self->set(
@ -855,7 +855,7 @@ sub _scanNodes {
#################### ####################
# Other hash nodes # # Other hash nodes #
#################### ####################
elsif ( $leaf->{title} =~ /^$simpleHashKeys$/o elsif ( $leaf->{title} =~ /^$simpleHashKeys$/
and not $leaf->{title} eq 'applicationList' ) and not $leaf->{title} eq 'applicationList' )
{ {
hdebug( $leaf->{title} ); hdebug( $leaf->{title} );
@ -1226,7 +1226,7 @@ sub _unitTest {
} }
# Hash parameters # Hash parameters
if ( $key =~ /^$simpleHashKeys$/o ) { if ( $key =~ /^$simpleHashKeys$/ ) {
$conf->{$key} //= {}; $conf->{$key} //= {};
unless ( ref $conf->{$key} eq 'HASH' ) { unless ( ref $conf->{$key} eq 'HASH' ) {
push @{ $self->errors }, push @{ $self->errors },
@ -1239,7 +1239,7 @@ sub _unitTest {
#TODO #TODO
} }
if ( $key =~ /^(?:$simpleHashKeys|$doubleHashKeys)$/o if ( $key =~ /^(?:$simpleHashKeys|$doubleHashKeys)$/
or $attr->{type} =~ /Container$/ ) or $attr->{type} =~ /Container$/ )
{ {
$res = 0 $res = 0

@ -1072,7 +1072,7 @@ sub tests {
return ( 1, return ( 1,
'FindUser wildcard should be allowed by parameters control' ) 'FindUser wildcard should be allowed by parameters control' )
unless ( unless (
$conf->{findUserWildcard} =~ /$conf->{findUserControl}/o ); $conf->{findUserWildcard} =~ /$conf->{findUserControl}/ );
return 1; return 1;
}, },

@ -45,7 +45,7 @@ sub extractFormInfo {
} }
return PE_MALFORMEDUSER return PE_MALFORMEDUSER
unless ( $req->env->{$user_header} =~ /$self->{conf}->{userControl}/o ); unless ( $req->env->{$user_header} =~ /$self->{conf}->{userControl}/ );
$req->{user} = $req->env->{$user_header}; $req->{user} = $req->env->{$user_header};
return PE_OK; return PE_OK;

@ -60,7 +60,7 @@ sub extractFormInfo {
my ( $self, $req ) = @_; my ( $self, $req ) = @_;
if ( $req->param('user') ) { if ( $req->param('user') ) {
unless ( $req->param('user') =~ /$self->{conf}->{userControl}/o ) { unless ( $req->param('user') =~ /$self->{conf}->{userControl}/ ) {
$self->setSecurity($req); $self->setSecurity($req);
return PE_MALFORMEDUSER; return PE_MALFORMEDUSER;
} }

@ -699,7 +699,7 @@ sub getAccessTokenFromTokenEndpoint {
|| 'client_secret_post'; || 'client_secret_post';
unless ( $auth_method =~ unless ( $auth_method =~
/^(?:client_secret_(?:(?:pos|jw)t|basic)|private_key_jwt)$/o ) /^(?:client_secret_(?:(?:pos|jw)t|basic)|private_key_jwt)$/ )
{ {
$self->logger->error( $self->logger->error(
"Bad authentication method on token endpoint for OP $op"); "Bad authentication method on token endpoint for OP $op");

@ -25,7 +25,7 @@ sub changeUrldc {
my $urldc = $req->{urldc} || ''; my $urldc = $req->{urldc} || '';
if ( $req->id if ( $req->id
and $urldc =~ URIRE and $urldc =~ URIRE
and $3 !~ m@\Q$self->{conf}->{domain}\E$@oi and $3 !~ m@\Q$self->{conf}->{domain}\E$@i
and $self->p->isTrustedUrl($urldc) ) and $self->p->isTrustedUrl($urldc) )
{ {
my $ssl = $urldc =~ /^https/; my $ssl = $urldc =~ /^https/;

@ -193,7 +193,7 @@ sub _certificateReset {
} }
} }
unless ( $req->{user} =~ /$self->{conf}->{userControl}/o ) { unless ( $req->{user} =~ /$self->{conf}->{userControl}/ ) {
$self->setSecurity($req); $self->setSecurity($req);
return PE_MALFORMEDUSER; return PE_MALFORMEDUSER;
} }

@ -235,7 +235,7 @@ sub check {
my $url = $req->param('url') || ''; my $url = $req->param('url') || '';
my $user = $req->param('user') || ''; my $user = $req->param('user') || '';
if ( $user and $user !~ /$self->{conf}->{userControl}/o ) { if ( $user and $user !~ /$self->{conf}->{userControl}/ ) {
$user = ''; $user = '';
$attrs = {}; $attrs = {};
return $self->p->sendError( $req, 'Malformed user', 400 ) return $self->p->sendError( $req, 'Malformed user', 400 )

@ -169,7 +169,7 @@ sub run {
# ContextSwitching required -> Check user Id # ContextSwitching required -> Check user Id
if ( $spoofId && $spoofId ne $req->{user} ) { if ( $spoofId && $spoofId ne $req->{user} ) {
$self->logger->debug("Spoofed Id: $spoofId"); $self->logger->debug("Spoofed Id: $spoofId");
unless ( $spoofId =~ /$self->{conf}->{userControl}/o ) { unless ( $spoofId =~ /$self->{conf}->{userControl}/ ) {
$self->userLogger->warn('Malformed spoofed Id'); $self->userLogger->warn('Malformed spoofed Id');
$self->logger->debug( $self->logger->debug(
"ContextSwitching tried with spoofed Id: $spoofId"); "ContextSwitching tried with spoofed Id: $spoofId");

@ -102,7 +102,7 @@ sub run {
$self->logger->debug("No impersonation required") $self->logger->debug("No impersonation required")
if ( $spoofId eq $req->{user} ); if ( $spoofId eq $req->{user} );
unless ( $spoofId =~ /$self->{conf}->{userControl}/o ) { unless ( $spoofId =~ /$self->{conf}->{userControl}/ ) {
$self->userLogger->warn('Malformed spoofed Id'); $self->userLogger->warn('Malformed spoofed Id');
$self->logger->debug("Impersonation tried with spoofed Id: $spoofId"); $self->logger->debug("Impersonation tried with spoofed Id: $spoofId");
$spoofId = $req->{user}; $spoofId = $req->{user};

@ -264,7 +264,7 @@ sub _reset {
} }
} }
unless ( $req->{user} =~ /$self->{conf}->{userControl}/o ) { unless ( $req->{user} =~ /$self->{conf}->{userControl}/ ) {
$self->setSecurity($req); $self->setSecurity($req);
return PE_MALFORMEDUSER; return PE_MALFORMEDUSER;
} }

@ -189,7 +189,7 @@ sub _register {
# Check mail # Check mail
return PE_MALFORMEDUSER return PE_MALFORMEDUSER
unless ( $req->data->{registerInfo}->{mail} =~ unless ( $req->data->{registerInfo}->{mail} =~
m/$self->{conf}->{userControl}/o ); m/$self->{conf}->{userControl}/ );
# Search for user using UserDB module # Search for user using UserDB module
# If the user already exists, register is forbidden # If the user already exists, register is forbidden

@ -44,7 +44,7 @@ foreach my $module (qw(common handler manager portal)) {
last if ( /^__END__$/ and not $autoload ); last if ( /^__END__$/ and not $autoload );
if (/\$(?:self|args)->\{\s*(\w+)\s*\}/) { if (/\$(?:self|args)->\{\s*(\w+)\s*\}/) {
my $k = $1; my $k = $1;
unless ( $k =~ /^$IGNORE$/o ) { unless ( $k =~ /^$IGNORE$/ ) {
$attr->{$module}->{$1}++; $attr->{$module}->{$1}++;
$attrFile->{$module}->{$1}->{$file}++; $attrFile->{$module}->{$1}->{$file}++;
} }

Loading…
Cancel
Save