Skip to content

Commit

Permalink
Fix succes script and add test output in failure script
Browse files Browse the repository at this point in the history
  • Loading branch information
Enaraque committed Dec 18, 2024
1 parent 2cd15c9 commit 1aefd1b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .github/actions/passwords-tool/tests-stack-failure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ elif ! curl -s -u wazuh:wazuh -k -X POST "https://127.0.0.1:55000/security/user/
elif ! curl -s -u wazuuh:"${apiPass}" -k -X POST "https://127.0.0.1:55000/security/user/authenticate" | grep "Invalid credentials"; then
exit 1
elif ! curl -s -XGET https://127.0.0.1:9200/ -u admin:admin -k | grep "Unauthorized"; then
exit 1
curl -s -XGET https://127.0.0.1:9200/ -u admin:admin -k
elif ! curl -s -XGET https://127.0.0.1:9200/ -u adminnnn:"${adminPass}" -k | grep "Unauthorized"; then
exit 1
curl -s -XGET https://127.0.0.1:9200/ -u adminnnn:"${adminPass}" -k
fi
30 changes: 7 additions & 23 deletions .github/actions/passwords-tool/tests-stack-success.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,8 @@
#!/bin/bash

users=( admin kibanaserver kibanaro logstash readall snapshotrestore )
users=( admin anomalyadmin kibanaserver kibanaro logstash readall snapshotrestore )
api_users=( wazuh wazuh-wui )

echo '::group:: Change indexer password, password providing it.'

bash wazuh-passwords-tool.sh -u admin -p LN*X1v.VNtCZ5sESEtLfijPAd39LXGAI
if curl -s -XGET https://127.0.0.1:9200/ -u admin:LN*X1v.VNtCZ5sESEtLfijPAd39LXGAI -k -w %{http_code} | grep "401"; then
exit 1
fi
echo '::endgroup::'

echo '::group:: Change indexer password without providing it.'

indx_pass="$(bash wazuh-passwords-tool.sh -u admin | awk '/admin/{ print $NF }' | tr -d \' )"
if curl -s -XGET https://127.0.0.1:9200/ -u admin:"${indx_pass}" -k -w %{http_code} | grep "401"; then
exit 1
fi

echo '::endgroup::'

echo '::group:: Change all passwords except Wazuh API ones.'

mapfile -t pass < <(bash wazuh-passwords-tool.sh -a | grep 'The password for' | awk '{ print $NF }')
Expand All @@ -35,8 +18,9 @@ echo '::group:: Change all passwords.'

wazuh_pass="$(cat wazuh-install-files/wazuh-passwords.txt | awk "/username: 'wazuh'/{getline;print;}" | awk '{ print $2 }' | tr -d \' )"

mapfile -t passall < <(bash wazuh-passwords-tool.sh -a -au wazuh -ap "${wazuh_pass}" | grep 'The password for' | awk '{ print $NF }' )
passindexer=("${passall[@]:0:6}")
mapfile -t passall < <(bash wazuh-passwords-tool.sh -a -A -au wazuh -ap "${wazuh_pass}" | grep 'The password for' | awk '{ print $NF }' )

passindexer=("${passall[@]:0:7}")
passapi=("${passall[@]:(-2)}")

for i in "${!users[@]}"; do
Expand All @@ -55,7 +39,7 @@ echo '::endgroup::'

echo '::group:: Change single Wazuh API user.'

bash wazuh-passwords-tool.sh -au wazuh -ap "${passapi[0]}" -u wazuh -p BkJt92r*ndzN.CkCYWn?d7i5Z7EaUt63 -A
bash wazuh-passwords-tool.sh -A -au wazuh -ap "${passapi[0]}" -u wazuh -p BkJt92r*ndzN.CkCYWn?d7i5Z7EaUt63
if curl -s -w "%{http_code}" -u wazuh:BkJt92r*ndzN.CkCYWn?d7i5Z7EaUt63 -k -X POST "https://127.0.0.1:55000/security/user/authenticate" | grep "401"; then
exit 1
fi
Expand All @@ -72,8 +56,8 @@ done
echo '::endgroup::'

echo '::group:: Change all passwords from a file.'
mapfile -t passallf < <(bash wazuh-passwords-tool.sh -f wazuh-install-files/wazuh-passwords.txt -au wazuh -ap BkJt92r*ndzN.CkCYWn?d7i5Z7EaUt63 | grep 'The password for' | awk '{ print $NF }' )
passindexerf=("${passallf[@]:0:6}")
mapfile -t passallf < <(bash wazuh-passwords-tool.sh -f wazuh-install-files/wazuh-passwords.txt -A -au wazuh -ap BkJt92r*ndzN.CkCYWn?d7i5Z7EaUt63 | grep 'The password for' | awk '{ print $NF }' )
passindexerf=("${passallf[@]:0:7}")
passapif=("${passallf[@]:(-2)}")

for i in "${!users[@]}"; do
Expand Down
2 changes: 1 addition & 1 deletion passwords_tool/passwordsFunctions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# and/or modify it under the terms of the GNU General Public
# License (version 2) as published by the FSF - Free Software
# Foundation.

function passwords_changePassword() {

if [ -n "${changeall}" ]; then
Expand Down

0 comments on commit 1aefd1b

Please sign in to comment.