mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 06:53:11 -04:00
Antivirus off for development by default
I have copied the approach we use in the API for this
This commit is contained in:
@@ -76,6 +76,7 @@ class Config(object):
|
|||||||
ROUTE_SECRET_KEY_1 = os.environ.get('ROUTE_SECRET_KEY_1', '')
|
ROUTE_SECRET_KEY_1 = os.environ.get('ROUTE_SECRET_KEY_1', '')
|
||||||
ROUTE_SECRET_KEY_2 = os.environ.get('ROUTE_SECRET_KEY_2', '')
|
ROUTE_SECRET_KEY_2 = os.environ.get('ROUTE_SECRET_KEY_2', '')
|
||||||
CHECK_PROXY_HEADER = False
|
CHECK_PROXY_HEADER = False
|
||||||
|
ANTIVIRUS_ENABLED = True
|
||||||
|
|
||||||
REDIS_URL = os.environ.get('REDIS_URL')
|
REDIS_URL = os.environ.get('REDIS_URL')
|
||||||
REDIS_ENABLED = os.environ.get('REDIS_ENABLED') == '1'
|
REDIS_ENABLED = os.environ.get('REDIS_ENABLED') == '1'
|
||||||
@@ -103,6 +104,7 @@ class Development(Config):
|
|||||||
SECRET_KEY = 'dev-notify-secret-key'
|
SECRET_KEY = 'dev-notify-secret-key'
|
||||||
ANTIVIRUS_API_HOST = 'http://localhost:6016'
|
ANTIVIRUS_API_HOST = 'http://localhost:6016'
|
||||||
ANTIVIRUS_API_KEY = 'test-key'
|
ANTIVIRUS_API_KEY = 'test-key'
|
||||||
|
ANTIVIRUS_ENABLED = os.getenv('ANTIVIRUS_ENABLED') == '1'
|
||||||
|
|
||||||
ASSET_PATH = '/static/'
|
ASSET_PATH = '/static/'
|
||||||
|
|
||||||
@@ -123,6 +125,7 @@ class Test(Development):
|
|||||||
TEMPLATE_PREVIEW_API_HOST = 'http://localhost:9999'
|
TEMPLATE_PREVIEW_API_HOST = 'http://localhost:9999'
|
||||||
ANTIVIRUS_API_HOST = 'https://test-antivirus'
|
ANTIVIRUS_API_HOST = 'https://test-antivirus'
|
||||||
ANTIVIRUS_API_KEY = 'test-antivirus-secret'
|
ANTIVIRUS_API_KEY = 'test-antivirus-secret'
|
||||||
|
ANTIVIRUS_ENABLED = True
|
||||||
|
|
||||||
ASSET_DOMAIN = 'static.example.com'
|
ASSET_DOMAIN = 'static.example.com'
|
||||||
ASSET_PATH = 'https://static.example.com/'
|
ASSET_PATH = 'https://static.example.com/'
|
||||||
|
|||||||
@@ -52,9 +52,10 @@ def upload_letter(service_id):
|
|||||||
pdf_file_bytes = form.file.data.read()
|
pdf_file_bytes = form.file.data.read()
|
||||||
original_filename = form.file.data.filename
|
original_filename = form.file.data.filename
|
||||||
|
|
||||||
virus_free = antivirus_client.scan(BytesIO(pdf_file_bytes))
|
if current_app.config['ANTIVIRUS_ENABLED']:
|
||||||
if not virus_free:
|
virus_free = antivirus_client.scan(BytesIO(pdf_file_bytes))
|
||||||
return invalid_upload_error('Your file contains a virus')
|
if not virus_free:
|
||||||
|
return invalid_upload_error('Your file contains a virus')
|
||||||
|
|
||||||
if len(pdf_file_bytes) > MAX_FILE_UPLOAD_SIZE:
|
if len(pdf_file_bytes) > MAX_FILE_UPLOAD_SIZE:
|
||||||
return invalid_upload_error('Your file is too big', 'Files must be smaller than 2MB.')
|
return invalid_upload_error('Your file is too big', 'Files must be smaller than 2MB.')
|
||||||
|
|||||||
Reference in New Issue
Block a user