mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2026-11-18 18:16:02 +01:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f005453605 |
No files matched your search
@@ -103,6 +103,7 @@ docker:
|
|||||||
- 80:80
|
- 80:80
|
||||||
- 443:443
|
- 443:443
|
||||||
- 8443:8443
|
- 8443:8443
|
||||||
|
- 7788:7788
|
||||||
- 7789:7789
|
- 7789:7789
|
||||||
custom_bind_mounts: []
|
custom_bind_mounts: []
|
||||||
extra_hosts: []
|
extra_hosts: []
|
||||||
|
|||||||
@@ -118,6 +118,10 @@ firewall:
|
|||||||
tcp:
|
tcp:
|
||||||
- 5601
|
- 5601
|
||||||
udp: []
|
udp: []
|
||||||
|
localrules:
|
||||||
|
tcp:
|
||||||
|
- 7788
|
||||||
|
udp: []
|
||||||
nginx:
|
nginx:
|
||||||
tcp:
|
tcp:
|
||||||
- 80
|
- 80
|
||||||
@@ -196,6 +200,7 @@ firewall:
|
|||||||
- postgres
|
- postgres
|
||||||
- elasticsearch_rest
|
- elasticsearch_rest
|
||||||
- elasticsearch_node
|
- elasticsearch_node
|
||||||
|
- localrules
|
||||||
sensor:
|
sensor:
|
||||||
portgroups:
|
portgroups:
|
||||||
- beats_5044
|
- beats_5044
|
||||||
@@ -386,6 +391,7 @@ firewall:
|
|||||||
- elastic_agent_control
|
- elastic_agent_control
|
||||||
- elastic_agent_data
|
- elastic_agent_data
|
||||||
- elastic_agent_update
|
- elastic_agent_update
|
||||||
|
- localrules
|
||||||
- sensoroni
|
- sensoroni
|
||||||
fleet:
|
fleet:
|
||||||
portgroups:
|
portgroups:
|
||||||
@@ -605,6 +611,7 @@ firewall:
|
|||||||
- elastic_agent_control
|
- elastic_agent_control
|
||||||
- elastic_agent_data
|
- elastic_agent_data
|
||||||
- elastic_agent_update
|
- elastic_agent_update
|
||||||
|
- localrules
|
||||||
- sensoroni
|
- sensoroni
|
||||||
fleet:
|
fleet:
|
||||||
portgroups:
|
portgroups:
|
||||||
@@ -822,6 +829,7 @@ firewall:
|
|||||||
- elastic_agent_control
|
- elastic_agent_control
|
||||||
- elastic_agent_data
|
- elastic_agent_data
|
||||||
- elastic_agent_update
|
- elastic_agent_update
|
||||||
|
- localrules
|
||||||
- sensoroni
|
- sensoroni
|
||||||
fleet:
|
fleet:
|
||||||
portgroups:
|
portgroups:
|
||||||
@@ -1050,6 +1058,7 @@ firewall:
|
|||||||
- elastic_agent_update
|
- elastic_agent_update
|
||||||
- endgame
|
- endgame
|
||||||
- strelka_frontend
|
- strelka_frontend
|
||||||
|
- localrules
|
||||||
fleet:
|
fleet:
|
||||||
portgroups:
|
portgroups:
|
||||||
- elasticsearch_rest
|
- elasticsearch_rest
|
||||||
@@ -1509,6 +1518,7 @@ firewall:
|
|||||||
- elasticsearch_rest
|
- elasticsearch_rest
|
||||||
- elasticsearch_node
|
- elasticsearch_node
|
||||||
- elastic_agent_control
|
- elastic_agent_control
|
||||||
|
- localrules
|
||||||
sensor:
|
sensor:
|
||||||
portgroups:
|
portgroups:
|
||||||
- beats_5044
|
- beats_5044
|
||||||
|
|||||||
@@ -138,6 +138,9 @@ firewall:
|
|||||||
kibana:
|
kibana:
|
||||||
tcp: *tcpsettings
|
tcp: *tcpsettings
|
||||||
udp: *udpsettings
|
udp: *udpsettings
|
||||||
|
localrules:
|
||||||
|
tcp: *tcpsettings
|
||||||
|
udp: *udpsettings
|
||||||
nginx:
|
nginx:
|
||||||
tcp: *tcpsettings
|
tcp: *tcpsettings
|
||||||
udp: *udpsettings
|
udp: *udpsettings
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ def showUsage(args):
|
|||||||
print(' append - Append a list item to a yaml key, if it exists and is a list. Requires KEY and LISTITEM args.', file=sys.stderr)
|
print(' append - Append a list item to a yaml key, if it exists and is a list. Requires KEY and LISTITEM args.', file=sys.stderr)
|
||||||
print(' appendlistobject - Append an object to a yaml list key. Requires KEY and JSON_OBJECT args.', file=sys.stderr)
|
print(' appendlistobject - Append an object to a yaml list key. Requires KEY and JSON_OBJECT args.', file=sys.stderr)
|
||||||
print(' removelistitem - Remove a list item from a yaml key, if it exists and is a list. Requires KEY and LISTITEM args.', file=sys.stderr)
|
print(' removelistitem - Remove a list item from a yaml key, if it exists and is a list. Requires KEY and LISTITEM args.', file=sys.stderr)
|
||||||
print(' purgelistitem - Remove every occurrence of a list item from all lists nested under a yaml key, if it exists. Requires KEY and LISTITEM args.', file=sys.stderr)
|
|
||||||
print(' replacelistobject - Replace a list object based on a condition. Requires KEY, CONDITION_FIELD, CONDITION_VALUE, and JSON_OBJECT args.', file=sys.stderr)
|
print(' replacelistobject - Replace a list object based on a condition. Requires KEY, CONDITION_FIELD, CONDITION_VALUE, and JSON_OBJECT args.', file=sys.stderr)
|
||||||
print(' add - Add a new key and set its value. Fails if key already exists. Requires KEY and VALUE args.', file=sys.stderr)
|
print(' add - Add a new key and set its value. Fails if key already exists. Requires KEY and VALUE args.', file=sys.stderr)
|
||||||
print(' get [-r] - Displays (to stdout) the value stored in the given key. Requires KEY arg. Use -r for raw output without YAML formatting.', file=sys.stderr)
|
print(' get [-r] - Displays (to stdout) the value stored in the given key. Requires KEY arg. Use -r for raw output without YAML formatting.', file=sys.stderr)
|
||||||
@@ -200,33 +199,6 @@ def removelistitem(args):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def purgeListItem(content, listItem):
|
|
||||||
if isinstance(content, dict):
|
|
||||||
for value in content.values():
|
|
||||||
purgeListItem(value, listItem)
|
|
||||||
elif isinstance(content, list):
|
|
||||||
content[:] = [item for item in content if item != listItem]
|
|
||||||
for item in content:
|
|
||||||
purgeListItem(item, listItem)
|
|
||||||
|
|
||||||
|
|
||||||
def purgelistitem(args):
|
|
||||||
if len(args) != 3:
|
|
||||||
print('Missing filename, key arg, or list item to purge', file=sys.stderr)
|
|
||||||
showUsage(None)
|
|
||||||
return 1
|
|
||||||
|
|
||||||
filename = args[0]
|
|
||||||
key = args[1]
|
|
||||||
listItem = args[2]
|
|
||||||
|
|
||||||
content = loadYaml(filename)
|
|
||||||
purgeListItem(getKeyValue(content, key), convertType(listItem))
|
|
||||||
writeYaml(filename, content)
|
|
||||||
|
|
||||||
return 0
|
|
||||||
|
|
||||||
|
|
||||||
def replaceListObjectByCondition(content, key, conditionField, conditionValue, newObject):
|
def replaceListObjectByCondition(content, key, conditionField, conditionValue, newObject):
|
||||||
pieces = key.split(".", 1)
|
pieces = key.split(".", 1)
|
||||||
if len(pieces) > 1:
|
if len(pieces) > 1:
|
||||||
@@ -319,8 +291,6 @@ def add(args):
|
|||||||
|
|
||||||
|
|
||||||
def removeKey(content, key):
|
def removeKey(content, key):
|
||||||
if not isinstance(content, dict):
|
|
||||||
return
|
|
||||||
pieces = key.split(".", 1)
|
pieces = key.split(".", 1)
|
||||||
if len(pieces) > 1:
|
if len(pieces) > 1:
|
||||||
if pieces[0] in content:
|
if pieces[0] in content:
|
||||||
@@ -364,8 +334,6 @@ def replace(args):
|
|||||||
|
|
||||||
|
|
||||||
def getKeyValue(content, key):
|
def getKeyValue(content, key):
|
||||||
if not isinstance(content, dict):
|
|
||||||
return None
|
|
||||||
pieces = key.split(".", 1)
|
pieces = key.split(".", 1)
|
||||||
if len(pieces) > 1 and pieces[0] in content:
|
if len(pieces) > 1 and pieces[0] in content:
|
||||||
return getKeyValue(content[pieces[0]], pieces[1])
|
return getKeyValue(content[pieces[0]], pieces[1])
|
||||||
@@ -417,7 +385,6 @@ def main():
|
|||||||
"append": append,
|
"append": append,
|
||||||
"appendlistobject": appendlistobject,
|
"appendlistobject": appendlistobject,
|
||||||
"removelistitem": removelistitem,
|
"removelistitem": removelistitem,
|
||||||
"purgelistitem": purgelistitem,
|
|
||||||
"replacelistobject": replacelistobject,
|
"replacelistobject": replacelistobject,
|
||||||
"get": get,
|
"get": get,
|
||||||
"remove": remove,
|
"remove": remove,
|
||||||
|
|||||||
@@ -128,22 +128,6 @@ class TestRemove(unittest.TestCase):
|
|||||||
sysmock.assert_called_once_with(1)
|
sysmock.assert_called_once_with(1)
|
||||||
self.assertIn("Missing filename or key arg\n", mock_stderr.getvalue())
|
self.assertIn("Missing filename or key arg\n", mock_stderr.getvalue())
|
||||||
|
|
||||||
def test_remove_null_parent(self):
|
|
||||||
filename = "/tmp/so-yaml_test-remove.yaml"
|
|
||||||
file = open(filename, "w")
|
|
||||||
file.write("key1: null\n")
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
result = soyaml.remove([filename, "key1.child1.deep1"])
|
|
||||||
self.assertEqual(result, 0)
|
|
||||||
|
|
||||||
file = open(filename, "r")
|
|
||||||
actual = file.read()
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
expected = "key1: null\n"
|
|
||||||
self.assertEqual(actual, expected)
|
|
||||||
|
|
||||||
def test_append_missing_arg(self):
|
def test_append_missing_arg(self):
|
||||||
with patch('sys.exit', new=MagicMock()) as sysmock:
|
with patch('sys.exit', new=MagicMock()) as sysmock:
|
||||||
with patch('sys.stderr', new=StringIO()) as mock_stderr:
|
with patch('sys.stderr', new=StringIO()) as mock_stderr:
|
||||||
@@ -581,19 +565,6 @@ class TestRemove(unittest.TestCase):
|
|||||||
self.assertEqual(result, 2)
|
self.assertEqual(result, 2)
|
||||||
self.assertEqual("", mock_stdout.getvalue())
|
self.assertEqual("", mock_stdout.getvalue())
|
||||||
|
|
||||||
def test_get_null_parent(self):
|
|
||||||
with patch('sys.stdout', new=StringIO()) as mock_stdout:
|
|
||||||
with patch('sys.stderr', new=StringIO()) as mock_stderr:
|
|
||||||
filename = "/tmp/so-yaml_test-get.yaml"
|
|
||||||
file = open(filename, "w")
|
|
||||||
file.write("key1: null\n")
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
result = soyaml.get([filename, "key1.child1"])
|
|
||||||
self.assertEqual(result, 2)
|
|
||||||
self.assertEqual("", mock_stdout.getvalue())
|
|
||||||
self.assertIn("Key 'key1.child1' not found by so-yaml.py", mock_stderr.getvalue())
|
|
||||||
|
|
||||||
def test_get_empty_file(self):
|
def test_get_empty_file(self):
|
||||||
with patch('sys.stdout', new=StringIO()) as mock_stdout:
|
with patch('sys.stdout', new=StringIO()) as mock_stdout:
|
||||||
with patch('sys.stderr', new=StringIO()) as mock_stderr:
|
with patch('sys.stderr', new=StringIO()) as mock_stderr:
|
||||||
@@ -738,255 +709,6 @@ class TestRemoveListItem(unittest.TestCase):
|
|||||||
self.assertEqual("The existing value for the given key is not a list. No action was taken on the file.\n", mock_stderr.getvalue())
|
self.assertEqual("The existing value for the given key is not a list. No action was taken on the file.\n", mock_stderr.getvalue())
|
||||||
|
|
||||||
|
|
||||||
class TestPurgeListItem(unittest.TestCase):
|
|
||||||
|
|
||||||
def test_purgelistitem_missing_arg(self):
|
|
||||||
with patch('sys.exit', new=MagicMock()) as sysmock:
|
|
||||||
with patch('sys.stderr', new=StringIO()) as mock_stderr:
|
|
||||||
sys.argv = ["cmd", "help"]
|
|
||||||
soyaml.purgelistitem(["file", "key"])
|
|
||||||
sysmock.assert_called()
|
|
||||||
self.assertIn("Missing filename, key arg, or list item to purge", mock_stderr.getvalue())
|
|
||||||
|
|
||||||
def test_purgelistitem(self):
|
|
||||||
filename = "/tmp/so-yaml_test-purgelistitem.yaml"
|
|
||||||
file = open(filename, "w")
|
|
||||||
file.write("{key1: [a,b,c], key2: false}")
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
soyaml.purgelistitem([filename, "key1", "b"])
|
|
||||||
|
|
||||||
file = open(filename, "r")
|
|
||||||
actual = file.read()
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
expected = "key1:\n- a\n- c\nkey2: false\n"
|
|
||||||
self.assertEqual(actual, expected)
|
|
||||||
|
|
||||||
def test_purgelistitem_nested_lists(self):
|
|
||||||
filename = "/tmp/so-yaml_test-purgelistitem.yaml"
|
|
||||||
file = open(filename, "w")
|
|
||||||
file.write("{key1: { child1: [a,b,c], child2: { deep1: [b,d], deep2: 45 } }, key2: [b,e]}")
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
soyaml.purgelistitem([filename, "key1", "b"])
|
|
||||||
|
|
||||||
file = open(filename, "r")
|
|
||||||
actual = file.read()
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
expected = "key1:\n child1:\n - a\n - c\n child2:\n deep1:\n - d\n deep2: 45\nkey2:\n- b\n- e\n"
|
|
||||||
self.assertEqual(actual, expected)
|
|
||||||
|
|
||||||
def test_purgelistitem_duplicates(self):
|
|
||||||
filename = "/tmp/so-yaml_test-purgelistitem.yaml"
|
|
||||||
file = open(filename, "w")
|
|
||||||
file.write("{key1: [b,a,b,c,b]}")
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
soyaml.purgelistitem([filename, "key1", "b"])
|
|
||||||
|
|
||||||
file = open(filename, "r")
|
|
||||||
actual = file.read()
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
expected = "key1:\n- a\n- c\n"
|
|
||||||
self.assertEqual(actual, expected)
|
|
||||||
|
|
||||||
def test_purgelistitem_list_of_objects(self):
|
|
||||||
filename = "/tmp/so-yaml_test-purgelistitem.yaml"
|
|
||||||
file = open(filename, "w")
|
|
||||||
file.write("{key1: [{name: item1, values: [a,b]}, b, {name: item2, values: [b,c]}]}")
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
soyaml.purgelistitem([filename, "key1", "b"])
|
|
||||||
|
|
||||||
file = open(filename, "r")
|
|
||||||
actual = file.read()
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
expected = "key1:\n- name: item1\n values:\n - a\n- name: item2\n values:\n - c\n"
|
|
||||||
self.assertEqual(actual, expected)
|
|
||||||
|
|
||||||
def test_purgelistitem_typed(self):
|
|
||||||
filename = "/tmp/so-yaml_test-purgelistitem.yaml"
|
|
||||||
file = open(filename, "w")
|
|
||||||
file.write("{key1: [1, '1', 2]}")
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
soyaml.purgelistitem([filename, "key1", "1"])
|
|
||||||
|
|
||||||
file = open(filename, "r")
|
|
||||||
actual = file.read()
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
expected = "key1:\n- '1'\n- 2\n"
|
|
||||||
self.assertEqual(actual, expected)
|
|
||||||
|
|
||||||
def test_purgelistitem_item_not_in_list(self):
|
|
||||||
filename = "/tmp/so-yaml_test-purgelistitem.yaml"
|
|
||||||
file = open(filename, "w")
|
|
||||||
file.write("{key1: { child1: [a,b,c] }}")
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
soyaml.purgelistitem([filename, "key1", "d"])
|
|
||||||
|
|
||||||
file = open(filename, "r")
|
|
||||||
actual = file.read()
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
expected = "key1:\n child1:\n - a\n - b\n - c\n"
|
|
||||||
self.assertEqual(actual, expected)
|
|
||||||
|
|
||||||
def test_purgelistitem_key_noexist(self):
|
|
||||||
filename = "/tmp/so-yaml_test-purgelistitem.yaml"
|
|
||||||
file = open(filename, "w")
|
|
||||||
file.write("{key1: [a,b,c]}")
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
result = soyaml.purgelistitem([filename, "key2.child1", "b"])
|
|
||||||
self.assertEqual(result, 0)
|
|
||||||
|
|
||||||
file = open(filename, "r")
|
|
||||||
actual = file.read()
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
expected = "key1:\n- a\n- b\n- c\n"
|
|
||||||
self.assertEqual(actual, expected)
|
|
||||||
|
|
||||||
def test_purgelistitem_key_noexist_deep(self):
|
|
||||||
filename = "/tmp/so-yaml_test-purgelistitem.yaml"
|
|
||||||
file = open(filename, "w")
|
|
||||||
file.write("{key1: { child1: [a,b,c] }}")
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
result = soyaml.purgelistitem([filename, "key1.child2.deep1", "b"])
|
|
||||||
self.assertEqual(result, 0)
|
|
||||||
|
|
||||||
file = open(filename, "r")
|
|
||||||
actual = file.read()
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
expected = "key1:\n child1:\n - a\n - b\n - c\n"
|
|
||||||
self.assertEqual(actual, expected)
|
|
||||||
|
|
||||||
def test_purgelistitem_scalar_and_null_values(self):
|
|
||||||
filename = "/tmp/so-yaml_test-purgelistitem.yaml"
|
|
||||||
file = open(filename, "w")
|
|
||||||
file.write("{key1: { child1: b, child2: null, child3: [b] }}")
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
soyaml.purgelistitem([filename, "key1", "b"])
|
|
||||||
|
|
||||||
file = open(filename, "r")
|
|
||||||
actual = file.read()
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
expected = "key1:\n child1: b\n child2: null\n child3: []\n"
|
|
||||||
self.assertEqual(actual, expected)
|
|
||||||
|
|
||||||
def test_purgelistitem_lists_of_lists(self):
|
|
||||||
filename = "/tmp/so-yaml_test-purgelistitem.yaml"
|
|
||||||
file = open(filename, "w")
|
|
||||||
file.write("{key1: [[a,b], [b,[b,c]], b]}")
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
soyaml.purgelistitem([filename, "key1", "b"])
|
|
||||||
|
|
||||||
file = open(filename, "r")
|
|
||||||
actual = file.read()
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
expected = "key1:\n- - a\n- - - c\n"
|
|
||||||
self.assertEqual(actual, expected)
|
|
||||||
|
|
||||||
def test_purgelistitem_file_object(self):
|
|
||||||
filename = "/tmp/so-yaml_test-purgelistitem.yaml"
|
|
||||||
file = open(filename, "w")
|
|
||||||
file.write("{key1: [{name: x}, a, {name: y}, {name: x}]}")
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
itemfile = "/tmp/so-yaml_test-purgelistitem-item.yaml"
|
|
||||||
file = open(itemfile, "w")
|
|
||||||
file.write("name: x\n")
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
soyaml.purgelistitem([filename, "key1", "file:" + itemfile])
|
|
||||||
|
|
||||||
file = open(filename, "r")
|
|
||||||
actual = file.read()
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
expected = "key1:\n- a\n- name: y\n"
|
|
||||||
self.assertEqual(actual, expected)
|
|
||||||
|
|
||||||
def test_purgelistitem_main(self):
|
|
||||||
filename = "/tmp/so-yaml_test-purgelistitem.yaml"
|
|
||||||
file = open(filename, "w")
|
|
||||||
file.write("{key1: { child1: [a,b,c] }, key2: [b]}")
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
with patch('sys.exit', new=MagicMock()) as sysmock:
|
|
||||||
sys.argv = ["cmd", "purgelistitem", filename, "key1", "b"]
|
|
||||||
soyaml.main()
|
|
||||||
sysmock.assert_called_once_with(0)
|
|
||||||
|
|
||||||
file = open(filename, "r")
|
|
||||||
actual = file.read()
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
expected = "key1:\n child1:\n - a\n - c\nkey2:\n- b\n"
|
|
||||||
self.assertEqual(actual, expected)
|
|
||||||
|
|
||||||
def test_purgelistitem_with_remove(self):
|
|
||||||
filename = "/tmp/so-yaml_test-purgelistitem.yaml"
|
|
||||||
file = open(filename, "w")
|
|
||||||
file.write("{key1: { child1: { deep1: [a] }, child2: [b] }, key2: { group1: { items: [x,child1,y] }, group2: { items: [child1] } }}")
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
soyaml.remove([filename, "key1.child1"])
|
|
||||||
soyaml.purgelistitem([filename, "key2", "child1"])
|
|
||||||
|
|
||||||
file = open(filename, "r")
|
|
||||||
actual = file.read()
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
expected = "key1:\n child2:\n - b\nkey2:\n group1:\n items:\n - x\n - y\n group2:\n items: []\n"
|
|
||||||
self.assertEqual(actual, expected)
|
|
||||||
|
|
||||||
def test_purgelistitem_null_parent(self):
|
|
||||||
filename = "/tmp/so-yaml_test-purgelistitem.yaml"
|
|
||||||
file = open(filename, "w")
|
|
||||||
file.write("key1: null\n")
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
result = soyaml.purgelistitem([filename, "key1.child1", "b"])
|
|
||||||
self.assertEqual(result, 0)
|
|
||||||
|
|
||||||
file = open(filename, "r")
|
|
||||||
actual = file.read()
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
expected = "key1: null\n"
|
|
||||||
self.assertEqual(actual, expected)
|
|
||||||
|
|
||||||
def test_purgelistitem_non_dict_parent(self):
|
|
||||||
filename = "/tmp/so-yaml_test-purgelistitem.yaml"
|
|
||||||
file = open(filename, "w")
|
|
||||||
file.write("key1:\n- a\n- b\n")
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
result = soyaml.purgelistitem([filename, "key1.child1", "b"])
|
|
||||||
self.assertEqual(result, 0)
|
|
||||||
|
|
||||||
file = open(filename, "r")
|
|
||||||
actual = file.read()
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
expected = "key1:\n- a\n- b\n"
|
|
||||||
self.assertEqual(actual, expected)
|
|
||||||
|
|
||||||
|
|
||||||
class TestAppendListObject(unittest.TestCase):
|
class TestAppendListObject(unittest.TestCase):
|
||||||
|
|
||||||
def test_appendlistobject_missing_arg(self):
|
def test_appendlistobject_missing_arg(self):
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
# 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.
|
||||||
|
|
||||||
|
|
||||||
. /usr/sbin/so-common
|
. /usr/sbin/so-common
|
||||||
. /usr/sbin/so-image-common
|
. /usr/sbin/so-image-common
|
||||||
|
|
||||||
@@ -16,7 +17,6 @@ INSTALLEDVERSION=$(cat /etc/soversion)
|
|||||||
# not finish its post-upgrade steps; its contents are the resume point. It is read
|
# not finish its post-upgrade steps; its contents are the resume point. It is read
|
||||||
# here before preupgrade_changes mutates INSTALLEDVERSION and before any highstate
|
# here before preupgrade_changes mutates INSTALLEDVERSION and before any highstate
|
||||||
# stamps /etc/soversion from the pillar.
|
# stamps /etc/soversion from the pillar.
|
||||||
|
|
||||||
POSTVERSION_FILE=/etc/sopostversion
|
POSTVERSION_FILE=/etc/sopostversion
|
||||||
|
|
||||||
if [ -f "$POSTVERSION_FILE" ]; then
|
if [ -f "$POSTVERSION_FILE" ]; then
|
||||||
@@ -55,6 +55,7 @@ fi
|
|||||||
# used to display messages to the user at the end of soup
|
# used to display messages to the user at the end of soup
|
||||||
declare -a FINAL_MESSAGE_QUEUE=()
|
declare -a FINAL_MESSAGE_QUEUE=()
|
||||||
SOUP_ERR_CONTEXT=
|
SOUP_ERR_CONTEXT=
|
||||||
|
TELEGRAF_REPAIR_RAN=
|
||||||
|
|
||||||
|
|
||||||
check_err() {
|
check_err() {
|
||||||
@@ -528,7 +529,6 @@ preupgrade_changes() {
|
|||||||
[[ "$INSTALLEDVERSION" == "3.1.0" ]] && up_to_3.2.0
|
[[ "$INSTALLEDVERSION" == "3.1.0" ]] && up_to_3.2.0
|
||||||
[[ "$INSTALLEDVERSION" == "3.2.0" ]] && up_to_3.3.0
|
[[ "$INSTALLEDVERSION" == "3.2.0" ]] && up_to_3.3.0
|
||||||
[[ "$INSTALLEDVERSION" == "3.3.0" ]] && up_to_3.4.0
|
[[ "$INSTALLEDVERSION" == "3.3.0" ]] && up_to_3.4.0
|
||||||
[[ "$INSTALLEDVERSION" == "3.4.0" ]] && up_to_3.5.0
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1064,6 +1064,17 @@ up_to_3.3.0() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
telegraf_repair() {
|
telegraf_repair() {
|
||||||
|
# post_to_3.3.0 and post_to_3.5.0 both call this; run it once per soup.
|
||||||
|
[[ -n "$TELEGRAF_REPAIR_RAN" ]] && return 0
|
||||||
|
TELEGRAF_REPAIR_RAN=true
|
||||||
|
local output
|
||||||
|
output=$(salt-call pillar.get telegraf:output --out=newline_values_only)
|
||||||
|
output=$(tr -d '[:space:]' <<<"$output" | tr '[:lower:]' '[:upper:]')
|
||||||
|
output=${output:-INFLUXDB}
|
||||||
|
case "$output" in
|
||||||
|
POSTGRES|BOTH) ;;
|
||||||
|
*) return 0 ;;
|
||||||
|
esac
|
||||||
# Only grids whose Telegraf partitions stalled need this; --check exits 1
|
# Only grids whose Telegraf partitions stalled need this; --check exits 1
|
||||||
# when there is something to repair, so everyone else is left alone.
|
# when there is something to repair, so everyone else is left alone.
|
||||||
local repair=/usr/sbin/so-telegraf-repair
|
local repair=/usr/sbin/so-telegraf-repair
|
||||||
@@ -1220,23 +1231,6 @@ add_detection_runtime_fields() {
|
|||||||
### 3.4.0 End ###
|
### 3.4.0 End ###
|
||||||
|
|
||||||
### 3.5.0 Scripts ###
|
### 3.5.0 Scripts ###
|
||||||
up_to_3.5.0() {
|
|
||||||
remove_localrules_portgroup
|
|
||||||
|
|
||||||
INSTALLEDVERSION=3.5.0
|
|
||||||
}
|
|
||||||
|
|
||||||
remove_localrules_portgroup() {
|
|
||||||
local pillar_file
|
|
||||||
|
|
||||||
for pillar_file in /opt/so/saltstack/local/pillar/firewall/{soc,adv}_firewall.sls; do
|
|
||||||
grep -qs localrules "$pillar_file" || continue
|
|
||||||
so-yaml.py get "$pillar_file" firewall 2>/dev/null | grep -q '\<localrules\>' || continue
|
|
||||||
echo "Removing the localrules portgroup from $pillar_file."
|
|
||||||
so-yaml.py remove "$pillar_file" firewall.portgroups.localrules
|
|
||||||
so-yaml.py purgelistitem "$pillar_file" firewall.role localrules
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
post_to_3.5.0() {
|
post_to_3.5.0() {
|
||||||
telegraf_repair
|
telegraf_repair
|
||||||
|
|||||||
+16
-12
@@ -10,25 +10,29 @@
|
|||||||
{% from 'docker/docker.map.jinja' import DOCKERMERGED %}
|
{% from 'docker/docker.map.jinja' import DOCKERMERGED %}
|
||||||
{% from 'nginx/map.jinja' import NGINXMERGED %}
|
{% from 'nginx/map.jinja' import NGINXMERGED %}
|
||||||
|
|
||||||
{% if GLOBALS.role != 'so-fleet' %}
|
|
||||||
{% set container_config = 'so-nginx' %}
|
|
||||||
{% else %}
|
|
||||||
{# if this is an so-fleet node then we want to use the port bindings, custom bind mounts defined for fleet #}
|
|
||||||
{% set container_config = 'so-nginx-fleet-node' %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
include:
|
include:
|
||||||
- ca.trust
|
- ca.trust
|
||||||
- nginx.ssl
|
- nginx.ssl
|
||||||
- nginx.config
|
- nginx.config
|
||||||
- nginx.sostatus
|
- nginx.sostatus
|
||||||
|
|
||||||
fleet_beats_dir_nginx:
|
{% if GLOBALS.role != 'so-fleet' %}
|
||||||
|
{% set container_config = 'so-nginx' %}
|
||||||
|
make-rule-dir-nginx:
|
||||||
file.directory:
|
file.directory:
|
||||||
- name: /nsm/elastic-fleet/artifacts/beats
|
- name: /nsm/rules
|
||||||
- makedirs: True
|
- user: socore
|
||||||
|
- group: socore
|
||||||
|
- recurse:
|
||||||
|
- user
|
||||||
|
- group
|
||||||
- show_changes: False
|
- show_changes: False
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
{# if this is an so-fleet node then we want to use the port bindings, custom bind mounts defined for fleet #}
|
||||||
|
{% set container_config = 'so-nginx-fleet-node' %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
so-nginx:
|
so-nginx:
|
||||||
docker_container.running:
|
docker_container.running:
|
||||||
- image: {{ GLOBALS.registry_host }}:5000/{{ GLOBALS.image_repo }}/so-nginx:{{ GLOBALS.so_version }}
|
- image: {{ GLOBALS.registry_host }}:5000/{{ GLOBALS.image_repo }}/so-nginx:{{ GLOBALS.so_version }}
|
||||||
@@ -50,7 +54,7 @@ so-nginx:
|
|||||||
- /opt/so/log/nginx/:/var/log/nginx:rw
|
- /opt/so/log/nginx/:/var/log/nginx:rw
|
||||||
- /opt/so/tmp/nginx/:/var/lib/nginx:rw
|
- /opt/so/tmp/nginx/:/var/lib/nginx:rw
|
||||||
- /opt/so/tmp/nginx/:/run:rw
|
- /opt/so/tmp/nginx/:/run:rw
|
||||||
- /nsm/elastic-fleet/artifacts/beats/:/opt/socore/elastic-artifacts/artifacts/beats:ro
|
- /nsm/elastic-fleet/artifacts/:/opt/socore/elastic-artifacts/artifacts:ro
|
||||||
{% if GLOBALS.is_manager %}
|
{% if GLOBALS.is_manager %}
|
||||||
- /nsm/elastic-fleet/so_agent-installers/:/opt/socore/html/packages
|
- /nsm/elastic-fleet/so_agent-installers/:/opt/socore/html/packages
|
||||||
- /etc/pki/managerssl.crt:/etc/pki/nginx/server.crt:ro
|
- /etc/pki/managerssl.crt:/etc/pki/nginx/server.crt:ro
|
||||||
@@ -60,6 +64,7 @@ so-nginx:
|
|||||||
- /opt/so/conf/navigator/config.json:/opt/socore/html/navigator/assets/config.json:ro
|
- /opt/so/conf/navigator/config.json:/opt/socore/html/navigator/assets/config.json:ro
|
||||||
- /nsm/repo:/opt/socore/html/repo:ro
|
- /nsm/repo:/opt/socore/html/repo:ro
|
||||||
- /nsm/kernelrepo:/opt/socore/html/kernelrepo:ro
|
- /nsm/kernelrepo:/opt/socore/html/kernelrepo:ro
|
||||||
|
- /nsm/rules:/nsm/rules:ro
|
||||||
{% if NGINXMERGED.external_suricata %}
|
{% if NGINXMERGED.external_suricata %}
|
||||||
- /opt/so/rules/nids/suri:/surirules:ro
|
- /opt/so/rules/nids/suri:/surirules:ro
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -101,7 +106,6 @@ so-nginx:
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
- require:
|
- require:
|
||||||
- file: nginxconf
|
- file: nginxconf
|
||||||
- file: fleet_beats_dir_nginx
|
|
||||||
{% if GLOBALS.is_manager %}
|
{% if GLOBALS.is_manager %}
|
||||||
{% if NGINXMERGED.ssl.replace_cert %}
|
{% if NGINXMERGED.ssl.replace_cert %}
|
||||||
- file: managerssl_key
|
- file: managerssl_key
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ http {
|
|||||||
server_name {{ GLOBALS.hostname }};
|
server_name {{ GLOBALS.hostname }};
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
root /opt/socore/elastic-artifacts;
|
root /opt/socore/elastic-artifacts;
|
||||||
location /artifacts/beats/ {
|
location /artifacts/ {
|
||||||
try_files $uri =404;
|
try_files $uri =404;
|
||||||
}
|
}
|
||||||
location / {
|
location / {
|
||||||
@@ -92,6 +92,21 @@ http {
|
|||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
{%- if GLOBALS.is_manager %}
|
{%- if GLOBALS.is_manager %}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 7788;
|
||||||
|
server_name {{ full_server_name }};
|
||||||
|
root /nsm/rules;
|
||||||
|
location / {
|
||||||
|
allow all;
|
||||||
|
sendfile on;
|
||||||
|
sendfile_max_chunk 1m;
|
||||||
|
autoindex on;
|
||||||
|
autoindex_exact_size off;
|
||||||
|
autoindex_format html;
|
||||||
|
autoindex_localtime on;
|
||||||
|
}
|
||||||
|
}
|
||||||
{%- if NGINXMERGED.external_suricata %}
|
{%- if NGINXMERGED.external_suricata %}
|
||||||
server {
|
server {
|
||||||
listen 7789 ssl;
|
listen 7789 ssl;
|
||||||
|
|||||||
@@ -251,16 +251,6 @@ socsensoronirepos:
|
|||||||
- mode: 775
|
- mode: 775
|
||||||
- makedirs: True
|
- makedirs: True
|
||||||
|
|
||||||
nsm_rules_dir:
|
|
||||||
file.directory:
|
|
||||||
- name: /nsm/rules
|
|
||||||
- user: socore
|
|
||||||
- group: socore
|
|
||||||
- recurse:
|
|
||||||
- user
|
|
||||||
- group
|
|
||||||
- show_changes: False
|
|
||||||
|
|
||||||
create_custom_local_yara_repo_template:
|
create_custom_local_yara_repo_template:
|
||||||
git.present:
|
git.present:
|
||||||
- name: /nsm/rules/custom-local-repos/local-yara
|
- name: /nsm/rules/custom-local-repos/local-yara
|
||||||
|
|||||||
Reference in new issue
Block a user