mirror of
				https://github.com/avatao-content/baseimage-tutorial-framework
				synced 2025-11-04 01:02:54 +00:00 
			
		
		
		
	Make Filemanager.is_allowed() public
This commit is contained in:
		@@ -7,7 +7,7 @@ from os.path import dirname, isdir, isfile, realpath
 | 
			
		||||
def _with_is_allowed(func):
 | 
			
		||||
    @wraps(func)
 | 
			
		||||
    def wrapper(self, *args, **kwargs):
 | 
			
		||||
        if self._is_allowed(args[0]): # pylint: disable=protected-access
 | 
			
		||||
        if self.is_allowed(args[0]): # pylint: disable=protected-access
 | 
			
		||||
            return func(self, *args, **kwargs)
 | 
			
		||||
        raise ValueError('Forbidden path.')
 | 
			
		||||
    return wrapper
 | 
			
		||||
@@ -23,7 +23,7 @@ class FileManager: # pylint: disable=too-many-instance-attributes
 | 
			
		||||
            path
 | 
			
		||||
            for pattern in self.patterns
 | 
			
		||||
            for path in glob(pattern, recursive=True)
 | 
			
		||||
            if isfile(path) and self._is_allowed(path)
 | 
			
		||||
            if isfile(path) and self.is_allowed(path)
 | 
			
		||||
        ))
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
@@ -39,7 +39,7 @@ class FileManager: # pylint: disable=too-many-instance-attributes
 | 
			
		||||
            pattern = dirname(pattern)
 | 
			
		||||
        return pattern
 | 
			
		||||
 | 
			
		||||
    def _is_allowed(self, filepath):
 | 
			
		||||
    def is_allowed(self, filepath):
 | 
			
		||||
        return any(
 | 
			
		||||
            fnmatchcase(realpath(filepath), pattern)
 | 
			
		||||
            for pattern in self.patterns
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user