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): """ 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)