mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
stub out antivirus in dev
antivirus is sometimes tough to get running locally - now in dev antivirus is skipped unless `ANTIVIRUS_ENABLED=1` is set on the command line. on all other environments it is always enabled.
This commit is contained in:
@@ -347,11 +347,19 @@ def replay_letters_in_error(filename=None):
|
|||||||
move_error_pdf_to_scan_bucket(filename)
|
move_error_pdf_to_scan_bucket(filename)
|
||||||
# call task to add the filename to anti virus queue
|
# call task to add the filename to anti virus queue
|
||||||
current_app.logger.info("Calling scan_file for: {}".format(filename))
|
current_app.logger.info("Calling scan_file for: {}".format(filename))
|
||||||
notify_celery.send_task(
|
|
||||||
name=TaskNames.SCAN_FILE,
|
if current_app.config['ANTIVIRUS_ENABLED']:
|
||||||
kwargs={'filename': filename},
|
notify_celery.send_task(
|
||||||
queue=QueueNames.ANTIVIRUS,
|
name=TaskNames.SCAN_FILE,
|
||||||
)
|
kwargs={'filename': filename},
|
||||||
|
queue=QueueNames.ANTIVIRUS,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
# stub out antivirus in dev
|
||||||
|
process_virus_scan_passed.apply_async(
|
||||||
|
kwargs={'filename': filename},
|
||||||
|
queue=QueueNames.LETTERS,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
error_files = get_file_names_from_error_bucket()
|
error_files = get_file_names_from_error_bucket()
|
||||||
for item in error_files:
|
for item in error_files:
|
||||||
@@ -359,8 +367,15 @@ def replay_letters_in_error(filename=None):
|
|||||||
current_app.logger.info("Calling scan_file for: {}".format(moved_file_name))
|
current_app.logger.info("Calling scan_file for: {}".format(moved_file_name))
|
||||||
move_error_pdf_to_scan_bucket(moved_file_name)
|
move_error_pdf_to_scan_bucket(moved_file_name)
|
||||||
# call task to add the filename to anti virus queue
|
# call task to add the filename to anti virus queue
|
||||||
notify_celery.send_task(
|
if current_app.config['ANTIVIRUS_ENABLED']:
|
||||||
name=TaskNames.SCAN_FILE,
|
notify_celery.send_task(
|
||||||
kwargs={'filename': moved_file_name},
|
name=TaskNames.SCAN_FILE,
|
||||||
queue=QueueNames.ANTIVIRUS,
|
kwargs={'filename': moved_file_name},
|
||||||
)
|
queue=QueueNames.ANTIVIRUS,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
# stub out antivirus in dev
|
||||||
|
process_virus_scan_passed.apply_async(
|
||||||
|
kwargs={'filename': moved_file_name},
|
||||||
|
queue=QueueNames.LETTERS,
|
||||||
|
)
|
||||||
|
|||||||
@@ -108,6 +108,9 @@ class Config(object):
|
|||||||
CRONITOR_ENABLED = False
|
CRONITOR_ENABLED = False
|
||||||
CRONITOR_KEYS = json.loads(os.environ.get('CRONITOR_KEYS', '{}'))
|
CRONITOR_KEYS = json.loads(os.environ.get('CRONITOR_KEYS', '{}'))
|
||||||
|
|
||||||
|
# Antivirus
|
||||||
|
ANTIVIRUS_ENABLED = True
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
# Default config values ###
|
# Default config values ###
|
||||||
###########################
|
###########################
|
||||||
@@ -354,6 +357,8 @@ class Development(Config):
|
|||||||
STATSD_PORT = 1000
|
STATSD_PORT = 1000
|
||||||
STATSD_PREFIX = "stats-prefix"
|
STATSD_PREFIX = "stats-prefix"
|
||||||
|
|
||||||
|
ANTIVIRUS_ENABLED = os.getenv('ANTIVIRUS_ENABLED') == '1'
|
||||||
|
|
||||||
for queue in QueueNames.all_queues():
|
for queue in QueueNames.all_queues():
|
||||||
Config.CELERY_QUEUES.append(
|
Config.CELERY_QUEUES.append(
|
||||||
Queue(queue, Exchange('default'), routing_key=queue)
|
Queue(queue, Exchange('default'), routing_key=queue)
|
||||||
@@ -381,6 +386,8 @@ class Test(Development):
|
|||||||
|
|
||||||
BROKER_URL = 'you-forgot-to-mock-celery-in-your-tests://'
|
BROKER_URL = 'you-forgot-to-mock-celery-in-your-tests://'
|
||||||
|
|
||||||
|
ANTIVIRUS_ENABLED = True
|
||||||
|
|
||||||
for queue in QueueNames.all_queues():
|
for queue in QueueNames.all_queues():
|
||||||
Config.CELERY_QUEUES.append(
|
Config.CELERY_QUEUES.append(
|
||||||
Queue(queue, Exchange('default'), routing_key=queue)
|
Queue(queue, Exchange('default'), routing_key=queue)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from flask import request, jsonify, current_app, abort
|
|||||||
from notifications_utils.recipients import try_validate_and_format_phone_number
|
from notifications_utils.recipients import try_validate_and_format_phone_number
|
||||||
|
|
||||||
from app import api_user, authenticated_service, notify_celery, document_download_client
|
from app import api_user, authenticated_service, notify_celery, document_download_client
|
||||||
from app.celery.letters_pdf_tasks import create_letters_pdf
|
from app.celery.letters_pdf_tasks import create_letters_pdf, process_virus_scan_passed
|
||||||
from app.celery.research_mode_tasks import create_fake_letter_response_file
|
from app.celery.research_mode_tasks import create_fake_letter_response_file
|
||||||
from app.clients.document_download import DocumentDownloadError
|
from app.clients.document_download import DocumentDownloadError
|
||||||
from app.config import QueueNames, TaskNames
|
from app.config import QueueNames, TaskNames
|
||||||
@@ -306,11 +306,18 @@ def process_precompiled_letter_notifications(*, letter_data, api_key, template,
|
|||||||
current_app.logger.info('Calling task scan-file for {}'.format(filename))
|
current_app.logger.info('Calling task scan-file for {}'.format(filename))
|
||||||
|
|
||||||
# call task to add the filename to anti virus queue
|
# call task to add the filename to anti virus queue
|
||||||
notify_celery.send_task(
|
if current_app.config['ANTIVIRUS_ENABLED']:
|
||||||
name=TaskNames.SCAN_FILE,
|
notify_celery.send_task(
|
||||||
kwargs={'filename': filename},
|
name=TaskNames.SCAN_FILE,
|
||||||
queue=QueueNames.ANTIVIRUS,
|
kwargs={'filename': filename},
|
||||||
)
|
queue=QueueNames.ANTIVIRUS,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
# stub out antivirus in dev
|
||||||
|
process_virus_scan_passed.apply_async(
|
||||||
|
kwargs={'filename': filename},
|
||||||
|
queue=QueueNames.LETTERS,
|
||||||
|
)
|
||||||
|
|
||||||
return notification
|
return notification
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user