centreon / centreon-plugins

Collection of standard plugins to discover and gather cloud-to-edge metrics and status across your whole IT infrastructure.
https://www.centreon.com
Apache License 2.0
310 stars 274 forks source link

[database::redis::plugin] --custommode="perlmod" does not allow authentication with a username #5212

Open Lanxor opened 3 weeks ago

Lanxor commented 3 weeks ago

Hello, for security reasons, the anonymous user of our Redis applications has been disabled. And we don't want to use --custommode="cli" from the plugins.

It turns out that the ability to specify a user in the plugin has not been implemented: https://github.com/centreon/centreon-plugins/blob/develop/src/database/redis/custom/perlmod.pm#L96

I was able to test a local modification that works based on the Redis library (https://metacpan.org/pod/Redis#auth)

# src/database/redis/custom/perlmod.pm
     sub check_options {
         ...
-        if ($self->{username} ne '') {
-            $self->{output}->add_option_msg(short_msg => 'Unsupported --username option.');
-            $self->{output}->option_exit();
-        }
         ...
    }
# src/database/redis/custom/perlmod.pm
     sub get_info {
         ...
         if ($self->{password} ne '') {
-            $redis->auth($self->{password});
+            $redis->auth($self->{username}, $self->{password});
         }
         ...
     }

Is it possible to implement this modification? Others modifications are needed to comply with developer guidelines ?

lucie-dubrunfaut commented 6 days ago

Hello :)

Would you be able to propose a Pull request instead (easier to understand the changes you are proposing) so that we can then adapt and, if necessary add missing things directly on the proposal? :)

Lanxor commented 3 days ago

Ok thank you @lucie-dubrunfaut. I just created the pull request #5255 with the changes. I'm not sure if I missed anything, but I followed the instructions.