Add condition when trying to change API user credentials #3005
+6
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
When attempting to change an api user's password without specifying the
--api
option, the script does not indicate that this argument must be passed to make the change effective. This may result in the user thinking that the password has been changed correctly even though it has not.Changing passwords fails without feedback from it
If I try to change the password of the wazuh user in an AIO environment, the message that appears is the one corresponding to the change of the wazuh indexer passwords. As there are no passwords to change, it does nothing, it just displays the message.
If I try to get the token with the "old" password, I can get it, showing that the password has not changed.
Description
The aim of this PR is to add a new validation in the options passed to the
wazuh-passwords-tool.sh
script where, if the user tries to change the passwords without specifying the--api
option, the output will be the script help.To make it clearer to the user that the
--api
option is required when changing API user passwords, a line has been added to the help of each option saying that the-A|--api
option is required in order to change the password correctly.Tests
Try to change the user API password without the --api option
Now if I try to change the password without specifying the
--api
option, the help pops up where it now appears in both the-au
and-ap
options that-A|--api
is required in order to change the password.Try to change the user API password with the --api option
Specifying the
--api
option now works normally.