From 3eed504bb8f1ca01e25592e7ad40a80bf59108b3 Mon Sep 17 00:00:00 2001 From: maclin-masterson Date: Fri, 1 Dec 2023 11:17:19 -0500 Subject: [PATCH 1/2] Make sure that keys exist in update_security_rule() We were hitting an error where the 'revision' key didn't exist. Updating the code to check to make sure that the key exists before getting rid of it with pop() Moved all of the keys into a list so we can check for the existence of the keys in a for loop --- plugins/module_utils/kibana.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/plugins/module_utils/kibana.py b/plugins/module_utils/kibana.py index 6d7e518..00e02e3 100644 --- a/plugins/module_utils/kibana.py +++ b/plugins/module_utils/kibana.py @@ -371,17 +371,24 @@ def get_security_rule_byid(self, rule_id): def update_security_rule(self, body): endpoint = "detection_engine/rules" rule_object = self.get_security_rule_byid(body['id']) - rule_object.pop('updated_at') - rule_object.pop('updated_by') - rule_object.pop('created_at') - rule_object.pop('created_by') - rule_object.pop('execution_summary') - rule_object.pop('rule_id') - rule_object.pop('related_integrations') - rule_object.pop('immutable') - rule_object.pop('required_fields') - rule_object.pop('setup') - rule_object.pop('revision') + keys_to_remove = [ + 'updated_at', + 'updated_by', + 'created_at', + 'created_by', + 'execution_summary', + 'rule_id', + 'related_integrations', + 'immutable', + 'required_fields', + 'setup', + 'revision' + ] + + for key in keys_to_remove: + if key in rule_object: + rule_object.pop(key) + rule_object.update(body) update_rule = self.send_api_request(endpoint, 'PUT', data=rule_object) return update_rule From 541e4c743c86d8bef0552ab3ceff515cb9a81084 Mon Sep 17 00:00:00 2001 From: maclin-masterson Date: Fri, 1 Dec 2023 11:55:38 -0500 Subject: [PATCH 2/2] patch release --- galaxy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/galaxy.yml b/galaxy.yml index d422984..3195018 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -13,7 +13,7 @@ # limitations under the License. --- -version: 2.4.1 +version: 2.4.2 namespace: expedient name: elastic readme: README.md