def safemembers(members, base):
 base = resolved(base)
 if (not base.startswith(resolved(settings.DATA_DIR))):
  raise SuspiciousOperation('Attempted to import course outside of data dir')
 for finfo in members:
  if _is_bad_path(finfo.name, base):
   log.debug('File %r is blocked (illegal path)', finfo.name)
   raise SuspiciousOperation('Illegal path')
  elif (finfo.issym() and _is_bad_link(finfo, base)):
   log.debug('File %r is blocked: Hard link to %r', finfo.name, finfo.linkname)
   raise SuspiciousOperation('Hard link')
  elif (finfo.islnk() and _is_bad_link(finfo, base)):
   log.debug('File %r is blocked: Symlink to %r', finfo.name, finfo.linkname)
   raise SuspiciousOperation('Symlink')
  elif finfo.isdev():
   log.debug('File %r is blocked: FIFO, device or character file', finfo.name)
   raise SuspiciousOperation('Dev file')
 return members

def safemembers ( members , base ) : base = resolved ( base ) if ( not base . startswith ( resolved ( settings . DATA_DIR ) ) ) : raise SuspiciousOperation ( 'Attempted to import course outside of data dir' ) for finfo in members : if _is_bad_path ( finfo . name , base ) : log . debug ( 'File %r is blocked (illegal path)' , finfo . name ) raise SuspiciousOperation ( 'Illegal path' ) elif ( finfo . issym ( ) and _is_bad_link ( finfo , base ) ) : log . debug ( 'File %r is blocked: Hard link to %r' , finfo . name , finfo . linkname ) raise SuspiciousOperation ( 'Hard link' ) elif ( finfo . islnk ( ) and _is_bad_link ( finfo , base ) ) : log . debug ( 'File %r is blocked: Symlink to %r' , finfo . name , finfo . linkname ) raise SuspiciousOperation ( 'Symlink' ) elif finfo . isdev ( ) : log . debug ( 'File %r is blocked: FIFO, device or character file' , finfo . name ) raise SuspiciousOperation ( 'Dev file' ) return members
check that all elements of a tar file are safe .