From 567e19e5d7fa1e79e793c317350f1d01a826937e Mon Sep 17 00:00:00 2001 From: Mike Reeves Date: Mon, 13 Nov 2023 15:38:23 -0500 Subject: [PATCH 1/7] Update VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 8ea99f559..29630cd6d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.4.30 +2.4.40 From 4666b993e57693033280bf769660ebfdb4a6daaf Mon Sep 17 00:00:00 2001 From: Doug Burks Date: Tue, 14 Nov 2023 09:58:45 -0500 Subject: [PATCH 2/7] Update defaults.yaml --- salt/soc/defaults.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/soc/defaults.yaml b/salt/soc/defaults.yaml index ceca9ef31..4e6406d3e 100644 --- a/salt/soc/defaults.yaml +++ b/salt/soc/defaults.yaml @@ -1240,7 +1240,7 @@ soc: showSubtitle: true - name: HTTP description: HTTP with exe downloads - query: 'tags:http AND (file.resp_mime_types:dosexec OR file.resp_mime_types:executable) | groupby http.virtual_host' + query: 'tags:http AND file.resp_mime_types:*exec* | groupby http.virtual_host' showSubtitle: true - name: Intel description: Intel framework hits grouped by indicator From f7fa4d05fb0c00a9a6394935208a974c951f1d7a Mon Sep 17 00:00:00 2001 From: Jason Ertel Date: Tue, 14 Nov 2023 15:40:52 -0500 Subject: [PATCH 3/7] avoid startup error --- salt/common/tools/sbin/so-log-check | 1 + 1 file changed, 1 insertion(+) diff --git a/salt/common/tools/sbin/so-log-check b/salt/common/tools/sbin/so-log-check index dc84ba5bd..d2582ff94 100755 --- a/salt/common/tools/sbin/so-log-check +++ b/salt/common/tools/sbin/so-log-check @@ -109,6 +109,7 @@ if [[ $EXCLUDE_STARTUP_ERRORS == 'Y' ]]; then EXCLUDED_ERRORS="$EXCLUDED_ERRORS|timeout exceeded" # server not yet ready (telegraf waiting on elasticsearch) EXCLUDED_ERRORS="$EXCLUDED_ERRORS|influxsize kbytes" # server not yet ready (telegraf waiting on influx) EXCLUDED_ERRORS="$EXCLUDED_ERRORS|expected field at" # server not yet ready (telegraf waiting on health data) + EXCLUDED_ERRORS="$EXCLUDED_ERRORS|connection timed out" # server not yet ready (telegraf plugin unable to connect) EXCLUDED_ERRORS="$EXCLUDED_ERRORS|cached the public key" # server not yet ready (salt minion waiting on key acceptance) EXCLUDED_ERRORS="$EXCLUDED_ERRORS|no ingest nodes" # server not yet ready (logstash waiting on elastic) EXCLUDED_ERRORS="$EXCLUDED_ERRORS|failed to poll" # server not yet ready (sensoroni waiting on soc) From de99cda766115eb9b41ef231a6921b419ab4a073 Mon Sep 17 00:00:00 2001 From: Jason Ertel Date: Thu, 16 Nov 2023 15:51:17 -0500 Subject: [PATCH 4/7] improve timing of responses --- salt/soc/files/bin/salt-relay.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/salt/soc/files/bin/salt-relay.sh b/salt/soc/files/bin/salt-relay.sh index fea81728d..783018b3a 100755 --- a/salt/soc/files/bin/salt-relay.sh +++ b/salt/soc/files/bin/salt-relay.sh @@ -37,12 +37,14 @@ function poll() { function respond() { file="$QUEUE_DIR/$1.response" + tmpfile=${file}.tmp response=$2 - touch "$file" - chmod 660 "$file" - chown "$QUEUE_OWNER:$QUEUE_GROUP" "$file" - echo "$response" > "$file" + touch "$tmpfile" + chmod 660 "$tmpfile" + chown "$QUEUE_OWNER:$QUEUE_GROUP" "$tmpfile" + echo "$response" > "$tmpfile" + mv $tmpfile $file } function list_minions() { From c09e8f0d718a2559673ace48e7bde7e113bbdac8 Mon Sep 17 00:00:00 2001 From: Jason Ertel Date: Thu, 16 Nov 2023 15:58:48 -0500 Subject: [PATCH 5/7] improve timing of responses --- salt/soc/files/bin/salt-relay.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/soc/files/bin/salt-relay.sh b/salt/soc/files/bin/salt-relay.sh index 783018b3a..4b183b20a 100755 --- a/salt/soc/files/bin/salt-relay.sh +++ b/salt/soc/files/bin/salt-relay.sh @@ -37,7 +37,7 @@ function poll() { function respond() { file="$QUEUE_DIR/$1.response" - tmpfile=${file}.tmp + tmpfile="${file}.tmp" response=$2 touch "$tmpfile" From b2ea7138f31b9ddcfe56ddc3cc72c1b08a2119f5 Mon Sep 17 00:00:00 2001 From: Jason Ertel Date: Mon, 20 Nov 2023 15:28:56 -0500 Subject: [PATCH 6/7] remove hotfix --- HOTFIX | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HOTFIX b/HOTFIX index 57030dc85..d3f5a12fa 100644 --- a/HOTFIX +++ b/HOTFIX @@ -1 +1 @@ -20231117 + From 6356a0bf9555c17cad2d917bef1b90635156831d Mon Sep 17 00:00:00 2001 From: Jason Ertel Date: Mon, 20 Nov 2023 16:18:30 -0500 Subject: [PATCH 7/7] add support for nested keys --- salt/manager/tools/sbin/so-yaml.py | 18 ++++++++++----- salt/manager/tools/sbin/so-yaml_test.py | 30 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/salt/manager/tools/sbin/so-yaml.py b/salt/manager/tools/sbin/so-yaml.py index 68f9b43fe..406e4ed45 100755 --- a/salt/manager/tools/sbin/so-yaml.py +++ b/salt/manager/tools/sbin/so-yaml.py @@ -16,12 +16,12 @@ lockFile = "/tmp/so-yaml.lock" def showUsage(args): print('Usage: {} [ARGS...]'.format(sys.argv[0])) print(' General commands:') - print(' remove - Removes a yaml top-level key, if it exists. Requires KEY arg.') + print(' remove - Removes a yaml key, if it exists. Requires KEY arg.') print(' help - Prints this usage information.') print('') print(' Where:') print(' YAML_FILE - Path to the file that will be modified. Ex: /opt/so/conf/service/conf.yaml') - print(' KEY - Top level key only, does not support dot-notations for nested keys at this time. Ex: level1') + print(' KEY - YAML key, does not support \' or " characters at this time. Ex: level1.level2') sys.exit(1) @@ -36,6 +36,13 @@ def writeYaml(filename, content): return yaml.dump(content, file) +def removeKey(content, key): + pieces = key.split(".", 1) + if len(pieces) > 1: + removeKey(content[pieces[0]], pieces[1]) + else: + content.pop(key, None) + def remove(args): if len(args) != 2: print('Missing filename or key arg', file=sys.stderr) @@ -43,11 +50,12 @@ def remove(args): return filename = args[0] + key = args[1] + content = loadYaml(filename) - - content.pop(args[1], None) - + removeKey(content, key) writeYaml(filename, content) + return 0 diff --git a/salt/manager/tools/sbin/so-yaml_test.py b/salt/manager/tools/sbin/so-yaml_test.py index 0f2ac7d81..7d0ed1a8e 100644 --- a/salt/manager/tools/sbin/so-yaml_test.py +++ b/salt/manager/tools/sbin/so-yaml_test.py @@ -57,6 +57,36 @@ class TestRemove(unittest.TestCase): expected = "key2: false\n" self.assertEqual(actual, expected) + def test_remove_nested(self): + filename = "/tmp/so-yaml_test-remove.yaml" + file = open(filename, "w") + file.write("{key1: { child1: 123, child2: abc }, key2: false}") + file.close() + + soyaml.remove([filename, "key1.child2"]) + + file = open(filename, "r") + actual = file.read() + file.close() + + expected = "key1:\n child1: 123\nkey2: false\n" + self.assertEqual(actual, expected) + + def test_remove_nested_deep(self): + filename = "/tmp/so-yaml_test-remove.yaml" + file = open(filename, "w") + file.write("{key1: { child1: 123, child2: { deep1: 45, deep2: ab } }, key2: false}") + file.close() + + soyaml.remove([filename, "key1.child2.deep1"]) + + file = open(filename, "r") + actual = file.read() + file.close() + + expected = "key1:\n child1: 123\n child2:\n deep2: ab\nkey2: false\n" + self.assertEqual(actual, expected) + def test_remove_missing_args(self): with patch('sys.exit', new=MagicMock()) as sysmock: with patch('sys.stderr', new=StringIO()) as mock_stdout: