Ejemplo n.º 1
0
 def upload_handle(self):
     params = dict(request.params.items())
     originalFilename = params.get("file").filename
     if re.search(QGOVDataController.allowedFileExtensionsRegex, originalFilename.lower(), re.I):
         return StorageController.upload_handle(StorageController())
     abort(
         403,
         "This file type is not supported. If possible, upload the file in another format.\nIf you continue to have problems, email Smart Service—\[email protected]",
     )
Ejemplo n.º 2
0
    def upload_handle(self):
        params = dict(request.params.items())
        field_storage = params.get('file')
        buffer = field_storage.file

        do_scan = asbool(config.get('kata.storage.malware_scan', False))

        if do_scan:
            try:
                passed = clamd_wrapper.scan_for_malware(buffer)
                # reset the stream so that the data can be properly read again
                buffer.seek(0)
            except clamd_wrapper.MalwareCheckError as err:
                passed = False
                log.error(str(err))
        else:
            passed = True

        if passed:
            return StorageController.upload_handle(self)
        else:
            # TODO: produce a meaningful error message through javascript?
            abort(403)