mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2026-12-02 08:36:08 +01:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
803158485a | ||
|
|
8cf44ac306 | ||
|
|
5d956de587 | ||
|
|
aba2f5ea43 | ||
|
|
65816ae717 |
No files matched your search
@@ -41,7 +41,6 @@
|
|||||||
'logstash.node': 'logstash.stack_monitoring.node',
|
'logstash.node': 'logstash.stack_monitoring.node',
|
||||||
'logstash.node_cel': 'logstash.node',
|
'logstash.node_cel': 'logstash.node',
|
||||||
'logstash.node_stats': 'logstash.stack_monitoring.node_stats',
|
'logstash.node_stats': 'logstash.stack_monitoring.node_stats',
|
||||||
'mqtt.traces': 'traces-mqtt.traces',
|
|
||||||
'synthetics.browser': 'synthetics-browser',
|
'synthetics.browser': 'synthetics-browser',
|
||||||
'synthetics.browser_network': 'synthetics-browser.network',
|
'synthetics.browser_network': 'synthetics-browser.network',
|
||||||
'synthetics.browser_screenshot': 'synthetics-browser.screenshot',
|
'synthetics.browser_screenshot': 'synthetics-browser.screenshot',
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
elasticsearch:
|
elasticsearch:
|
||||||
enabled: false
|
enabled: false
|
||||||
esheap: '600m'
|
esheap: '600m'
|
||||||
version: 9.4.10
|
version: 9.4.8
|
||||||
index_clean: true
|
index_clean: true
|
||||||
data_retention_method: DLM
|
data_retention_method: DLM
|
||||||
vm:
|
vm:
|
||||||
|
|||||||
@@ -11,8 +11,7 @@
|
|||||||
{% set DATA_RETENTION_METHOD = ELASTICSEARCHMERGED.data_retention_method %}
|
{% set DATA_RETENTION_METHOD = ELASTICSEARCHMERGED.data_retention_method %}
|
||||||
|
|
||||||
{% set PILLAR_GLOBAL_OVERRIDES = {} %}
|
{% set PILLAR_GLOBAL_OVERRIDES = {} %}
|
||||||
{# merge into a copy: pillar.get returns a live reference and this map pops/updates ES_INDEX_PILLAR #}
|
{% set ES_INDEX_PILLAR = salt['pillar.get']('elasticsearch:index_settings', {}) %}
|
||||||
{% set ES_INDEX_PILLAR = salt['defaults.merge'](salt['pillar.get']('elasticsearch:index_settings', {}), {}, in_place=False) %}
|
|
||||||
{% if ES_INDEX_PILLAR.global_overrides is defined %}
|
{% if ES_INDEX_PILLAR.global_overrides is defined %}
|
||||||
{% set PILLAR_GLOBAL_OVERRIDES = ES_INDEX_PILLAR.pop('global_overrides') %}
|
{% set PILLAR_GLOBAL_OVERRIDES = ES_INDEX_PILLAR.pop('global_overrides') %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -140,24 +140,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"dynamic_templates": [
|
|
||||||
{
|
|
||||||
"event_data_scalars_as_keyword": {
|
|
||||||
"path_match": "event_data.*",
|
|
||||||
"match_mapping_type": [
|
|
||||||
"long",
|
|
||||||
"double",
|
|
||||||
"boolean"
|
|
||||||
],
|
|
||||||
"mapping": {
|
|
||||||
"type": "keyword",
|
|
||||||
"ignore_above": 1024
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"description": "Fields written by the ElastAlert SecurityOnionESAlerter to logs-detections.alerts-so"
|
"description": "Fields written by the ElastAlert SecurityOnionESAlerter to logs-detections.alerts-so"
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ influxdb:
|
|||||||
flux-log-enabled: false
|
flux-log-enabled: false
|
||||||
hardening-enabled: true
|
hardening-enabled: true
|
||||||
http-bind-address: :8086
|
http-bind-address: :8086
|
||||||
http-idle-timeout: 0s
|
http-idle-timeout: 0
|
||||||
http-read-header-timeout: 10s
|
http-read-header-timeout: 10s
|
||||||
http-read-timeout: 0s
|
http-read-timeout: 0
|
||||||
http-write-timeout: 0s
|
http-write-timeout: 0
|
||||||
influxql-max-select-buckets: 0
|
influxql-max-select-buckets: 0
|
||||||
influxql-max-select-point: 0
|
influxql-max-select-point: 0
|
||||||
influxql-max-select-series: 0
|
influxql-max-select-series: 0
|
||||||
|
|||||||
@@ -42,17 +42,17 @@ influxdb:
|
|||||||
advanced: True
|
advanced: True
|
||||||
helpLink: influxdb
|
helpLink: influxdb
|
||||||
http-idle-timeout:
|
http-idle-timeout:
|
||||||
description: Keep-alive timeout while a connection waits for new requests. A value of 0s is the same as no timeout enforced.
|
description: Keep-alive timeout while a connection waits for new requests. A value of 0 is the same as no timeout enforced.
|
||||||
global: True
|
global: True
|
||||||
advanced: True
|
advanced: True
|
||||||
helpLink: influxdb
|
helpLink: influxdb
|
||||||
http-read-header-timeout:
|
http-read-header-timeout:
|
||||||
description: The duration to wait for a request header before closing the connection. A value of 0s is the same as no timeout enforced.
|
description: The duration to wait for a request header before closing the connection. A value of 0 is the same as no timeout enforced.
|
||||||
global: True
|
global: True
|
||||||
advanced: True
|
advanced: True
|
||||||
helpLink: influxdb
|
helpLink: influxdb
|
||||||
http-read-timeout:
|
http-read-timeout:
|
||||||
description: The duration to wait for the request to be fully read before closing the connection. A value of 0s is the same as no timeout enforced.
|
description: The duration to wait for the request to be fully read before closing the connection. A value of 0 is the same as no timeout enforced.
|
||||||
global: True
|
global: True
|
||||||
advanced: True
|
advanced: True
|
||||||
helpLink: influxdb
|
helpLink: influxdb
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ lookup_org_id_with_wait() {
|
|||||||
wait=10
|
wait=10
|
||||||
while [[ $attempts -lt $max_attempts ]]; do
|
while [[ $attempts -lt $max_attempts ]]; do
|
||||||
response=$(request orgs?org=Security+Onion)
|
response=$(request orgs?org=Security+Onion)
|
||||||
oid=$(echo "$response" | jq -r ".orgs[]? | select(.name == \"Security Onion\").id")
|
oid=$(echo "$response" | jq -r ".orgs[] | select(.name == \"Security Onion\").id")
|
||||||
if [[ -z $oid ]]; then
|
if [[ -z $oid ]]; then
|
||||||
attempts=$((attempts+1))
|
attempts=$((attempts+1))
|
||||||
log "Server does not appear to be running or fully initialized - will try again in $wait seconds ($attempts / $max_attempts)"
|
log "Server does not appear to be running or fully initialized - will try again in $wait seconds ($attempts / $max_attempts)"
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ kibana:
|
|||||||
- default
|
- default
|
||||||
- file
|
- file
|
||||||
migrations:
|
migrations:
|
||||||
discardCorruptObjects: "9.4.10"
|
discardCorruptObjects: "9.4.8"
|
||||||
telemetry:
|
telemetry:
|
||||||
enabled: False
|
enabled: False
|
||||||
xpack:
|
xpack:
|
||||||
|
|||||||
@@ -16,7 +16,9 @@ For each intent file under /opt/so/state/push_pending/*.json whose last_touch
|
|||||||
is older than debounce_seconds, this script:
|
is older than debounce_seconds, this script:
|
||||||
* concatenates the actions lists from every ready intent
|
* concatenates the actions lists from every ready intent
|
||||||
* dedupes by (state or __highstate__, tgt, tgt_type)
|
* dedupes by (state or __highstate__, tgt, tgt_type)
|
||||||
|
* narrows each target to minions that have completed a highstate
|
||||||
* drops actions whose target matches no accepted minion (e.g. a role with no nodes yet)
|
* drops actions whose target matches no accepted minion (e.g. a role with no nodes yet)
|
||||||
|
* holds everything for a later pass while salt-master has only just started
|
||||||
* dispatches a single `salt-run state.orchestrate orch.push_batch --async`
|
* dispatches a single `salt-run state.orchestrate orch.push_batch --async`
|
||||||
with the deduped actions list passed as pillar kwargs
|
with the deduped actions list passed as pillar kwargs
|
||||||
* deletes the contributed intent files on successful dispatch
|
* deletes the contributed intent files on successful dispatch
|
||||||
@@ -46,11 +48,20 @@ PENDING_DIR = '/opt/so/state/push_pending'
|
|||||||
LOCK_FILE = os.path.join(PENDING_DIR, '.lock')
|
LOCK_FILE = os.path.join(PENDING_DIR, '.lock')
|
||||||
LOG_FILE = '/opt/so/log/salt/so-push-drainer.log'
|
LOG_FILE = '/opt/so/log/salt/so-push-drainer.log'
|
||||||
MASTER_CONFIG = '/etc/salt/master'
|
MASTER_CONFIG = '/etc/salt/master'
|
||||||
|
MASTER_PIDFILE = '/var/run/salt-master.pid'
|
||||||
|
|
||||||
|
# Minions rejoin a restarted master's publisher up to ~22s after it returns (zmq reconnect interval
|
||||||
|
# plus jitter, each up to recon_default + recon_max) and a job published before then reaches nobody.
|
||||||
|
# Doubled to allow for a slow master start.
|
||||||
|
MASTER_SETTLE_SECONDS = 45
|
||||||
|
|
||||||
DISPATCHED_DIR = '/opt/so/state/push_dispatched'
|
DISPATCHED_DIR = '/opt/so/state/push_dispatched'
|
||||||
|
|
||||||
HIGHSTATE_SENTINEL = '__highstate__'
|
HIGHSTATE_SENTINEL = '__highstate__'
|
||||||
|
|
||||||
|
# Grain written by setup and removed by salt.lasthighstate at the end of the node's first highstate.
|
||||||
|
PENDING_GRAIN = 'first_highstate_pending'
|
||||||
|
|
||||||
RESULT_CHECK_DELAY = 30
|
RESULT_CHECK_DELAY = 30
|
||||||
RESULT_RECHECK_MAX = 300
|
RESULT_RECHECK_MAX = 300
|
||||||
RESULT_MAX_AGE = 7200
|
RESULT_MAX_AGE = 7200
|
||||||
@@ -60,6 +71,8 @@ TEXT_LIMIT = 500
|
|||||||
# Lead-in salt puts on the comment of an orchestration step that raised.
|
# Lead-in salt puts on the comment of an orchestration step that raised.
|
||||||
STEP_RAISED = 'An exception occurred in this state:'
|
STEP_RAISED = 'An exception occurred in this state:'
|
||||||
|
|
||||||
|
NO_RETURN = 'no return received'
|
||||||
|
|
||||||
# salt-run --async reports the jid only in a log line (stderr by default).
|
# salt-run --async reports the jid only in a log line (stderr by default).
|
||||||
JID_RE = re.compile(r'salt/run/(\d{20})')
|
JID_RE = re.compile(r'salt/run/(\d{20})')
|
||||||
|
|
||||||
@@ -117,9 +130,18 @@ def _dedupe_actions(actions):
|
|||||||
return deduped
|
return deduped
|
||||||
|
|
||||||
|
|
||||||
|
def _skip_pending(action):
|
||||||
|
"""Narrows a compound target to minions that have completed a highstate. A newly accepted node matches
|
||||||
|
its role's targets before orch.deploy_newnode has highstated it, and a single state fails there."""
|
||||||
|
if action.get('tgt_type', 'compound') != 'compound':
|
||||||
|
return action
|
||||||
|
return dict(action, tgt='( {} ) and not G@{}:True'.format(action.get('tgt'), PENDING_GRAIN))
|
||||||
|
|
||||||
|
|
||||||
def _targeted(actions, log):
|
def _targeted(actions, log):
|
||||||
"""Drops actions whose target matches no accepted minion (e.g. a role with no nodes yet), which
|
"""Drops actions whose target matches no accepted minion (e.g. a role with no nodes yet), which
|
||||||
the orchestration would otherwise report as failed with 'No minions responded'."""
|
the orchestration would otherwise report as failed with 'No minions responded'."""
|
||||||
|
actions = [_skip_pending(action) for action in actions]
|
||||||
try:
|
try:
|
||||||
ckminions = salt.utils.minions.CkMinions(salt.config.master_config(MASTER_CONFIG))
|
ckminions = salt.utils.minions.CkMinions(salt.config.master_config(MASTER_CONFIG))
|
||||||
except Exception:
|
except Exception:
|
||||||
@@ -140,6 +162,14 @@ def _targeted(actions, log):
|
|||||||
return targeted
|
return targeted
|
||||||
|
|
||||||
|
|
||||||
|
def _master_settling(now):
|
||||||
|
try:
|
||||||
|
age = now - os.path.getmtime(MASTER_PIDFILE)
|
||||||
|
except OSError:
|
||||||
|
return False
|
||||||
|
return 0 <= age < MASTER_SETTLE_SECONDS
|
||||||
|
|
||||||
|
|
||||||
def _dispatch(actions, log):
|
def _dispatch(actions, log):
|
||||||
pillar_arg = json.dumps({'actions': actions})
|
pillar_arg = json.dumps({'actions': actions})
|
||||||
cmd = [
|
cmd = [
|
||||||
@@ -221,6 +251,10 @@ def _lookup_jid(jid, log):
|
|||||||
|
|
||||||
|
|
||||||
def _minion_failure(minion_ret):
|
def _minion_failure(minion_ret):
|
||||||
|
# What salt.state records for a minion it stopped waiting on: no reply to a saltutil.find_job
|
||||||
|
# poll within gather_job_timeout, though the state run may still be queued or running.
|
||||||
|
if minion_ret == {}:
|
||||||
|
return NO_RETURN
|
||||||
if isinstance(minion_ret, dict):
|
if isinstance(minion_ret, dict):
|
||||||
return '; '.join(
|
return '; '.join(
|
||||||
'{}: {}'.format(state.get('__id__', state_key), _trim(state.get('comment', '')))
|
'{}: {}'.format(state.get('__id__', state_key), _trim(state.get('comment', '')))
|
||||||
@@ -283,11 +317,21 @@ def _failed_steps(ret):
|
|||||||
return steps
|
return steps
|
||||||
|
|
||||||
|
|
||||||
|
def _lost_track(step):
|
||||||
|
changes = step.get('changes')
|
||||||
|
minion_rets = changes.get('ret') if isinstance(changes, dict) else None
|
||||||
|
if not isinstance(minion_rets, dict):
|
||||||
|
return False
|
||||||
|
failed = [text for text in map(_minion_failure, minion_rets.values()) if text]
|
||||||
|
return bool(failed) and all(text == NO_RETURN for text in failed)
|
||||||
|
|
||||||
|
|
||||||
def _result_unknown(ret):
|
def _result_unknown(ret):
|
||||||
# A step that raised (e.g. salt-master restarted while it waited on a queued state run)
|
# A step that raised (e.g. salt-master restarted while it waited on a queued state run) or
|
||||||
# never collected the minion's return, so the state run may still have completed.
|
# stopped waiting never collected the minion's return, so the state run may still have completed.
|
||||||
steps = _failed_steps(ret)
|
steps = _failed_steps(ret)
|
||||||
return bool(steps) and all(str(step.get('comment', '')).startswith(STEP_RAISED) for step in steps)
|
return bool(steps) and all(
|
||||||
|
str(step.get('comment', '')).startswith(STEP_RAISED) or _lost_track(step) for step in steps)
|
||||||
|
|
||||||
|
|
||||||
def _recheck_delay(age):
|
def _recheck_delay(age):
|
||||||
@@ -410,6 +454,10 @@ def main():
|
|||||||
log.debug('no ready intents (%d still in debounce window)', skipped)
|
log.debug('no ready intents (%d still in debounce window)', skipped)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
if _master_settling(now):
|
||||||
|
log.info('salt-master just started; holding %d intent(s) until minions reconnect', len(ready))
|
||||||
|
return 0
|
||||||
|
|
||||||
combined_actions = []
|
combined_actions = []
|
||||||
oldest_first_touch = now
|
oldest_first_touch = now
|
||||||
all_paths = []
|
all_paths = []
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ JID = '20260930171554259426'
|
|||||||
ASYNC_STDERR = ('[WARNING ] Running in asynchronous mode. Results of this execution may be collected '
|
ASYNC_STDERR = ('[WARNING ] Running in asynchronous mode. Results of this execution may be collected '
|
||||||
'by attaching to the master event bus or by examining the master job cache, if '
|
'by attaching to the master event bus or by examining the master job cache, if '
|
||||||
'configured. This execution is running under tag salt/run/{}\n'.format(JID))
|
'configured. This execution is running under tag salt/run/{}\n'.format(JID))
|
||||||
|
NOT_PENDING = ' and not G@first_highstate_pending:True'
|
||||||
CONFLICT = ('The function "state.sls" is running as PID 372218 and was started at '
|
CONFLICT = ('The function "state.sls" is running as PID 372218 and was started at '
|
||||||
'2026, Sep 30 17:15:40.466233 with jid 20260930171540466233')
|
'2026, Sep 30 17:15:40.466233 with jid 20260930171540466233')
|
||||||
|
|
||||||
@@ -88,6 +89,22 @@ RAISED_RET = _orch_ret(dict(REFRESH_STEP, **{
|
|||||||
},
|
},
|
||||||
}), success=False)
|
}), success=False)
|
||||||
|
|
||||||
|
LOST_RET = _orch_ret(dict(REFRESH_STEP, **{
|
||||||
|
'salt_|-apply_soc_1_|-apply_soc_1_|-state': {
|
||||||
|
'__id__': 'apply_soc_1', 'result': False,
|
||||||
|
'changes': {'out': 'highstate', 'ret': {'manager_standalone': {}}},
|
||||||
|
'comment': 'Run failed on minions: manager_standalone',
|
||||||
|
},
|
||||||
|
}), success=False)
|
||||||
|
|
||||||
|
LOST_AND_FAILED_RET = _orch_ret({
|
||||||
|
'salt_|-apply_soc_1_|-apply_soc_1_|-state': {
|
||||||
|
'__id__': 'apply_soc_1', 'result': False,
|
||||||
|
'changes': {'out': 'highstate', 'ret': {'manager_standalone': {}, 'sensor1_sensor': [CONFLICT]}},
|
||||||
|
'comment': 'Run failed on minions: manager_standalone, sensor1_sensor',
|
||||||
|
},
|
||||||
|
}, success=False)
|
||||||
|
|
||||||
SUCCESS_RET = _orch_ret(dict(REFRESH_STEP, **{
|
SUCCESS_RET = _orch_ret(dict(REFRESH_STEP, **{
|
||||||
'salt_|-apply_telegraf_1_|-apply_telegraf_1_|-state': {
|
'salt_|-apply_telegraf_1_|-apply_telegraf_1_|-state': {
|
||||||
'__id__': 'apply_telegraf_1', 'result': True,
|
'__id__': 'apply_telegraf_1', 'result': True,
|
||||||
@@ -199,6 +216,17 @@ class TestHelpers(DrainerTestCase):
|
|||||||
drainer._unlink(self.tmpdir, self.log)
|
drainer._unlink(self.tmpdir, self.log)
|
||||||
self.log.exception.assert_called_once()
|
self.log.exception.assert_called_once()
|
||||||
|
|
||||||
|
def test_master_settling(self):
|
||||||
|
pidfile = os.path.join(self.tmpdir, 'salt-master.pid')
|
||||||
|
now = time.time()
|
||||||
|
with patch.object(drainer, 'MASTER_PIDFILE', pidfile):
|
||||||
|
self.assertFalse(drainer._master_settling(now))
|
||||||
|
self.write_json(self.tmpdir, 'salt-master.pid', '1100')
|
||||||
|
for age, settling in ((0, True), (drainer.MASTER_SETTLE_SECONDS - 1, True),
|
||||||
|
(drainer.MASTER_SETTLE_SECONDS, False), (-60, False)):
|
||||||
|
os.utime(pidfile, (now - age, now - age))
|
||||||
|
self.assertIs(drainer._master_settling(now), settling, age)
|
||||||
|
|
||||||
|
|
||||||
class TestDispatch(DrainerTestCase):
|
class TestDispatch(DrainerTestCase):
|
||||||
|
|
||||||
@@ -265,6 +293,13 @@ class TestResults(DrainerTestCase):
|
|||||||
self.assertEqual(drainer._minion_failure('Rendering SLS failed'), 'Rendering SLS failed')
|
self.assertEqual(drainer._minion_failure('Rendering SLS failed'), 'Rendering SLS failed')
|
||||||
self.assertEqual(drainer._minion_failure(True), '')
|
self.assertEqual(drainer._minion_failure(True), '')
|
||||||
self.assertEqual(drainer._minion_failure({'a': {'result': True}}), '')
|
self.assertEqual(drainer._minion_failure({'a': {'result': True}}), '')
|
||||||
|
self.assertEqual(drainer._minion_failure({}), drainer.NO_RETURN)
|
||||||
|
|
||||||
|
def test_orch_failures_lost(self):
|
||||||
|
self.assertEqual(drainer._orch_failures(LOST_RET), [
|
||||||
|
'apply_soc_1: Run failed on minions: manager_standalone',
|
||||||
|
'manager_standalone: no return received',
|
||||||
|
])
|
||||||
|
|
||||||
def test_orch_failures_conflict(self):
|
def test_orch_failures_conflict(self):
|
||||||
failures = drainer._orch_failures(CONFLICT_RET)
|
failures = drainer._orch_failures(CONFLICT_RET)
|
||||||
@@ -308,7 +343,17 @@ class TestResults(DrainerTestCase):
|
|||||||
|
|
||||||
def test_result_unknown(self):
|
def test_result_unknown(self):
|
||||||
self.assertTrue(drainer._result_unknown(RAISED_RET))
|
self.assertTrue(drainer._result_unknown(RAISED_RET))
|
||||||
for ret in (CONFLICT_RET, STATE_FAIL_RET, SUCCESS_RET, ['No minions matched'], {MASTER: 'odd'},
|
self.assertTrue(drainer._result_unknown(LOST_RET))
|
||||||
|
changed = json.loads(json.dumps(LOST_RET))
|
||||||
|
changed[MASTER]['return']['data'][MASTER]['salt_|-apply_soc_1_|-apply_soc_1_|-state']['changes']['ret'][
|
||||||
|
'sensor1_sensor'] = {'file_|-a_|-a_|-managed': {'result': True, 'changes': {'diff': 'x'}}}
|
||||||
|
self.assertTrue(drainer._result_unknown(changed))
|
||||||
|
odd = _orch_ret({'salt_|-apply_soc_1_|-apply_soc_1_|-state': {
|
||||||
|
'__id__': 'apply_soc_1', 'result': False, 'changes': 'Run failed', 'comment': 'Run failed on minions',
|
||||||
|
}}, success=False)
|
||||||
|
self.assertFalse(drainer._result_unknown(odd))
|
||||||
|
for ret in (CONFLICT_RET, STATE_FAIL_RET, SUCCESS_RET, LOST_AND_FAILED_RET, ['No minions matched'],
|
||||||
|
{MASTER: 'odd'},
|
||||||
{MASTER: {'return': {'data': {MASTER: ['Rendering SLS failed']}}, 'success': False}}):
|
{MASTER: {'return': {'data': {MASTER: ['Rendering SLS failed']}}, 'success': False}}):
|
||||||
self.assertFalse(drainer._result_unknown(ret), ret)
|
self.assertFalse(drainer._result_unknown(ret), ret)
|
||||||
mixed = _orch_ret(dict(RAISED_RET[MASTER]['return']['data'][MASTER],
|
mixed = _orch_ret(dict(RAISED_RET[MASTER]['return']['data'][MASTER],
|
||||||
@@ -350,6 +395,21 @@ class TestResults(DrainerTestCase):
|
|||||||
self.assertIn('AuthenticationError: Authentication error occurred.', self.logged('warning'))
|
self.assertIn('AuthenticationError: Authentication error occurred.', self.logged('warning'))
|
||||||
self.assertNotIn('6_unknown', self.logged('error'))
|
self.assertNotIn('6_unknown', self.logged('error'))
|
||||||
|
|
||||||
|
def test_check_dispatched_lost(self):
|
||||||
|
now = time.time()
|
||||||
|
results = {'1_lost': LOST_RET, '2_lost_and_failed': LOST_AND_FAILED_RET}
|
||||||
|
paths = [self.record(jid, 60, now) for jid in results]
|
||||||
|
with patch.object(drainer, '_lookup_jid', side_effect=lambda jid, log: results[jid]):
|
||||||
|
drainer._check_dispatched(self.log, now)
|
||||||
|
|
||||||
|
for path in paths:
|
||||||
|
self.assertFalse(os.path.exists(path), path)
|
||||||
|
self.assertIn('push result unknown jid=1_lost', self.logged('warning'))
|
||||||
|
self.assertIn('manager_standalone: no return received', self.logged('warning'))
|
||||||
|
self.assertNotIn('1_lost', self.logged('error'))
|
||||||
|
self.assertIn('push failed jid=2_lost_and_failed', self.logged('error'))
|
||||||
|
self.assertIn('is running as PID 372218', self.logged('error'))
|
||||||
|
|
||||||
def test_check_dispatched_survives_bad_result(self):
|
def test_check_dispatched_survives_bad_result(self):
|
||||||
now = time.time()
|
now = time.time()
|
||||||
bad = self.record('1_bad', 60, now)
|
bad = self.record('1_bad', 60, now)
|
||||||
@@ -431,8 +491,19 @@ class TestTargeted(DrainerTestCase):
|
|||||||
self.CkMinions = patcher.start()
|
self.CkMinions = patcher.start()
|
||||||
self.addCleanup(patcher.stop)
|
self.addCleanup(patcher.stop)
|
||||||
|
|
||||||
|
def test_skip_pending(self):
|
||||||
|
self.assertEqual(drainer._skip_pending({'state': 'soc', 'tgt': 'G@role:so-eval or G@role:so-manager'}),
|
||||||
|
{'state': 'soc', 'tgt': '( G@role:so-eval or G@role:so-manager )' + NOT_PENDING})
|
||||||
|
self.assertEqual(drainer._skip_pending({'highstate': True, 'tgt': '*', 'tgt_type': 'compound'}),
|
||||||
|
{'highstate': True, 'tgt': '( * )' + NOT_PENDING, 'tgt_type': 'compound'})
|
||||||
|
listed = {'state': 'soc', 'tgt': 'manager_manager', 'tgt_type': 'list'}
|
||||||
|
self.assertEqual(drainer._skip_pending(listed), listed)
|
||||||
|
|
||||||
def test_drops_unmatched(self):
|
def test_drops_unmatched(self):
|
||||||
matches = {'G@role:so-sensor': ['sensor_sensor'], 'manager_manager': ['manager_manager']}
|
sensor = '( G@role:so-sensor )' + NOT_PENDING
|
||||||
|
heavynode = '( G@role:so-heavynode )' + NOT_PENDING
|
||||||
|
idh = '( G@role:so-idh )' + NOT_PENDING
|
||||||
|
matches = {sensor: ['sensor_sensor'], 'manager_manager': ['manager_manager']}
|
||||||
self.ckminions.check_minions.side_effect = lambda tgt, tgt_type: {'minions': matches.get(tgt, [])}
|
self.ckminions.check_minions.side_effect = lambda tgt, tgt_type: {'minions': matches.get(tgt, [])}
|
||||||
actions = [
|
actions = [
|
||||||
{'state': 'strelka', 'tgt': 'G@role:so-sensor'},
|
{'state': 'strelka', 'tgt': 'G@role:so-sensor'},
|
||||||
@@ -440,28 +511,27 @@ class TestTargeted(DrainerTestCase):
|
|||||||
{'highstate': True, 'tgt': 'G@role:so-idh'},
|
{'highstate': True, 'tgt': 'G@role:so-idh'},
|
||||||
{'state': 'soc', 'tgt': 'manager_manager', 'tgt_type': 'list'},
|
{'state': 'soc', 'tgt': 'manager_manager', 'tgt_type': 'list'},
|
||||||
]
|
]
|
||||||
self.assertEqual(drainer._targeted(actions, self.log), [actions[0], actions[3]])
|
self.assertEqual(drainer._targeted(actions, self.log), [{'state': 'strelka', 'tgt': sensor}, actions[3]])
|
||||||
self.CkMinions.assert_called_once()
|
self.CkMinions.assert_called_once()
|
||||||
self.assertEqual([c.args for c in self.ckminions.check_minions.call_args_list], [
|
self.assertEqual([c.args for c in self.ckminions.check_minions.call_args_list], [
|
||||||
('G@role:so-sensor', 'compound'), ('G@role:so-heavynode', 'compound'),
|
(sensor, 'compound'), (heavynode, 'compound'), (idh, 'compound'), ('manager_manager', 'list'),
|
||||||
('G@role:so-idh', 'compound'), ('manager_manager', 'list'),
|
|
||||||
])
|
])
|
||||||
info = self.logged('info')
|
info = self.logged('info')
|
||||||
self.assertIn('skipping suricata: no minions match tgt=G@role:so-heavynode', info)
|
self.assertIn('skipping suricata: no minions match tgt=' + heavynode, info)
|
||||||
self.assertIn('skipping highstate: no minions match tgt=G@role:so-idh', info)
|
self.assertIn('skipping highstate: no minions match tgt=' + idh, info)
|
||||||
self.assertNotIn('strelka', info)
|
self.assertNotIn('strelka', info)
|
||||||
|
|
||||||
def test_master_config_error_keeps_actions(self):
|
def test_master_config_error_keeps_actions(self):
|
||||||
actions = [{'state': 'soc', 'tgt': '*'}]
|
actions = [{'state': 'soc', 'tgt': '*'}]
|
||||||
with patch.object(drainer.salt.config, 'master_config', side_effect=OSError('no config')):
|
with patch.object(drainer.salt.config, 'master_config', side_effect=OSError('no config')):
|
||||||
self.assertEqual(drainer._targeted(actions, self.log), actions)
|
self.assertEqual(drainer._targeted(actions, self.log), [{'state': 'soc', 'tgt': '( * )' + NOT_PENDING}])
|
||||||
self.log.exception.assert_called_once()
|
self.log.exception.assert_called_once()
|
||||||
self.CkMinions.assert_not_called()
|
self.CkMinions.assert_not_called()
|
||||||
|
|
||||||
def test_check_error_keeps_action(self):
|
def test_check_error_keeps_action(self):
|
||||||
actions = [{'state': 'soc', 'tgt': 'G@role:'}]
|
actions = [{'state': 'soc', 'tgt': 'G@role:'}]
|
||||||
self.ckminions.check_minions.side_effect = RuntimeError('bad target')
|
self.ckminions.check_minions.side_effect = RuntimeError('bad target')
|
||||||
self.assertEqual(drainer._targeted(actions, self.log), actions)
|
self.assertEqual(drainer._targeted(actions, self.log), [{'state': 'soc', 'tgt': '( G@role: )' + NOT_PENDING}])
|
||||||
self.log.exception.assert_called_once()
|
self.log.exception.assert_called_once()
|
||||||
|
|
||||||
|
|
||||||
@@ -475,6 +545,7 @@ class TestMain(DrainerTestCase):
|
|||||||
('_load_push_cfg', {'side_effect': lambda: self.cfg}),
|
('_load_push_cfg', {'side_effect': lambda: self.cfg}),
|
||||||
('_check_dispatched', {}),
|
('_check_dispatched', {}),
|
||||||
('_targeted', {'side_effect': lambda actions, log: actions}),
|
('_targeted', {'side_effect': lambda actions, log: actions}),
|
||||||
|
('_master_settling', {'return_value': False}),
|
||||||
):
|
):
|
||||||
patcher = patch.object(drainer, name, **kwargs)
|
patcher = patch.object(drainer, name, **kwargs)
|
||||||
setattr(self, name, patcher.start())
|
setattr(self, name, patcher.start())
|
||||||
@@ -528,6 +599,16 @@ class TestMain(DrainerTestCase):
|
|||||||
with patch.object(drainer.os, 'unlink', side_effect=OSError('busy')):
|
with patch.object(drainer.os, 'unlink', side_effect=OSError('busy')):
|
||||||
self.assertEqual(drainer.main(), 0)
|
self.assertEqual(drainer.main(), 0)
|
||||||
|
|
||||||
|
def test_holds_while_master_settling(self):
|
||||||
|
path = self.intent('pillar_soc.json')
|
||||||
|
self._master_settling.return_value = True
|
||||||
|
with patch.object(drainer, '_dispatch') as dispatch:
|
||||||
|
self.assertEqual(drainer.main(), 0)
|
||||||
|
dispatch.assert_not_called()
|
||||||
|
self._check_dispatched.assert_called_once()
|
||||||
|
self.assertTrue(os.path.exists(path))
|
||||||
|
self.assertIn('holding 1 intent(s)', self.logged('info'))
|
||||||
|
|
||||||
def test_dispatch_failure_keeps_intents(self):
|
def test_dispatch_failure_keeps_intents(self):
|
||||||
path = self.intent('pillar_soc.json')
|
path = self.intent('pillar_soc.json')
|
||||||
with patch.object(drainer, '_dispatch', return_value=None):
|
with patch.object(drainer, '_dispatch', return_value=None):
|
||||||
|
|||||||
@@ -1108,6 +1108,9 @@ post_to_3.3.0() {
|
|||||||
|
|
||||||
### 3.4.0 Scripts ###
|
### 3.4.0 Scripts ###
|
||||||
up_to_3.4.0() {
|
up_to_3.4.0() {
|
||||||
|
# download 9.4.8 elastic agent packages
|
||||||
|
determine_elastic_agent_upgrade
|
||||||
|
|
||||||
set_soauth_range
|
set_soauth_range
|
||||||
|
|
||||||
echo "Removing so-kratos, so-hydra and so-soc so they are recreated on the soauth network."
|
echo "Removing so-kratos, so-hydra and so-soc so they are recreated on the soauth network."
|
||||||
@@ -1185,6 +1188,10 @@ valid_soauth_range() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
post_to_3.4.0() {
|
post_to_3.4.0() {
|
||||||
|
# Generate 9.4.8 elastic agent installers
|
||||||
|
echo "Regenerating Elastic Agent Installers"
|
||||||
|
/sbin/so-elastic-agent-gen-installers
|
||||||
|
|
||||||
for idx in "metrics-logstash.node-default" "metrics-logstash.stack_monitoring.node-default"; do
|
for idx in "metrics-logstash.node-default" "metrics-logstash.stack_monitoring.node-default"; do
|
||||||
rollover_index "$idx"
|
rollover_index "$idx"
|
||||||
done
|
done
|
||||||
@@ -1214,9 +1221,6 @@ add_detection_runtime_fields() {
|
|||||||
|
|
||||||
### 3.5.0 Scripts ###
|
### 3.5.0 Scripts ###
|
||||||
up_to_3.5.0() {
|
up_to_3.5.0() {
|
||||||
# download 9.4.10 elastic agent packages
|
|
||||||
determine_elastic_agent_upgrade
|
|
||||||
|
|
||||||
remove_localrules_portgroup
|
remove_localrules_portgroup
|
||||||
|
|
||||||
INSTALLEDVERSION=3.5.0
|
INSTALLEDVERSION=3.5.0
|
||||||
@@ -1235,14 +1239,8 @@ remove_localrules_portgroup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
post_to_3.5.0() {
|
post_to_3.5.0() {
|
||||||
# Generate 9.4.10 elastic agent installers
|
|
||||||
echo "Regenerating Elastic Agent Installers"
|
|
||||||
/sbin/so-elastic-agent-gen-installers
|
|
||||||
|
|
||||||
telegraf_repair
|
telegraf_repair
|
||||||
|
|
||||||
rollover_index "logs-detections.alerts-so"
|
|
||||||
|
|
||||||
set_postversion 3.5.0
|
set_postversion 3.5.0
|
||||||
}
|
}
|
||||||
### 3.5.0 End ###
|
### 3.5.0 End ###
|
||||||
@@ -1519,11 +1517,10 @@ verify_es_version_compatibility() {
|
|||||||
["8.18.4"]="8.18.6 8.18.8 9.0.8"
|
["8.18.4"]="8.18.6 8.18.8 9.0.8"
|
||||||
["8.18.6"]="8.18.8 9.0.8"
|
["8.18.6"]="8.18.8 9.0.8"
|
||||||
["8.18.8"]="9.0.8"
|
["8.18.8"]="9.0.8"
|
||||||
["9.0.8"]="9.3.3 9.3.7 9.4.5 9.4.8 9.4.10"
|
["9.0.8"]="9.3.3 9.3.7 9.4.5 9.4.8"
|
||||||
["9.3.3"]="9.3.7 9.4.5 9.4.8 9.4.10"
|
["9.3.3"]="9.3.7 9.4.5 9.4.8"
|
||||||
["9.3.7"]="9.4.5 9.4.8 9.4.10"
|
["9.3.7"]="9.4.5 9.4.8"
|
||||||
["9.4.5"]="9.4.8 9.4.10"
|
["9.4.5"]="9.4.8"
|
||||||
["9.4.8"]="9.4.10"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Elasticsearch MUST upgrade through these versions
|
# Elasticsearch MUST upgrade through these versions
|
||||||
|
|||||||
@@ -2,10 +2,24 @@
|
|||||||
{% set actions = salt['pillar.get']('actions', []) %}
|
{% set actions = salt['pillar.get']('actions', []) %}
|
||||||
{% set BATCH = AUTOAPPLY.batch %}
|
{% set BATCH = AUTOAPPLY.batch %}
|
||||||
{% set BATCH_WAIT = AUTOAPPLY.batch_wait %}
|
{% set BATCH_WAIT = AUTOAPPLY.batch_wait %}
|
||||||
|
{# Must exceed gather_job_timeout (10s): at the 5s default, one saltutil.find_job reply slower than that abandons
|
||||||
|
a queued state run, and a master slow to accept the publish gets it a second time. #}
|
||||||
|
{% set STATE_TIMEOUT = 60 %}
|
||||||
|
|
||||||
{# queue must be a top-level salt.state arg (kwarg is ignored); an int is max_queue and still fails on conflict #}
|
{# queue must be a top-level salt.state arg (kwarg is ignored); an int is max_queue and still fails on conflict #}
|
||||||
|
{# refresh_pillar doubles as the reachability check: minions take up to ~22s to rejoin a restarted master's
|
||||||
|
publisher, and a job published before then reaches nobody. Each failed attempt takes ~15s to time out. #}
|
||||||
|
|
||||||
{% for action in actions %}
|
{% for action in actions %}
|
||||||
|
refresh_pillar_{{ loop.index }}:
|
||||||
|
salt.function:
|
||||||
|
- name: saltutil.refresh_pillar
|
||||||
|
- tgt: '{{ action.tgt }}'
|
||||||
|
- tgt_type: {{ action.get('tgt_type', 'compound') }}
|
||||||
|
- retry:
|
||||||
|
attempts: 3
|
||||||
|
interval: 10
|
||||||
|
|
||||||
{% if action.get('highstate') %}
|
{% if action.get('highstate') %}
|
||||||
apply_highstate_{{ loop.index }}:
|
apply_highstate_{{ loop.index }}:
|
||||||
salt.state:
|
salt.state:
|
||||||
@@ -15,13 +29,10 @@ apply_highstate_{{ loop.index }}:
|
|||||||
- batch: {{ action.get('batch', BATCH) }}
|
- batch: {{ action.get('batch', BATCH) }}
|
||||||
- batch_wait: {{ action.get('batch_wait', BATCH_WAIT) }}
|
- batch_wait: {{ action.get('batch_wait', BATCH_WAIT) }}
|
||||||
- queue: True
|
- queue: True
|
||||||
|
- timeout: {{ STATE_TIMEOUT }}
|
||||||
|
- require:
|
||||||
|
- salt: refresh_pillar_{{ loop.index }}
|
||||||
{% else %}
|
{% else %}
|
||||||
refresh_pillar_{{ loop.index }}:
|
|
||||||
salt.function:
|
|
||||||
- name: saltutil.refresh_pillar
|
|
||||||
- tgt: '{{ action.tgt }}'
|
|
||||||
- tgt_type: {{ action.get('tgt_type', 'compound') }}
|
|
||||||
|
|
||||||
apply_{{ action.state | replace('.', '_') }}_{{ loop.index }}:
|
apply_{{ action.state | replace('.', '_') }}_{{ loop.index }}:
|
||||||
salt.state:
|
salt.state:
|
||||||
- tgt: '{{ action.tgt }}'
|
- tgt: '{{ action.tgt }}'
|
||||||
@@ -31,6 +42,7 @@ apply_{{ action.state | replace('.', '_') }}_{{ loop.index }}:
|
|||||||
- batch: {{ action.get('batch', BATCH) }}
|
- batch: {{ action.get('batch', BATCH) }}
|
||||||
- batch_wait: {{ action.get('batch_wait', BATCH_WAIT) }}
|
- batch_wait: {{ action.get('batch_wait', BATCH_WAIT) }}
|
||||||
- queue: True
|
- queue: True
|
||||||
|
- timeout: {{ STATE_TIMEOUT }}
|
||||||
- require:
|
- require:
|
||||||
- salt: refresh_pillar_{{ loop.index }}
|
- salt: refresh_pillar_{{ loop.index }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#
|
#
|
||||||
# One pillar directory can map to multiple (state, tgt) actions.
|
# One pillar directory can map to multiple (state, tgt) actions.
|
||||||
# tgt is a raw salt compound expression. tgt_type is always "compound".
|
# tgt is a raw salt compound expression. tgt_type is always "compound".
|
||||||
|
# so-push-drainer excludes nodes that have not completed their first highstate.
|
||||||
# Per-action `batch` / `batch_wait` override the orch defaults (10% / 15s).
|
# Per-action `batch` / `batch_wait` override the orch defaults (10% / 15s).
|
||||||
# An action with `highstate: True` triggers state.highstate instead of
|
# An action with `highstate: True` triggers state.highstate instead of
|
||||||
# state.apply -- see salt/orch/push_batch.sls.
|
# state.apply -- see salt/orch/push_batch.sls.
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ include:
|
|||||||
# Install the registry container
|
# Install the registry container
|
||||||
so-dockerregistry:
|
so-dockerregistry:
|
||||||
docker_container.running:
|
docker_container.running:
|
||||||
- image: ghcr.io/security-onion-solutions/registry:3.1.2
|
- image: ghcr.io/security-onion-solutions/registry:3.1.1
|
||||||
# Intentionally `always`-- registry is critical and must
|
# Intentionally `always`-- registry is critical and must
|
||||||
# come back up even if it was manually stopped.
|
# come back up even if it was manually stopped.
|
||||||
- restart_policy: always
|
- restart_policy: always
|
||||||
|
|||||||
@@ -2,3 +2,9 @@ lasthighstate:
|
|||||||
file.touch:
|
file.touch:
|
||||||
- name: /opt/so/log/salt/lasthighstate
|
- name: /opt/so/log/salt/lasthighstate
|
||||||
- order: 9001
|
- order: 9001
|
||||||
|
|
||||||
|
# set by setup; so-push-drainer does not target a node that still has it
|
||||||
|
first_highstate_pending:
|
||||||
|
grains.absent:
|
||||||
|
- destructive: True
|
||||||
|
- order: 9001
|
||||||
@@ -1638,12 +1638,6 @@ soc:
|
|||||||
- "user.effective.name"
|
- "user.effective.name"
|
||||||
- "weird.name"
|
- "weird.name"
|
||||||
- "tags"
|
- "tags"
|
||||||
queryNotifications:
|
|
||||||
defaultLimit: 10
|
|
||||||
maxLimit: 50
|
|
||||||
summaryMaxLength: 1000
|
|
||||||
fieldValueMaxLength: 200
|
|
||||||
maxEntries: 25
|
|
||||||
onionconfig:
|
onionconfig:
|
||||||
saltstackDir: /opt/so/saltstack
|
saltstackDir: /opt/so/saltstack
|
||||||
bypassEnabled: false
|
bypassEnabled: false
|
||||||
|
|||||||
@@ -1112,32 +1112,6 @@ soc:
|
|||||||
description: A whitelist of fields to return when OnionAI uses the query_events tool. All other fields are removed. One field per line.
|
description: A whitelist of fields to return when OnionAI uses the query_events tool. All other fields are removed. One field per line.
|
||||||
global: True
|
global: True
|
||||||
multiline: True
|
multiline: True
|
||||||
queryNotifications:
|
|
||||||
defaultLimit:
|
|
||||||
description: Number of notifications Onion AI reads with the query_notifications tool when it doesn't ask for a specific number. Must be greater than 0. Values above maxLimit use maxLimit.
|
|
||||||
global: True
|
|
||||||
advanced: True
|
|
||||||
forcedType: int
|
|
||||||
maxLimit:
|
|
||||||
description: Maximum number of notifications Onion AI may read with one query_notifications call. Must be greater than 0. Higher values put more notification text into the model's context.
|
|
||||||
global: True
|
|
||||||
advanced: True
|
|
||||||
forcedType: int
|
|
||||||
summaryMaxLength:
|
|
||||||
description: Maximum number of characters of each notification summary that query_notifications returns to Onion AI. Must be greater than 0. Longer summaries are shortened.
|
|
||||||
global: True
|
|
||||||
advanced: True
|
|
||||||
forcedType: int
|
|
||||||
fieldValueMaxLength:
|
|
||||||
description: Maximum number of characters of each notification field value that query_notifications returns to Onion AI. Must be greater than 0. Longer values are shortened. Link values are never shortened.
|
|
||||||
global: True
|
|
||||||
advanced: True
|
|
||||||
forcedType: int
|
|
||||||
maxEntries:
|
|
||||||
description: Maximum number of fields, of links, and of attachment names, each counted separately, per notification that query_notifications returns to Onion AI. Must be greater than 0. The result tells Onion AI how many were left out.
|
|
||||||
global: True
|
|
||||||
advanced: True
|
|
||||||
forcedType: int
|
|
||||||
client:
|
client:
|
||||||
assistant:
|
assistant:
|
||||||
enabled:
|
enabled:
|
||||||
|
|||||||
@@ -24,8 +24,6 @@ so-telegraf:
|
|||||||
- environment:
|
- environment:
|
||||||
- HOST_ETC=/host/etc
|
- HOST_ETC=/host/etc
|
||||||
- HOST_SYS=/host/sys
|
- HOST_SYS=/host/sys
|
||||||
- HOST_PROC=/host/proc
|
|
||||||
- HOST_PROC_MOUNTINFO=/proc/1
|
|
||||||
- HOST_MOUNT_PREFIX=/host
|
- HOST_MOUNT_PREFIX=/host
|
||||||
- GODEBUG=x509ignoreCN=0
|
- GODEBUG=x509ignoreCN=0
|
||||||
{% if DOCKERMERGED.containers['so-telegraf'].extra_env %}
|
{% if DOCKERMERGED.containers['so-telegraf'].extra_env %}
|
||||||
|
|||||||
@@ -519,6 +519,8 @@ configure_minion() {
|
|||||||
info "Configuring minion type as $minion_type"
|
info "Configuring minion type as $minion_type"
|
||||||
logCmd "mkdir -p /etc/salt/minion.d"
|
logCmd "mkdir -p /etc/salt/minion.d"
|
||||||
echo "role: so-$minion_type" > /etc/salt/grains
|
echo "role: so-$minion_type" > /etc/salt/grains
|
||||||
|
# so-push-drainer leaves the node alone until salt.lasthighstate removes this
|
||||||
|
echo "first_highstate_pending: True" >> /etc/salt/grains
|
||||||
|
|
||||||
local minion_config=/etc/salt/minion
|
local minion_config=/etc/salt/minion
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user