diff --git a/bindep.txt b/bindep.txt new file mode 100644 index 0000000..cab23f9 --- /dev/null +++ b/bindep.txt @@ -0,0 +1,8 @@ +# This is a cross-platform list tracking distribution packages needed by tests; +# see https://docs.openstack.org/infra/bindep/ for additional information. + +gcc-c++ [doc test platform:rpm] +python3-devel [test platform:rpm] +python3 [test platform:rpm] +libssh-devel [test platform:rpm] +libssh-dev [test platform:dpkg] diff --git a/changelogs/fragments/bindep_update.yaml b/changelogs/fragments/bindep_update.yaml new file mode 100644 index 0000000..b73614f --- /dev/null +++ b/changelogs/fragments/bindep_update.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - "Add bindep file for installation of correct dependencies." diff --git a/plugins/action/deepsec_anti_malwares.py b/plugins/action/deepsec_anti_malwares.py index a92bac6..71a86f1 100644 --- a/plugins/action/deepsec_anti_malwares.py +++ b/plugins/action/deepsec_anti_malwares.py @@ -47,8 +47,7 @@ class ActionModule(ActionBase): - """ action module - """ + """action module""" def __init__(self, *args, **kwargs): super(ActionModule, self).__init__(*args, **kwargs) @@ -353,16 +352,18 @@ def run(self, tmp=None, task_vars=None): or self._task.args["state"] == "replaced" ): if self._task.args.get("config"): - self._result[self.module_return], self._result[ - "changed" - ] = self.configure_module_api( + ( + self._result[self.module_return], + self._result["changed"], + ) = self.configure_module_api( conn_request, self._task.args["config"] ) elif self._task.args["state"] == "deleted": if self._task.args.get("config"): - self._result[self.module_return], self._result[ - "changed" - ] = self.delete_module_api_config( + ( + self._result[self.module_return], + self._result["changed"], + ) = self.delete_module_api_config( conn_request, self._task.args["config"] ) diff --git a/plugins/action/deepsec_firewall_rules.py b/plugins/action/deepsec_firewall_rules.py index 13d0bf0..3606f18 100644 --- a/plugins/action/deepsec_firewall_rules.py +++ b/plugins/action/deepsec_firewall_rules.py @@ -32,8 +32,7 @@ class ActionModule(ActionBase): - """ action module - """ + """action module""" def __init__(self, *args, **kwargs): super(ActionModule, self).__init__(*args, **kwargs) @@ -342,16 +341,18 @@ def run(self, tmp=None, task_vars=None): or self._task.args["state"] == "replaced" ): if self._task.args.get("config"): - self._result[self.module_return], self._result[ - "changed" - ] = self.configure_module_api( + ( + self._result[self.module_return], + self._result["changed"], + ) = self.configure_module_api( conn_request, self._task.args["config"] ) elif self._task.args["state"] == "deleted": if self._task.args.get("config"): - self._result[self.module_return], self._result[ - "changed" - ] = self.delete_module_api_config( + ( + self._result[self.module_return], + self._result["changed"], + ) = self.delete_module_api_config( conn_request, self._task.args["config"] ) diff --git a/plugins/action/deepsec_integrity_monitoring_rules.py b/plugins/action/deepsec_integrity_monitoring_rules.py index 3708120..21dbe70 100644 --- a/plugins/action/deepsec_integrity_monitoring_rules.py +++ b/plugins/action/deepsec_integrity_monitoring_rules.py @@ -32,8 +32,7 @@ class ActionModule(ActionBase): - """ action module - """ + """action module""" def __init__(self, *args, **kwargs): super(ActionModule, self).__init__(*args, **kwargs) @@ -318,16 +317,18 @@ def run(self, tmp=None, task_vars=None): or self._task.args["state"] == "replaced" ): if self._task.args.get("config"): - self._result[self.module_return], self._result[ - "changed" - ] = self.configure_module_api( + ( + self._result[self.module_return], + self._result["changed"], + ) = self.configure_module_api( conn_request, self._task.args["config"] ) elif self._task.args["state"] == "deleted": if self._task.args.get("config"): - self._result[self.module_return], self._result[ - "changed" - ] = self.delete_module_api_config( + ( + self._result[self.module_return], + self._result["changed"], + ) = self.delete_module_api_config( conn_request, self._task.args["config"] ) diff --git a/plugins/action/deepsec_intrusion_prevention_rules.py b/plugins/action/deepsec_intrusion_prevention_rules.py index f0f4e2f..33542c9 100644 --- a/plugins/action/deepsec_intrusion_prevention_rules.py +++ b/plugins/action/deepsec_intrusion_prevention_rules.py @@ -43,8 +43,7 @@ class ActionModule(ActionBase): - """ action module - """ + """action module""" def __init__(self, *args, **kwargs): super(ActionModule, self).__init__(*args, **kwargs) @@ -126,8 +125,10 @@ def search_for_ipr_name(self, deepsec_conn_request, search_ipr_by_names): } ], } - temp_search_response = self.search_for_intrusion_prevention_rules( - deepsec_conn_request, search_payload + temp_search_response = ( + self.search_for_intrusion_prevention_rules( + deepsec_conn_request, search_payload + ) ) if ( temp_search_response.get("intrusionPreventionRules") @@ -241,7 +242,10 @@ def configure_module_api(self, deepsec_conn_request, module_config_params): payload = map_params_to_obj( each, self.key_transform ) - response_code, api_response = deepsec_conn_request.post( + ( + response_code, + api_response, + ) = deepsec_conn_request.post( "{0}/{1}".format(self.api_object, every["id"]), data=payload, ) @@ -256,7 +260,10 @@ def configure_module_api(self, deepsec_conn_request, module_config_params): ) ) elif self._task.args["state"] == "replaced": - response_code, api_response = deepsec_conn_request.delete( + ( + response_code, + api_response, + ) = deepsec_conn_request.delete( "{0}/{1}".format(self.api_object, every["id"]), data=each, ) @@ -267,7 +274,10 @@ def configure_module_api(self, deepsec_conn_request, module_config_params): payload = map_params_to_obj( each, self.key_transform ) - response_code, api_response = deepsec_conn_request.post( + ( + response_code, + api_response, + ) = deepsec_conn_request.post( "{0}".format(self.api_object), data=payload ) self._check_for_response_code( @@ -334,16 +344,18 @@ def run(self, tmp=None, task_vars=None): or self._task.args["state"] == "replaced" ): if self._task.args.get("config"): - self._result[self.module_return], self._result[ - "changed" - ] = self.configure_module_api( + ( + self._result[self.module_return], + self._result["changed"], + ) = self.configure_module_api( deepsec_conn_request, self._task.args["config"] ) elif self._task.args["state"] == "deleted": if self._task.args.get("config"): - self._result[self.module_return], self._result[ - "changed" - ] = self.delete_module_api_config( + ( + self._result[self.module_return], + self._result["changed"], + ) = self.delete_module_api_config( deepsec_conn_request, self._task.args["config"] ) diff --git a/plugins/action/deepsec_log_inspection_rules.py b/plugins/action/deepsec_log_inspection_rules.py index b4d3be2..d0e5052 100644 --- a/plugins/action/deepsec_log_inspection_rules.py +++ b/plugins/action/deepsec_log_inspection_rules.py @@ -32,8 +32,7 @@ class ActionModule(ActionBase): - """ action module - """ + """action module""" def __init__(self, *args, **kwargs): super(ActionModule, self).__init__(*args, **kwargs) @@ -401,16 +400,18 @@ def run(self, tmp=None, task_vars=None): or self._task.args["state"] == "replaced" ): if self._task.args.get("config"): - self._result[self.module_return], self._result[ - "changed" - ] = self.configure_module_api( + ( + self._result[self.module_return], + self._result["changed"], + ) = self.configure_module_api( conn_request, self._task.args["config"] ) elif self._task.args["state"] == "deleted": if self._task.args.get("config"): - self._result[self.module_return], self._result[ - "changed" - ] = self.delete_module_api_config( + ( + self._result[self.module_return], + self._result["changed"], + ) = self.delete_module_api_config( conn_request, self._task.args["config"] ) diff --git a/plugins/module_utils/deepsec.py b/plugins/module_utils/deepsec.py index 46e37c8..a34c0ae 100644 --- a/plugins/module_utils/deepsec.py +++ b/plugins/module_utils/deepsec.py @@ -45,7 +45,7 @@ def remove_get_keys_from_payload_dict(payload_dict, remove_key_list): def map_params_to_obj(module_params, key_transform): - """ The fn to convert the api returned params to module params + """The fn to convert the api returned params to module params :param module_params: Module params :param key_transform: Dict with module equivalent API params :rtype: A dict @@ -65,7 +65,7 @@ def map_params_to_obj(module_params, key_transform): def map_obj_to_params(module_return_params, key_transform, return_param): - """ The fn to convert the api returned params to module params + """The fn to convert the api returned params to module params :param module_return_params: API returned response params :param key_transform: Module params :rtype: A dict @@ -105,7 +105,7 @@ def check_if_config_exists( field_name="name", api_request="post", ): - """ The fn check if the config_name detect based on config + """The fn check if the config_name detect based on config :param deepsec_request: the objects from which the configuration should be read :param config_name: config_name rule with which config will be searched :param api: REST API for which search POST call is made @@ -146,7 +146,7 @@ def delete_config_with_id( api_or_rest=True, handle_return=False, ): - """ The fn calls the delete API based on the config id + """The fn calls the delete API based on the config id :param deepsec_request: connection obj for TM :param config_id: config id for the config that's supposed to be deleted :param api_or_rest: Fire request for legacy or latest API call diff --git a/plugins/modules/deepsec_log_inspectionrules.py b/plugins/modules/deepsec_log_inspectionrules.py index 87f0b12..cd4a8ea 100644 --- a/plugins/modules/deepsec_log_inspectionrules.py +++ b/plugins/modules/deepsec_log_inspectionrules.py @@ -281,7 +281,7 @@ def map_params_to_obj(module_params): def check_if_log_inspection_rules_exists(deepsec_request, log_inspection_name): - """ The fn check if the log_inspection detect based on log_inspection name + """The fn check if the log_inspection detect based on log_inspection name :param deepsec_request: the objects from which the configuration should be read :param log_inspection_name: log_inspection name with which log_inspection will be searched in existing log_inspection configurations @@ -305,7 +305,7 @@ def check_if_log_inspection_rules_exists(deepsec_request, log_inspection_name): def delete_log_inspection_with_id(module, deepsec_request, log_inspection_id): - """ The fn calls the delete API based on the log_inspection id + """The fn calls the delete API based on the log_inspection id :param module: ansible module object :param deepsec_request: connection obj for TM :param log_inspection_id: log_inspection id for the log_inspection that's supposed to be deleted diff --git a/test-requirements.txt b/test-requirements.txt index 538e15f..d8ec9ca 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,4 +1,4 @@ -black==19.3b0 ; python_version > '3.5' +black==22.3.0 ; python_version > '3.5' coverage==4.5.4 flake8 mock ; python_version < '3.5'