diff --git a/app/config.py b/app/config.py index bcdcbc679..ad8951baf 100644 --- a/app/config.py +++ b/app/config.py @@ -79,6 +79,7 @@ class Config(object): ROUTE_SECRET_KEY_1 = os.environ.get('ROUTE_SECRET_KEY_1', '') ROUTE_SECRET_KEY_2 = os.environ.get('ROUTE_SECRET_KEY_2', '') CHECK_PROXY_HEADER = False + ANTIVIRUS_ENABLED = True REDIS_URL = os.environ.get('REDIS_URL') REDIS_ENABLED = os.environ.get('REDIS_ENABLED') == '1' @@ -106,6 +107,7 @@ class Development(Config): SECRET_KEY = 'dev-notify-secret-key' ANTIVIRUS_API_HOST = 'http://localhost:6016' ANTIVIRUS_API_KEY = 'test-key' + ANTIVIRUS_ENABLED = os.getenv('ANTIVIRUS_ENABLED') == '1' ASSET_PATH = '/static/' @@ -126,6 +128,7 @@ class Test(Development): TEMPLATE_PREVIEW_API_HOST = 'http://localhost:9999' ANTIVIRUS_API_HOST = 'https://test-antivirus' ANTIVIRUS_API_KEY = 'test-antivirus-secret' + ANTIVIRUS_ENABLED = True ASSET_DOMAIN = 'static.example.com' ASSET_PATH = 'https://static.example.com/' diff --git a/app/main/views/uploads.py b/app/main/views/uploads.py index 3b12b548f..967ac9dd5 100644 --- a/app/main/views/uploads.py +++ b/app/main/views/uploads.py @@ -52,9 +52,10 @@ def upload_letter(service_id): pdf_file_bytes = form.file.data.read() original_filename = form.file.data.filename - virus_free = antivirus_client.scan(BytesIO(pdf_file_bytes)) - if not virus_free: - return invalid_upload_error('Your file contains a virus') + if current_app.config['ANTIVIRUS_ENABLED']: + virus_free = antivirus_client.scan(BytesIO(pdf_file_bytes)) + if not virus_free: + return invalid_upload_error('Your file contains a virus') if len(pdf_file_bytes) > MAX_FILE_UPLOAD_SIZE: return invalid_upload_error('Your file is too big', 'Files must be smaller than 2MB.')