-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Installation assistant Wazuh API default password change #1548
Changes from 14 commits
fd27e47
b6866c9
171d256
9f4155d
2822e6b
362e7f7
f769633
06b1918
888ecfe
59e05f3
424c75c
a8b3617
3ede3ff
342ed72
c563e90
6297b26
c77d1d9
c4362c2
bb0d889
9e22306
6fe1ccb
409e15a
d3e7a30
b07aba8
f59e46c
39d59da
ae865dc
2e046bc
f04bb3f
a501b5e
83e3500
86a2a61
5a99ea0
eecad12
c910060
1ccfd05
91d0ba5
bcd7dc3
9bf4c86
57ec492
ca5a7b5
c8c49c9
b4c8c78
ac09720
d1488db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ source "${base_dir}"/bach.sh | |
@setup-test { | ||
@ignore common_logger | ||
k_certs_path="/etc/wazuh-dashboard/certs/" | ||
wazuh_version="4.3.1" | ||
wazuh_version="4.3.0" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update version |
||
elasticsearch_oss_version="7.10.2" | ||
wazuh_kibana_plugin_revision="1" | ||
repobaseurl="https://packages.wazuh.com/4.x" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
|
||
## Package vars | ||
readonly wazuh_major="4.3" | ||
readonly wazuh_version="4.3.1" | ||
readonly wazuh_version="4.3.0" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update version |
||
readonly wazuh_revision_deb="1" | ||
readonly wazuh_revision_rpm="1" | ||
readonly indexer_revision_deb="1" | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -177,6 +177,7 @@ function passwords_generatePasswordFile() { | |||||
echo " password: ${passwords[${i}]}" >> "${gen_file}" | ||||||
echo "" >> "${gen_file}" | ||||||
done | ||||||
passwords_createPasswordAPI | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
|
||||||
} | ||||||
|
||||||
|
@@ -217,7 +218,7 @@ function passwords_readAdmincerts() { | |||||
} | ||||||
|
||||||
function passwords_readFileUsers() { | ||||||
filecorrect=$(grep -Ev '^#|^\s*$' "${p_file}" | grep -Pzc '\A(\s*username:[ \t]+\w+\s*password:[ \t]+[A-Za-z0-9_\-]+\s*)+\Z') | ||||||
filecorrect=$(grep -Ev '^#|^\s*$' "${p_file}" | grep -Pzc '\A(\s*username:[ \t]+\w+\s*password:[ \t]+[A-Za-z0-9.*+?()[{\|]+\s*)+\Z') | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
if [[ "${filecorrect}" -ne 1 ]]; then | ||||||
common_logger -e "The password file doesn't have a correct format. | ||||||
|
||||||
|
@@ -380,3 +381,62 @@ function passwords_runSecurityAdmin() { | |||||
fi | ||||||
|
||||||
} | ||||||
|
||||||
function passwords_genereatePasswordSpecialChar() { | ||||||
|
||||||
choose() { echo ${1:RANDOM%${#1}:1} $RANDOM; } | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [shellcheck (suggestion)] reported by reviewdog 🐶
Suggested change
|
||||||
pass="$({ choose '.*+?()[{\|' | ||||||
choose '0123456789' | ||||||
choose 'abcdefghijklmnopqrstuvwxyz' | ||||||
choose 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' | ||||||
for i in $( seq 1 $(( 20 + RANDOM % 8 )) ) | ||||||
do | ||||||
choose '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' | ||||||
done | ||||||
} | sort -R | awk '{printf "%s",$1}')" | ||||||
|
||||||
} | ||||||
|
||||||
function passwords_createPasswordAPI() { | ||||||
|
||||||
passwords_genereatePasswordSpecialChar | ||||||
password_wazuh="${pass}" | ||||||
passwords_genereatePasswordSpecialChar | ||||||
password_wazuh_wui="${pass}" | ||||||
|
||||||
echo "# New password for wazuh API" >> "${gen_file}" | ||||||
echo " username: wazuh" >> "${gen_file}" | ||||||
echo " password: $password_wazuh" >> "${gen_file}" | ||||||
echo "" >> "${gen_file}" | ||||||
echo "# New password for wazuh-wui API" >> "${gen_file}" | ||||||
echo " username: wazuh_wui" >> "${gen_file}" | ||||||
echo " password: $password_wazuh_wui" >> "${gen_file}" | ||||||
echo "" >> "${gen_file}" | ||||||
|
||||||
} | ||||||
|
||||||
function passwords_changePasswordAPI() { | ||||||
alberpilot marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
password_wazuh=$(< /tmp/wazuh-install-files/passwords.wazuh awk '$2 == "wazuh" {getline;print;}' | awk -F': ' '{print $2}') | ||||||
password_wazuh_wui=$(< /tmp/wazuh-install-files/passwords.wazuh awk '$2 == "wazuh_wui" {getline;print;}' | awk -F': ' '{print $2}') | ||||||
WAZUH_PASS='{"password":"'"$password_wazuh"'"}' | ||||||
WAZUH_WUI_PASS='{"password":"'"$password_wazuh_wui"'"}' | ||||||
|
||||||
TOKEN=$(curl -s -u wazuh:wazuh -k -X GET "https://localhost:55000/security/user/authenticate?raw=true") | ||||||
eval 'curl -s -k -X PUT -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -d "$WAZUH_PASS" "https://localhost:55000/security/users/1" -o /dev/null' | ||||||
|
||||||
TOKEN_WUI=$(curl -s -u wazuh-wui:wazuh-wui -k -X GET "https://localhost:55000/security/user/authenticate?raw=true") | ||||||
eval 'curl -s -k -X PUT -H "Authorization: Bearer $TOKEN_WUI" -H "Content-Type: application/json" -d "$WAZUH_WUI_PASS" "https://localhost:55000/security/users/2" -o /dev/null' | ||||||
|
||||||
} | ||||||
|
||||||
function passwords_updateDashborad_WUI_Password() { | ||||||
|
||||||
if [ -f "/usr/share/wazuh-dashboard/data/wazuh/config/wazuh.yml" ]; then | ||||||
password_wazuh_wui=$(< /tmp/wazuh-install-files/passwords.wazuh awk '$2 == "wazuh_wui" {getline;print;}' | awk -F': ' '{print $2}') | ||||||
eval 'sed -i "s|password: wazuh-wui|password: ${password_wazuh_wui}|g" /usr/share/wazuh-dashboard/data/wazuh/config/wazuh.yml' | ||||||
else | ||||||
echo "ERROR: File /usr/share/wazuh-dashboard/data/wazuh/config/wazuh.yml does not exist" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use logger |
||||||
fi | ||||||
|
||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be used the variable
user
a function parameter?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 39d59da