mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2026-06-23 02:38:09 +02:00
Merge remote-tracking branch 'origin/3/dev' into soupmod
This commit is contained in:
@@ -16,40 +16,35 @@
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% set soc_annotation_lines = [] %}
|
||||
{% set defaults_lines = [] %}
|
||||
{% for k in matched_integration_names %}
|
||||
{% do soc_annotation_lines.append(' ' ~ k ~ ': *dataStreamSettings') %}
|
||||
{% do defaults_lines.append(' ' ~ k ~ ':') %}
|
||||
{% set defaults_yaml = salt['slsutil.serialize']('yaml', ADDON_INTEGRATION_DEFAULTS[k], default_flow_style=False).strip() %}
|
||||
{% for line in defaults_yaml.splitlines() %}
|
||||
{% do defaults_lines.append(' ' ~ line) %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% set es_soc_annotations = '/opt/so/saltstack/default/salt/elasticsearch/soc_elasticsearch.yaml' %}
|
||||
{{ es_soc_annotations }}:
|
||||
file.serialize:
|
||||
- dataset:
|
||||
{% set data = salt['file.read'](es_soc_annotations) | load_yaml %}
|
||||
{% set es = data.get('elasticsearch', {}) %}
|
||||
{% set index_settings = es.get('index_settings', {}) %}
|
||||
{% set input = index_settings.get('so-logs', {}) %}
|
||||
{% for k in matched_integration_names %}
|
||||
{% do index_settings.update({k: input}) %}
|
||||
{% endfor %}
|
||||
{% for k in addon_integration_keys %}
|
||||
{% if k not in matched_integration_names and k in index_settings %}
|
||||
{% do index_settings.pop(k) %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{{ data }}
|
||||
manage_soc_annotations:
|
||||
file.blockreplace:
|
||||
- name: {{ es_soc_annotations }}
|
||||
- marker_start: ' # START managed SOC integration annotations'
|
||||
- marker_end: ' # END managed SOC integration annotations'
|
||||
- content: {{ soc_annotation_lines | join('\n') | tojson }}
|
||||
- insert_after_match: '^ # Managed SOC integration annotations are inserted below this line\.'
|
||||
- append_if_not_found: False
|
||||
- show_changes: True
|
||||
|
||||
{# Managed elasticsearch/defaults.yaml file for enabling 'Revert to default' via SOC UI for newly added config items #}
|
||||
{% set es_defaults = '/opt/so/saltstack/default/salt/elasticsearch/defaults.yaml' %}
|
||||
{{ es_defaults }}:
|
||||
file.serialize:
|
||||
- dataset:
|
||||
{% set data = salt['file.read'](es_defaults) | load_yaml %}
|
||||
{% set es = data.get('elasticsearch', {}) %}
|
||||
{% set index_settings = es.get('index_settings', {}) %}
|
||||
{% for k in matched_integration_names %}
|
||||
{% set input = ADDON_INTEGRATION_DEFAULTS[k] %}
|
||||
{% do index_settings.update({k: input})%}
|
||||
{% endfor %}
|
||||
{% for k in addon_integration_keys %}
|
||||
{% if k not in matched_integration_names and k in index_settings %}
|
||||
{% do index_settings.pop(k) %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{{ data }}
|
||||
{% endif %}
|
||||
file.blockreplace:
|
||||
- marker_start: ' # START managed SOC integration defaults'
|
||||
- marker_end: ' # END managed SOC integration defaults'
|
||||
- content: {{ defaults_lines | join('\n') | tojson }}
|
||||
- insert_after_match: '^ index_settings:$'
|
||||
- append_if_not_found: False
|
||||
- show_changes: True
|
||||
{% endif %}
|
||||
|
||||
@@ -16,6 +16,7 @@ POSTVERSION=$INSTALLEDVERSION
|
||||
INSTALLEDSALTVERSION=$(salt --versions-report | grep Salt: | awk '{print $2}')
|
||||
BATCHSIZE=5
|
||||
SOUP_LOG=/root/soup.log
|
||||
SOUP_DEBUG_LOG=/root/soup-debug.log
|
||||
WHATWOULDYOUSAYYAHDOHERE=soup
|
||||
whiptail_title='Security Onion UPdater'
|
||||
NOTIFYCUSTOMELASTICCONFIG=false
|
||||
@@ -34,6 +35,7 @@ if [[ -f /etc/salt/cloud.profiles.d/socloud.conf ]]; then
|
||||
fi
|
||||
# used to display messages to the user at the end of soup
|
||||
declare -a FINAL_MESSAGE_QUEUE=()
|
||||
SOUP_ERR_CONTEXT=
|
||||
|
||||
|
||||
check_err() {
|
||||
@@ -114,11 +116,52 @@ check_err() {
|
||||
echo "$err_msg"
|
||||
fi
|
||||
|
||||
if [[ -n $SOUP_ERR_CONTEXT ]]; then
|
||||
echo ""
|
||||
printf '%s\n' "$SOUP_ERR_CONTEXT"
|
||||
fi
|
||||
|
||||
echo "SOUP XTRACE debug log (if enabled) at $SOUP_DEBUG_LOG. Re-run soup with SOUP_DEBUG=1 to create $SOUP_DEBUG_LOG"
|
||||
|
||||
exit $exit_code
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
# Collect bash error context before passing off to check_err()
|
||||
on_err() {
|
||||
local exit_code=$?
|
||||
# Ignore failures in blocks that explicitly disabled errexit with `set +e`.
|
||||
[[ $- == *e* ]] || return $exit_code
|
||||
# turn off xtrace to prevent added noise in debug log
|
||||
set +x 2>/dev/null || true
|
||||
|
||||
# Use first error context, multiple errors can happen with command substitutions or nested functions. We just need context from the initial error.
|
||||
[[ -n $SOUP_ERR_CONTEXT ]] && return $exit_code
|
||||
|
||||
local cmd=$BASH_COMMAND
|
||||
local line=${BASH_LINENO[0]}
|
||||
local function=${FUNCNAME[1]:-main}
|
||||
local source=${BASH_SOURCE[1]##*/}
|
||||
local -a err_lines=(
|
||||
"ERROR on: ${cmd}"
|
||||
" source: ${source}:${line} in ${function}()"
|
||||
)
|
||||
local i caller_line caller_src caller_func
|
||||
|
||||
for ((i=2; i<${#FUNCNAME[@]}-1; i++)); do
|
||||
caller_line=${BASH_LINENO[$((i-1))]}
|
||||
[[ -n $caller_line && $caller_line -gt 0 ]] || continue
|
||||
caller_src=${BASH_SOURCE[$i]##*/}
|
||||
caller_func=${FUNCNAME[$i]:-main}
|
||||
err_lines+=(" called by: ${caller_src}:${caller_line} in ${caller_func}()")
|
||||
done
|
||||
|
||||
SOUP_ERR_CONTEXT=$(printf '%s\n' "${err_lines[@]}")
|
||||
|
||||
return $exit_code
|
||||
}
|
||||
|
||||
airgap_mounted() {
|
||||
# Let's see if the ISO is already mounted.
|
||||
if [[ -f /tmp/soagupdate/SecurityOnion/VERSION ]]; then
|
||||
@@ -762,9 +805,56 @@ bootstrap_so_soc_database() {
|
||||
echo "so_soc bootstrap complete."
|
||||
}
|
||||
|
||||
# Existing grids should keep ILM unless an admin explicitly opts in to DLM.
|
||||
pin_elasticsearch_data_retention_method() {
|
||||
local elasticsearch_file=/opt/so/saltstack/local/pillar/elasticsearch/soc_elasticsearch.sls
|
||||
mkdir -p "$(dirname "$elasticsearch_file")"
|
||||
[[ -f "$elasticsearch_file" ]] || touch "$elasticsearch_file"
|
||||
|
||||
if so-yaml.py get -r "$elasticsearch_file" elasticsearch.data_retention_method >/dev/null 2>&1; then
|
||||
echo "elasticsearch.data_retention_method already set; leaving as-is."
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "Pinning existing grid to ILM data retention."
|
||||
so-yaml.py add "$elasticsearch_file" elasticsearch.data_retention_method ILM
|
||||
chown socore:socore "$elasticsearch_file"
|
||||
}
|
||||
|
||||
# Addes auto_expand_replicas setting to .kibana_streams index template
|
||||
#
|
||||
# In Kibana 9.3.3 the auto_expand_replicas setting was not added to the .kibana_streams index template. Causing single node deployments to be stuck in yellow state (unable to assign replica). Here we update the template in place using the so_kibana system user (system managed index template) to include the auto_expand_replicas setting
|
||||
#
|
||||
# Reference: https://github.com/elastic/kibana/issues/263048
|
||||
kibana_backport_streams_index_template() {
|
||||
local current_template updated_template
|
||||
|
||||
set +e
|
||||
if ! current_template=$(so-elasticsearch-query "_index_template/.kibana_streams" --retry 3 --retry-delay 5 --fail); then
|
||||
echo "Index template .kibana_streams does not exist, skipping backport."
|
||||
return 0
|
||||
fi
|
||||
set -e
|
||||
|
||||
updated_template=$(jq '.index_templates[0].index_template | .template.settings += {"index.auto_expand_replicas": "0-1"} | del(.created_date_millis, .modified_date_millis)' <<< "$current_template")
|
||||
|
||||
if ! kibana_user_pass=$(/usr/sbin/so-yaml.py get -r /opt/so/saltstack/local/pillar/elasticsearch/auth.sls elasticsearch.auth.users.so_kibana_user.pass); then
|
||||
echo "Unable to retrieve so_kibana_user password, skipping .kibana_streams index template backport."
|
||||
return 0
|
||||
fi
|
||||
|
||||
if ! so-elasticsearch-query "_index_template/.kibana_streams" -XPUT -d "$updated_template" -u "so_kibana:$kibana_user_pass" --retry 3 --retry-delay 5 --fail; then
|
||||
echo "Unable to automatically update .kibana_streams index template"
|
||||
return 0
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
up_to_3.2.0() {
|
||||
fix_logstash_0013_lumberjack_pipeline_name
|
||||
|
||||
pin_elasticsearch_data_retention_method
|
||||
|
||||
INSTALLEDVERSION=3.2.0
|
||||
}
|
||||
|
||||
@@ -775,6 +865,8 @@ post_to_3.2.0() {
|
||||
echo "Regenerating Elastic Agent Installers"
|
||||
/sbin/so-elastic-agent-gen-installers
|
||||
|
||||
kibana_backport_streams_index_template
|
||||
|
||||
POSTVERSION=3.2.0
|
||||
}
|
||||
|
||||
@@ -1943,4 +2035,20 @@ EOF
|
||||
read -r input
|
||||
fi
|
||||
|
||||
main "$@" | tee -a $SOUP_LOG
|
||||
set -o errtrace
|
||||
trap on_err ERR
|
||||
|
||||
if [[ $SOUP_DEBUG == 1 ]]; then
|
||||
if [ -f $SOUP_DEBUG_LOG ]; then
|
||||
current_time=$(date +%Y%m%d.%H%M%S)
|
||||
mv $SOUP_DEBUG_LOG $SOUP_DEBUG_LOG.$INSTALLEDVERSION.$current_time
|
||||
fi
|
||||
exec {SOUP_XTRACE_FD}>>"$SOUP_DEBUG_LOG"
|
||||
export SOUP_XTRACE_FD
|
||||
BASH_XTRACEFD=$SOUP_XTRACE_FD
|
||||
PS4='+ [${BASH_SOURCE##*/}:${LINENO} ${FUNCNAME[0]:-main}()] | '
|
||||
set -x
|
||||
export SOUP_DEBUG
|
||||
fi
|
||||
|
||||
main "$@" 2>&1 | tee -a $SOUP_LOG
|
||||
|
||||
Reference in New Issue
Block a user