From 6cfa1926a12ea7f902479fab247afbe4e97be87a Mon Sep 17 00:00:00 2001 From: root Date: Thu, 25 Feb 2021 09:32:40 +0100 Subject: [PATCH 1/2] fixed check funtion in mgmtroot directory --- ibmsecurity/isam/web/reverse_proxy/management_root/directory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibmsecurity/isam/web/reverse_proxy/management_root/directory.py b/ibmsecurity/isam/web/reverse_proxy/management_root/directory.py index 34ee995d..0f9bf0cf 100644 --- a/ibmsecurity/isam/web/reverse_proxy/management_root/directory.py +++ b/ibmsecurity/isam/web/reverse_proxy/management_root/directory.py @@ -22,7 +22,7 @@ def get(isamAppliance, instance_id, dir_name='', recursive='yes', check_mode=Fal def _check(isamAppliance, instance_id, id, name): ret_obj = get(isamAppliance, instance_id) - dir_name = os.path.join(id, name) + dir_name = id +"/" + name return _parse_id(ret_obj['data'], dir_name) From 4ff75652240ff982c4de9509f7a630579a3d6a5c Mon Sep 17 00:00:00 2001 From: Ivan Yartsev Date: Fri, 26 Feb 2021 13:33:48 +0100 Subject: [PATCH 2/2] Mapping Rule check javascript fileName in set --- ibmsecurity/isam/aac/mapping_rules.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/ibmsecurity/isam/aac/mapping_rules.py b/ibmsecurity/isam/aac/mapping_rules.py index 1974b1f0..007b6fe8 100644 --- a/ibmsecurity/isam/aac/mapping_rules.py +++ b/ibmsecurity/isam/aac/mapping_rules.py @@ -67,7 +67,13 @@ def set(isamAppliance, name, category, filename=None, content=None, upload_filen """ if _check(isamAppliance, name=name) is False: - # Force the add - we already know connection does not exist + # Force the add - we already know Mapping Rule does not exist + if upload_filename is not None: + # Check if another Mapping Rule with the same js exists + another_name = _get_name_by_jsname(isamAppliance,upload_filename) + if another_name is not None: + #Another Mapping rule with the same js exists -> delete existing rule before adding + delete(isamAppliance,another_name) return add(isamAppliance, name=name, filename=filename, content=content, category=category, upload_filename=upload_filename, check_mode=check_mode, force=True) else: @@ -261,12 +267,23 @@ def _check(isamAppliance, name): """ ret_obj = get_all(isamAppliance) - for obj in ret_obj['data']: + for obj in ret_obj['data']: if obj['name'] == name: return True return False +def _get_name_by_jsname(isamAppliance, js_name): + """ + Check if Mapping Rules with given filename already exists + Return Mapping Rule name if found + """ + js_name = _extract_filename(js_name) + ret_obj = get_all(isamAppliance) + for obj in ret_obj['data']: + if obj['fileName'] == js_name: + return obj['name'] + return None def compare(isamAppliance1, isamAppliance2): """