def _get_clean_directory_path(path_leader, dir_path):
    # Strip out any .. or . relative directories and remove duplicate slashes
    dir_path = re.sub('/[\./]*/?', '/', dir_path)
    dir_path = re.sub('//+', '/', dir_path)

    # Prevents the directory path from being a substring of the path leader.
    # os.path.join('/usr/local/ocw', '/usr/local') gives '/usr/local'
    # which could allow access to unacceptable paths. This also means that
    if dir_path[0] == '/': dir_path = dir_path[1:]

    return os.path.join(path_leader, dir_path)
Select rules from the security groups the port is member of.
dataset/ETHPy150Open apache/climate/ocw-ui/backend/directory_helpers.py/_get_clean_directory_path--crossover with--dataset/ETHPy150Open openstack/neutron/neutron/agent/linux/iptables_firewall.py/IptablesFirewallDriver._select_sg_rules_for_port