mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2026-06-21 01:44:16 +02:00
Replace duplicate random generator with common function
This commit is contained in:
@@ -135,3 +135,8 @@ fail() {
|
||||
echo "Exiting."
|
||||
exit 1
|
||||
}
|
||||
|
||||
get_random_value() {
|
||||
length=${1:-20}
|
||||
head -c 5000 /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $length | head -n 1
|
||||
}
|
||||
@@ -212,8 +212,8 @@ rc1_to_rc2() {
|
||||
sed -i "/^global:/a \\$line" /opt/so/saltstack/local/pillar/global.sls;
|
||||
|
||||
# Adding play values to the global.sls
|
||||
local HIVEPLAYSECRET=$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 20 | head -n 1)
|
||||
local CORTEXPLAYSECRET=$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 20 | head -n 1)
|
||||
local HIVEPLAYSECRET=$(get_random_value)
|
||||
local CORTEXPLAYSECRET=$(get_random_value)
|
||||
sed -i "/^global:/a \\ hiveplaysecret: $HIVEPLAYSECRET" /opt/so/saltstack/local/pillar/global.sls;
|
||||
sed -i "/^global:/a \\ cortexplaysecret: $CORTEXPLAYSECRET" /opt/so/saltstack/local/pillar/global.sls;
|
||||
|
||||
@@ -275,8 +275,8 @@ rc3_to_2.3.0() {
|
||||
|
||||
sed -i 's/playbook:/playbook_db:/' /opt/so/saltstack/local/pillar/secrets.sls
|
||||
{
|
||||
echo "playbook_admin: $(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 20 | head -n 1)"
|
||||
echo "playbook_automation: $(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 20 | head -n 1)"
|
||||
echo "playbook_admin: $(get_random_value)"
|
||||
echo "playbook_automation: $(get_random_value)"
|
||||
} >> /opt/so/saltstack/local/pillar/secrets.sls
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#!/bin/bash
|
||||
# {%- set MYSQLPASS = salt['pillar.get']('secrets:mysql', None) -%}
|
||||
# {%- set admin_pass = salt['pillar.get']('secrets:playbook_admin', None) %}
|
||||
. /usr/sbin/so-common
|
||||
|
||||
default_salt_dir=/opt/so/saltstack/default
|
||||
|
||||
# Generate salt + hash for admin user
|
||||
admin_salt=$(tr -dc "a-zA-Z0-9" < /dev/urandom | fold -w 32 | head -n 1)
|
||||
admin_salt=$(get_random_value 32)
|
||||
admin_stage1_hash=$(echo -n '{{ admin_pass }}' | sha1sum | awk '{print $1}')
|
||||
admin_hash=$(echo -n "${admin_salt}${admin_stage1_hash}" | sha1sum | awk '{print $1}')
|
||||
sed -i "s/ADMIN_HASH/${admin_hash}/g" $default_salt_dir/salt/playbook/files/playbook_db_init.sql
|
||||
|
||||
Reference in New Issue
Block a user