def is_path_within_dependency_dir(app, path):
 allowed = False
 resolved_path = os.path.realpath(path)
 tool_dependency_dir = app.config.get('tool_dependency_dir', None)
 if tool_dependency_dir:
  dependency_path = os.path.abspath(tool_dependency_dir)
  allowed = (os.path.commonprefix([dependency_path, resolved_path]) == dependency_path)
 return allowed

def is_path_within_dependency_dir ( app , path ) : allowed = False resolved_path = os . path . realpath ( path ) tool_dependency_dir = app . config . get ( 'tool_dependency_dir' , None ) if tool_dependency_dir : dependency_path = os . path . abspath ( tool_dependency_dir ) allowed = ( os . path . commonprefix ( [ dependency_path , resolved_path ] ) == dependency_path ) return allowed
detect whether the given path is within the tool_dependency_dir folder on the disk .