def validate(self): if not blacklist.allow_file("/" + self.relative_path): raise dr.SkipComponent() if not os.path.exists(self.path): raise ContentException("%s does not exist." % self.path) if not os.access(self.path, os.R_OK): raise ContentException("Cannot access %s" % self.path)
def validate(self): if not blacklist.allow_file("/" + self.relative_path): raise dr.SkipComponent() if not os.path.exists(self.path): raise ContentException("%s does not exist." % self.path) resolved = os.path.realpath(self.path) if not resolved.startswith(os.path.realpath(self.root)): msg = "Relative path points outside the root: %s -> %s." raise Exception(msg % (self.path, resolved)) if not os.access(self.path, os.R_OK): raise ContentException("Cannot access %s" % self.path)