Add antivirus check on precompiled letters sent with test key

- precompiled PDFs sent by test key uploaded to scan bucket
- set status to VIRUS-SCAN-FAILED for pdfs failing virus scan rather than PERMANENT-FAILURE
- Make call to AV app for precompiled letters sent via a test key, and set notification status to PENDING-VIRUS-SCAN
This commit is contained in:
Ken Tsang
2018-03-23 12:04:37 +00:00
parent 8c282aa406
commit 0ee5c33084
6 changed files with 78 additions and 42 deletions

View File

@@ -227,7 +227,7 @@ def process_letter_notification(*, letter_data, api_key, template, reply_to_text
if precompiled:
try:
if should_send:
if should_send or (precompiled and api_key.key_type == KEY_TYPE_TEST):
status = NOTIFICATION_PENDING_VIRUS_CHECK
letter_content = base64.b64decode(letter_data['content'])
pages = pdf_page_count(io.BytesIO(letter_content))
@@ -273,8 +273,16 @@ def process_letter_notification(*, letter_data, api_key, template, reply_to_text
)
else:
if precompiled and api_key.key_type == KEY_TYPE_TEST:
upload_letter_pdf(notification, letter_content, is_test_letter=True)
update_notification_status_by_reference(notification.reference, NOTIFICATION_DELIVERED)
filename = upload_letter_pdf(notification, letter_content)
# call task to add the filename to anti virus queue
notify_celery.send_task(
name=TaskNames.SCAN_FILE,
kwargs={'filename': filename},
queue=QueueNames.ANTIVIRUS,
)
else:
update_notification_status_by_reference(notification.reference, NOTIFICATION_DELIVERED)
return notification