Merge branch 'harmonize_regex' into 'v2.0'

Harmonize regex

See merge request lemonldap-ng/lemonldap-ng!237
This commit is contained in:
Yadd 2021-11-16 22:25:23 +00:00
commit 15a96f2213
5 changed files with 34 additions and 8 deletions

View File

@ -26,7 +26,7 @@ has multiValuesSeparator => ( is => 'rw', isa => 'Maybe[Str]' );
has jail => ( is => 'rw' );
has error => ( is => 'rw' );
our $VERSION = '2.0.13';
our $VERSION = '2.0.14';
our @builtCustomFunctions;
## @imethod protected build_jail()
@ -45,7 +45,7 @@ sub build_jail {
$self->useSafeJail(1) unless defined $self->useSafeJail;
if ($require) {
foreach my $f ( split /[, ]+/, $require ) {
foreach my $f ( split /[,\s]+/, $require ) {
if ( $f =~ /^[\w\:]+$/ ) {
eval "require $f";
}
@ -63,7 +63,7 @@ sub build_jail {
if ($build) {
@builtCustomFunctions =
$self->customFunctions ? split( /\s+/, $self->customFunctions ) : ();
$self->customFunctions ? split( /[,\s]+/, $self->customFunctions ) : ();
foreach (@builtCustomFunctions) {
no warnings 'redefine';
$api->logger->debug("Custom function: $_");

View File

@ -785,6 +785,7 @@ t/99-Dont-load-Dumper.t
t/99-pod.t
t/AfterDataCustomPlugin.pm
t/CasHookPlugin.pm
t/Custom.pm
t/gpghome/key.asc
t/gpghome/openpgp-revocs.d/9482CEFB055809CBAFE6D71AAB2D5542891D1677.rev
t/gpghome/private-keys-v1.d/A076B0E7DB141A919271EE8B581CDFA8DA42F333.key

View File

@ -96,7 +96,7 @@ sub enabledPlugins {
# Check if custom plugins are required
if ( $conf->{customPlugins} ) {
$self->logger->debug( 'Custom plugins: ' . $conf->{customPlugins} );
push @res, grep ( /\w+/, split( /,\s*/, $conf->{customPlugins} ) );
push @res, grep ( /\w+/, split( /[,\s]+/, $conf->{customPlugins} ) );
}
# Impersonation overwrites req->step and pops 'afterData' EP.

View File

@ -9,10 +9,12 @@ require 't/test-lib.pm';
my $res;
my $client = LLNG::Manager::Test->new( {
ini => {
logLevel => 'error',
passwordDB => 'Demo',
impersonationRule => 1,
customPlugins => 't::AfterDataCustomPlugin',
logLevel => 'error',
passwordDB => 'Demo',
impersonationRule => 1,
customFunctions => 'My::accesToTrace My::return0,, My::return1 ',
customPlugins =>
't::AfterDataCustomPlugin t::CasHookPlugin,, t::OidcHookPlugin ',
customPluginsParams => { uid => 'rtyler' }
}
}

View File

@ -0,0 +1,23 @@
package My;
sub accessToTrace {
my $hash = shift;
my $custom = $hash->{custom};
my $req = $hash->{req};
my $vhost = $hash->{vhost};
my $params = $hash->{params};
my $session = $hash->{session};
return
"$custom alias $params->[0]_$params->[1]:$session->{groups} by using $session->{ $params->[2] }";
}
sub return0 {
return 0;
}
sub return1 {
return 1;
}
1;