예제 #1
0
파일: posix.py 프로젝트: msauria/galaxy
    def _safe_directory(self, directory):
        if self.enforce_symlink_security:
            if not safe_path(directory, allowlist=self._allowlist):
                raise exceptions.ConfigDoesNotAllowException(f'directory ({directory}) is a symlink to a location not on the allowlist')

        if not os.path.exists(directory):
            return False
        return True
예제 #2
0
    def __safe_directory(self, directory, whitelist=None):
        """
        Checks to see if the directory is contained within itself or the whitelist, and whether it exists

        :param directory:   the directory to check for safety
        :type directory:    string
        :param whitelist:   a list of acceptable paths to import from
        :type whitelist:    comma separated list of strings
        :return:            ``True`` if the path is safe to import from, ``False`` otherwise
        """
        if not safe_path(directory, whitelist=whitelist):
            raise exceptions.ConfigDoesNotAllowException('directory (%s) is a symlink to a location not on the whitelist' % directory)
        if not os.path.exists(directory):
            return False
        return True
예제 #3
0
    def __safe_directory(self, directory, whitelist=None):
        """
        Checks to see if the directory is contained within itself or the whitelist, and whether it exists

        :param directory:   the directory to check for safety
        :type directory:    string
        :param whitelist:   a list of acceptable paths to import from
        :type whitelist:    comma separated list of strings
        :return:            ``True`` if the path is safe to import from, ``False`` otherwise
        """
        if not safe_path(directory, whitelist=whitelist):
            raise exceptions.ConfigDoesNotAllowException(
                'directory (%s) is a symlink to a location not on the whitelist'
                % directory)
        if not os.path.exists(directory):
            return False
        return True