mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2026-05-06 19:38:51 +02:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 652ac5d61f | |||
| f888a2ba6b | |||
| 8a1ee02335 | |||
| 192f6cfe13 | |||
| 5bca81d833 | |||
| 1c6574c694 | |||
| bc64f1431d | |||
| 2203037ce7 | |||
| 3a4b7b50de |
@@ -51,6 +51,16 @@ so-elastic-fleet-package-registry:
|
|||||||
- {{ ULIMIT.name }}={{ ULIMIT.soft }}:{{ ULIMIT.hard }}
|
- {{ ULIMIT.name }}={{ ULIMIT.soft }}:{{ ULIMIT.hard }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
wait_for_so-elastic-fleet-package-registry:
|
||||||
|
http.wait_for_successful_query:
|
||||||
|
- name: "http://localhost:8080/health"
|
||||||
|
- status: 200
|
||||||
|
- wait_for: 300
|
||||||
|
- request_interval: 15
|
||||||
|
- require:
|
||||||
|
- docker_container: so-elastic-fleet-package-registry
|
||||||
|
|
||||||
delete_so-elastic-fleet-package-registry_so-status.disabled:
|
delete_so-elastic-fleet-package-registry_so-status.disabled:
|
||||||
file.uncomment:
|
file.uncomment:
|
||||||
- name: /opt/so/conf/so-status/so-status.conf
|
- name: /opt/so/conf/so-status/so-status.conf
|
||||||
|
|||||||
@@ -3,7 +3,14 @@
|
|||||||
# https://securityonion.net/license; you may not use this file except in compliance with the
|
# https://securityonion.net/license; you may not use this file except in compliance with the
|
||||||
# Elastic License 2.0.
|
# Elastic License 2.0.
|
||||||
|
|
||||||
{% set hypervisor = pillar.minion_id %}
|
{% set hypervisor = pillar.get('minion_id', '') %}
|
||||||
|
|
||||||
|
{% if not hypervisor|regex_match('^([A-Za-z0-9._-]{1,253})$') %}
|
||||||
|
{% do salt.log.error('delete_hypervisor_orch: refusing unsafe minion_id=' ~ hypervisor) %}
|
||||||
|
delete_hypervisor_invalid_minion_id:
|
||||||
|
test.fail_without_changes:
|
||||||
|
- name: delete_hypervisor_invalid_minion_id
|
||||||
|
{% else %}
|
||||||
|
|
||||||
ensure_hypervisor_mine_deleted:
|
ensure_hypervisor_mine_deleted:
|
||||||
salt.function:
|
salt.function:
|
||||||
@@ -20,3 +27,5 @@ update_salt_cloud_profile:
|
|||||||
- sls:
|
- sls:
|
||||||
- salt.cloud.config
|
- salt.cloud.config
|
||||||
- concurrent: True
|
- concurrent: True
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|||||||
@@ -12,7 +12,14 @@
|
|||||||
{% if 'vrt' in salt['pillar.get']('features', []) %}
|
{% if 'vrt' in salt['pillar.get']('features', []) %}
|
||||||
|
|
||||||
{% do salt.log.debug('vm_pillar_clean_orch: Running') %}
|
{% do salt.log.debug('vm_pillar_clean_orch: Running') %}
|
||||||
{% set vm_name = pillar.get('vm_name') %}
|
{% set vm_name = pillar.get('vm_name', '') %}
|
||||||
|
|
||||||
|
{% if not vm_name|regex_match('^([A-Za-z0-9._-]{1,253})$') %}
|
||||||
|
{% do salt.log.error('vm_pillar_clean_orch: refusing unsafe vm_name=' ~ vm_name) %}
|
||||||
|
vm_pillar_clean_invalid_name:
|
||||||
|
test.fail_without_changes:
|
||||||
|
- name: vm_pillar_clean_invalid_name
|
||||||
|
{% else %}
|
||||||
|
|
||||||
delete_adv_{{ vm_name }}_pillar:
|
delete_adv_{{ vm_name }}_pillar:
|
||||||
module.run:
|
module.run:
|
||||||
@@ -24,6 +31,8 @@ delete_{{ vm_name }}_pillar:
|
|||||||
- file.remove:
|
- file.remove:
|
||||||
- path: /opt/so/saltstack/local/pillar/minions/{{ vm_name }}.sls
|
- path: /opt/so/saltstack/local/pillar/minions/{{ vm_name }}.sls
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
||||||
{% do salt.log.error(
|
{% do salt.log.error(
|
||||||
|
|||||||
@@ -3,12 +3,15 @@
|
|||||||
# https://securityonion.net/license; you may not use this file except in compliance with the
|
# https://securityonion.net/license; you may not use this file except in compliance with the
|
||||||
# Elastic License 2.0.
|
# Elastic License 2.0.
|
||||||
|
|
||||||
{% if data['id'].endswith('_hypervisor') and data['result'] == True %}
|
{% set hid = data['id'] %}
|
||||||
|
{% if hid|regex_match('^([A-Za-z0-9._-]{1,253})$')
|
||||||
|
and hid.endswith('_hypervisor')
|
||||||
|
and data['result'] == True %}
|
||||||
|
|
||||||
{% if data['act'] == 'accept' %}
|
{% if data['act'] == 'accept' %}
|
||||||
check_and_trigger:
|
check_and_trigger:
|
||||||
runner.setup_hypervisor.setup_environment:
|
runner.setup_hypervisor.setup_environment:
|
||||||
- minion_id: {{ data['id'] }}
|
- minion_id: {{ hid }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if data['act'] == 'delete' %}
|
{% if data['act'] == 'delete' %}
|
||||||
@@ -17,8 +20,7 @@ delete_hypervisor:
|
|||||||
- args:
|
- args:
|
||||||
- mods: orch.delete_hypervisor
|
- mods: orch.delete_hypervisor
|
||||||
- pillar:
|
- pillar:
|
||||||
minion_id: {{ data['id'] }}
|
minion_id: {{ hid }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!py
|
#!py
|
||||||
|
|
||||||
# Copyright Security Onion Solutions LLC and/or licensed to Security Onion Solutions LLC under one
|
# Copyright Security Onion Solutions LLC and/or licensed to Security Onion Solutions LLC under one
|
||||||
# or more contributor license agreements. Licensed under the Elastic License 2.0 as shown at
|
# or more contributor license agreements. Licensed under the Elastic License 2.0 as shown at
|
||||||
# https://securityonion.net/license; you may not use this file except in compliance with the
|
# https://securityonion.net/license; you may not use this file except in compliance with the
|
||||||
# Elastic License 2.0.
|
# Elastic License 2.0.
|
||||||
|
|
||||||
@@ -9,30 +9,42 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import pwd
|
import pwd
|
||||||
import grp
|
import grp
|
||||||
|
import re
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
PILLAR_ROOT = '/opt/so/saltstack/local/pillar/minions/'
|
||||||
|
_VMNAME_RE = re.compile(r'^[A-Za-z0-9._-]{1,253}$')
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
vm_name = data['kwargs']['name']
|
vm_name = data.get('kwargs', {}).get('name', '')
|
||||||
logging.error("createEmptyPillar reactor: vm_name: %s" % vm_name)
|
if not _VMNAME_RE.match(str(vm_name)):
|
||||||
pillar_root = '/opt/so/saltstack/local/pillar/minions/'
|
log.error("createEmptyPillar reactor: refusing unsafe vm_name=%r", vm_name)
|
||||||
|
return {}
|
||||||
|
|
||||||
|
log.info("createEmptyPillar reactor: vm_name: %s", vm_name)
|
||||||
pillar_files = ['adv_' + vm_name + '.sls', vm_name + '.sls']
|
pillar_files = ['adv_' + vm_name + '.sls', vm_name + '.sls']
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Get socore user and group IDs
|
|
||||||
socore_uid = pwd.getpwnam('socore').pw_uid
|
socore_uid = pwd.getpwnam('socore').pw_uid
|
||||||
socore_gid = grp.getgrnam('socore').gr_gid
|
socore_gid = grp.getgrnam('socore').gr_gid
|
||||||
|
pillar_root_real = os.path.realpath(PILLAR_ROOT)
|
||||||
|
|
||||||
for f in pillar_files:
|
for f in pillar_files:
|
||||||
full_path = pillar_root + f
|
full_path = os.path.join(PILLAR_ROOT, f)
|
||||||
if not os.path.exists(full_path):
|
resolved = os.path.realpath(full_path)
|
||||||
# Create empty file
|
if os.path.dirname(resolved) != pillar_root_real:
|
||||||
os.mknod(full_path)
|
log.error("createEmptyPillar reactor: refusing path outside pillar root: %s", resolved)
|
||||||
# Set ownership to socore:socore
|
continue
|
||||||
os.chown(full_path, socore_uid, socore_gid)
|
if os.path.exists(resolved):
|
||||||
# Set mode to 644 (rw-r--r--)
|
continue
|
||||||
os.chmod(full_path, 0o640)
|
os.mknod(resolved)
|
||||||
logging.error("createEmptyPillar reactor: created %s with socore:socore ownership and mode 644" % f)
|
os.chown(resolved, socore_uid, socore_gid)
|
||||||
|
os.chmod(resolved, 0o640)
|
||||||
|
log.info("createEmptyPillar reactor: created %s with socore:socore ownership and mode 0640", f)
|
||||||
|
|
||||||
except (KeyError, OSError) as e:
|
except (KeyError, OSError) as e:
|
||||||
logging.error("createEmptyPillar reactor: Error setting ownership/permissions: %s" % str(e))
|
log.error("createEmptyPillar reactor: Error setting ownership/permissions: %s", e)
|
||||||
|
|
||||||
return {}
|
return {}
|
||||||
|
|||||||
+33
-11
@@ -1,18 +1,40 @@
|
|||||||
|
#!py
|
||||||
|
|
||||||
# Copyright Security Onion Solutions LLC and/or licensed to Security Onion Solutions LLC under one
|
# Copyright Security Onion Solutions LLC and/or licensed to Security Onion Solutions LLC under one
|
||||||
# or more contributor license agreements. Licensed under the Elastic License 2.0 as shown at
|
# or more contributor license agreements. Licensed under the Elastic License 2.0 as shown at
|
||||||
# https://securityonion.net/license; you may not use this file except in compliance with the
|
# https://securityonion.net/license; you may not use this file except in compliance with the
|
||||||
# Elastic License 2.0.
|
# Elastic License 2.0.
|
||||||
|
|
||||||
remove_key:
|
import logging
|
||||||
wheel.key.delete:
|
import re
|
||||||
- args:
|
|
||||||
- match: {{ data['name'] }}
|
|
||||||
|
|
||||||
{{ data['name'] }}_pillar_clean:
|
log = logging.getLogger(__name__)
|
||||||
runner.state.orchestrate:
|
|
||||||
- args:
|
|
||||||
- mods: orch.vm_pillar_clean
|
|
||||||
- pillar:
|
|
||||||
vm_name: {{ data['name'] }}
|
|
||||||
|
|
||||||
{% do salt.log.info('deleteKey reactor: deleted minion key: %s' % data['name']) %}
|
_VMNAME_RE = re.compile(r'^[A-Za-z0-9._-]{1,253}$')
|
||||||
|
|
||||||
|
|
||||||
|
def run():
|
||||||
|
name = data.get('name', '')
|
||||||
|
if not _VMNAME_RE.match(str(name)):
|
||||||
|
log.error("deleteKey reactor: refusing unsafe name=%r", name)
|
||||||
|
return {}
|
||||||
|
|
||||||
|
log.info("deleteKey reactor: deleted minion key: %s", name)
|
||||||
|
|
||||||
|
return {
|
||||||
|
'remove_key': {
|
||||||
|
'wheel.key.delete': [
|
||||||
|
{'args': [
|
||||||
|
{'match': name},
|
||||||
|
]},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
'%s_pillar_clean' % name: {
|
||||||
|
'runner.state.orchestrate': [
|
||||||
|
{'args': [
|
||||||
|
{'mods': 'orch.vm_pillar_clean'},
|
||||||
|
{'pillar': {'vm_name': name}},
|
||||||
|
]},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|||||||
@@ -1701,6 +1701,24 @@ remove_package() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ensure_pyyaml() {
|
||||||
|
title "Ensuring python3-pyyaml is installed"
|
||||||
|
if rpm -q python3-pyyaml >/dev/null 2>&1; then
|
||||||
|
info "python3-pyyaml already installed"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
info "python3-pyyaml not found, attempting to install"
|
||||||
|
set -o pipefail
|
||||||
|
dnf -y install python3-pyyaml 2>&1 | tee -a "$setup_log"
|
||||||
|
local result=$?
|
||||||
|
set +o pipefail
|
||||||
|
if [[ $result -ne 0 ]] || ! rpm -q python3-pyyaml >/dev/null 2>&1; then
|
||||||
|
error "Failed to install python3-pyyaml (exit=$result)"
|
||||||
|
fail_setup
|
||||||
|
fi
|
||||||
|
info "python3-pyyaml installed successfully"
|
||||||
|
}
|
||||||
|
|
||||||
# When updating the salt version, also update the version in securityonion-builds/images/iso-task/Dockerfile and salt/salt/master.defaults.yaml and salt/salt/minion.defaults.yaml
|
# When updating the salt version, also update the version in securityonion-builds/images/iso-task/Dockerfile and salt/salt/master.defaults.yaml and salt/salt/minion.defaults.yaml
|
||||||
# CAUTION! SALT VERSION UDDATES - READ BELOW
|
# CAUTION! SALT VERSION UDDATES - READ BELOW
|
||||||
# When updating the salt version, also update the version in:
|
# When updating the salt version, also update the version in:
|
||||||
|
|||||||
@@ -66,6 +66,9 @@ set_timezone
|
|||||||
# Let's see what OS we are dealing with here
|
# Let's see what OS we are dealing with here
|
||||||
detect_os
|
detect_os
|
||||||
|
|
||||||
|
# Ensure python3-pyyaml is available before any code that may need so-yaml/PyYAML
|
||||||
|
ensure_pyyaml
|
||||||
|
|
||||||
|
|
||||||
# Check to see if this is the setup type of "desktop".
|
# Check to see if this is the setup type of "desktop".
|
||||||
is_desktop=
|
is_desktop=
|
||||||
|
|||||||
Reference in New Issue
Block a user