From 420845fac79823ebf1b4f94bc9f77f81fa9e1e70 Mon Sep 17 00:00:00 2001
From: stvnrlly
Date: Mon, 5 Dec 2022 16:35:46 -0500
Subject: [PATCH] remove antivirus code (email does not allow attachments via
ui)
---
app/__init__.py | 3 +--
app/config.py | 6 ------
app/extensions.py | 4 ----
app/main/views/send.py | 3 +--
app/template_previews.py | 5 +----
app/templates/components/table.html | 2 +-
app/templates/views/activity/notifications.html | 6 +-----
app/templates/views/api/index.html | 4 +---
app/templates/views/support/public.html | 2 +-
app/utils/__init__.py | 4 ++--
sample.env | 1 -
tests/app/main/views/test_activity.py | 11 +++++------
tests/app/main/views/test_jobs.py | 11 +++++------
tests/app/main/views/test_platform_admin.py | 6 +++---
tests/app/main/views/test_send.py | 2 +-
15 files changed, 23 insertions(+), 47 deletions(-)
diff --git a/app/__init__.py b/app/__init__.py
index bd2c03387..e7e19259c 100644
--- a/app/__init__.py
+++ b/app/__init__.py
@@ -38,7 +38,7 @@ from app import proxy_fix, webauthn_server
from app.asset_fingerprinter import asset_fingerprinter
from app.config import configs
from app.custom_auth import CustomBasicAuth
-from app.extensions import antivirus_client, redis_client, zendesk_client
+from app.extensions import redis_client, zendesk_client
from app.formatters import (
convert_to_boolean,
format_auth_type,
@@ -199,7 +199,6 @@ def create_app(application):
user_api_client,
# External API clients
- antivirus_client,
redis_client,
zendesk_client,
diff --git a/app/config.py b/app/config.py
index e133be313..47ee9a4cf 100644
--- a/app/config.py
+++ b/app/config.py
@@ -30,8 +30,6 @@ class Config(object):
TEMPLATE_PREVIEW_API_HOST = os.environ.get('TEMPLATE_PREVIEW_API_HOST', 'http://localhost:9999')
TEMPLATE_PREVIEW_API_KEY = os.environ.get('TEMPLATE_PREVIEW_API_KEY', 'my-secret-key')
- ANTIVIRUS_API_HOST = os.environ.get('ANTIVIRUS_API_HOST', 'http://localhost:6016')
- ANTIVIRUS_API_KEY = os.environ.get('ANTIVIRUS_API_KEY', 'test-key')
# Logging
NOTIFY_LOG_LEVEL = os.environ.get('NOTIFY_LOG_LEVEL', 'INFO')
@@ -55,7 +53,6 @@ class Config(object):
WTF_CSRF_ENABLED = True
WTF_CSRF_TIME_LIMIT = None
CHECK_PROXY_HEADER = False
- ANTIVIRUS_ENABLED = os.environ.get('ANTIVIRUS_ENABLED') == '1'
AWS_REGION = os.environ.get('AWS_REGION')
@@ -118,9 +115,6 @@ class Test(Development):
API_HOST_NAME = 'http://you-forgot-to-mock-an-api-call-to'
REDIS_URL = 'redis://you-forgot-to-mock-a-redis-call-to'
- ANTIVIRUS_API_HOST = 'https://test-antivirus'
- ANTIVIRUS_API_KEY = 'test-antivirus-secret'
- ANTIVIRUS_ENABLED = True
LOGO_CDN_DOMAIN = 'static-logos.test.com'
# Buckets
diff --git a/app/extensions.py b/app/extensions.py
index 0d676c8e6..8bbb874a3 100644
--- a/app/extensions.py
+++ b/app/extensions.py
@@ -1,9 +1,5 @@
-from notifications_utils.clients.antivirus.antivirus_client import (
- AntivirusClient,
-)
from notifications_utils.clients.redis.redis_client import RedisClient
from notifications_utils.clients.zendesk.zendesk_client import ZendeskClient
-antivirus_client = AntivirusClient()
zendesk_client = ZendeskClient()
redis_client = RedisClient()
diff --git a/app/main/views/send.py b/app/main/views/send.py
index 71043bc9d..85a9fdffe 100644
--- a/app/main/views/send.py
+++ b/app/main/views/send.py
@@ -28,7 +28,7 @@ from app import (
notification_api_client,
service_api_client,
)
-from app.main import main, no_cookie
+from app.main import main
from app.main.forms import (
ChooseTimeForm,
CsvUploadForm,
@@ -43,7 +43,6 @@ from app.s3_client.s3_csv_client import (
s3upload,
set_metadata_on_csv_upload,
)
-from app.template_previews import TemplatePreview
from app.utils import (
PermanentRedirect,
should_skip_template_page,
diff --git a/app/template_previews.py b/app/template_previews.py
index 72f3e7aaf..311186d66 100644
--- a/app/template_previews.py
+++ b/app/template_previews.py
@@ -1,8 +1,5 @@
-import base64
-from io import BytesIO
-
import requests
-from flask import current_app, json
+from flask import current_app
from app import current_service
diff --git a/app/templates/components/table.html b/app/templates/components/table.html
index f5e15c9eb..4da7ebc3f 100644
--- a/app/templates/components/table.html
+++ b/app/templates/components/table.html
@@ -147,7 +147,7 @@
{% macro notification_status_field(notification) %}
- {% set displayed_on_single_line = notification.status in ['created', 'pending', 'pending-virus-check', 'sending', 'delivered', 'accepted', 'received'] %}
+ {% set displayed_on_single_line = notification.status in ['created', 'pending', 'sending', 'delivered', 'accepted', 'received'] %}
{% if not notification %}
{% call field(align='right') %}{% endcall %}
diff --git a/app/templates/views/activity/notifications.html b/app/templates/views/activity/notifications.html
index 17e7e0df9..4920a151e 100644
--- a/app/templates/views/activity/notifications.html
+++ b/app/templates/views/activity/notifications.html
@@ -16,11 +16,7 @@
field_headings_visible=False
) %}
{% call row_heading() %}
- {% if item.status in ('pending-virus-check', 'virus-scan-failed') %}
- Checking
- {% else %}
- {{ item.to.splitlines()|join(', ') if item.to else '' }}
- {% endif %}
+ {{ item.to.splitlines()|join(', ') if item.to else '' }}
{{ item.preview_of_content }}
diff --git a/app/templates/views/api/index.html b/app/templates/views/api/index.html
index cff7a30c7..1d01f5c4b 100644
--- a/app/templates/views/api/index.html
+++ b/app/templates/views/api/index.html
@@ -74,9 +74,7 @@
{{ notification[key] }}
{% endif %}
{% endfor %}
- {% if notification.status not in ('pending-virus-check', 'virus-scan-failed') %}
- View {{ 1|message_count_label(notification.template.template_type, suffix='') }}
- {% endif %}
+ View {{ 1|message_count_label(notification.template.template_type, suffix='') }}
diff --git a/app/templates/views/support/public.html b/app/templates/views/support/public.html
index f241153fc..cf4b56414 100644
--- a/app/templates/views/support/public.html
+++ b/app/templates/views/support/public.html
@@ -23,7 +23,7 @@
- There are other pages on US Notifywhere you can get help:
+ There are other pages on US Notify where you can get help:
diff --git a/app/utils/__init__.py b/app/utils/__init__.py
index 15435418c..9409056b1 100644
--- a/app/utils/__init__.py
+++ b/app/utils/__init__.py
@@ -8,10 +8,10 @@ from orderedset._orderedset import OrderedSet
from werkzeug.datastructures import MultiDict
from werkzeug.routing import RequestRedirect
-SENDING_STATUSES = ['created', 'pending', 'sending', 'pending-virus-check']
+SENDING_STATUSES = ['created', 'pending', 'sending']
DELIVERED_STATUSES = ['delivered', 'sent']
FAILURE_STATUSES = ['failed', 'temporary-failure', 'permanent-failure',
- 'technical-failure', 'virus-scan-failed', 'validation-failed']
+ 'technical-failure', 'validation-failed']
REQUESTED_STATUSES = SENDING_STATUSES + DELIVERED_STATUSES + FAILURE_STATUSES
NOTIFICATION_TYPES = ["sms", "email"]
diff --git a/sample.env b/sample.env
index 04a1ffbbe..5b7e99192 100644
--- a/sample.env
+++ b/sample.env
@@ -24,7 +24,6 @@ FLASK_APP=application.py
FLASK_ENV=development
WERKZEUG_DEBUG_PIN=off
-ANTIVIRUS_ENABLED=0
NODE_VERSION=16.15.1
#############################################################
diff --git a/tests/app/main/views/test_activity.py b/tests/app/main/views/test_activity.py
index 54528dd1d..de86e21da 100644
--- a/tests/app/main/views/test_activity.py
+++ b/tests/app/main/views/test_activity.py
@@ -49,15 +49,14 @@ from tests.conftest import (
(
'',
[
- 'created', 'pending', 'sending', 'pending-virus-check',
- 'delivered', 'sent',
- 'failed', 'temporary-failure', 'permanent-failure', 'technical-failure',
- 'virus-scan-failed', 'validation-failed'
+ 'created', 'pending', 'sending', 'delivered', 'sent', 'failed',
+ 'temporary-failure', 'permanent-failure', 'technical-failure',
+ 'validation-failed'
]
),
(
'sending',
- ['sending', 'created', 'pending', 'pending-virus-check']
+ ['sending', 'created', 'pending']
),
(
'delivered',
@@ -67,7 +66,7 @@ from tests.conftest import (
'failed',
[
'failed', 'temporary-failure', 'permanent-failure', 'technical-failure',
- 'virus-scan-failed', 'validation-failed'
+ 'validation-failed'
]
)
]
diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py
index e40469a47..8190eb122 100644
--- a/tests/app/main/views/test_jobs.py
+++ b/tests/app/main/views/test_jobs.py
@@ -38,15 +38,14 @@ def test_old_jobs_hub_redirects(
(
'',
[
- 'created', 'pending', 'sending', 'pending-virus-check',
- 'delivered', 'sent',
- 'failed', 'temporary-failure', 'permanent-failure', 'technical-failure',
- 'virus-scan-failed', 'validation-failed'
+ 'created', 'pending', 'sending', 'delivered', 'sent', 'failed',
+ 'temporary-failure', 'permanent-failure', 'technical-failure',
+ 'validation-failed'
]
),
(
'sending',
- ['sending', 'created', 'pending', 'pending-virus-check']
+ ['sending', 'created', 'pending']
),
(
'delivered',
@@ -55,7 +54,7 @@ def test_old_jobs_hub_redirects(
(
'failed',
[
- 'failed', 'temporary-failure', 'permanent-failure', 'technical-failure', 'virus-scan-failed',
+ 'failed', 'temporary-failure', 'permanent-failure', 'technical-failure',
'validation-failed'
]
)
diff --git a/tests/app/main/views/test_platform_admin.py b/tests/app/main/views/test_platform_admin.py
index c0a20f8dd..918c80d7b 100644
--- a/tests/app/main/views/test_platform_admin.py
+++ b/tests/app/main/views/test_platform_admin.py
@@ -516,7 +516,7 @@ def test_is_over_threshold(number, total, threshold, result):
def test_get_tech_failure_status_box_data_removes_percentage_data():
stats = {
'failures':
- {'permanent-failure': 0, 'technical-failure': 0, 'temporary-failure': 1, 'virus-scan-failed': 0},
+ {'permanent-failure': 0, 'technical-failure': 0, 'temporary-failure': 1},
'test-key': 0,
'total': 5589
}
@@ -612,11 +612,11 @@ def test_platform_admin_displays_stats_in_right_boxes_and_with_correct_styling(
):
platform_stats = {
'email': {'failures':
- {'permanent-failure': 3, 'technical-failure': 0, 'temporary-failure': 0, 'virus-scan-failed': 0},
+ {'permanent-failure': 3, 'technical-failure': 0, 'temporary-failure': 0},
'test-key': 0,
'total': 145},
'sms': {'failures':
- {'permanent-failure': 0, 'technical-failure': 1, 'temporary-failure': 0, 'virus-scan-failed': 0},
+ {'permanent-failure': 0, 'technical-failure': 1, 'temporary-failure': 0},
'test-key': 5,
'total': 168},
}
diff --git a/tests/app/main/views/test_send.py b/tests/app/main/views/test_send.py
index fbdf00fa5..d17b593f0 100644
--- a/tests/app/main/views/test_send.py
+++ b/tests/app/main/views/test_send.py
@@ -940,7 +940,7 @@ def test_upload_valid_csv_shows_preview_and_table(
row = page.select('table tbody tr')[row_index]
assert 'id' not in row
assert normalize_spaces(str(row.select('td')[index + 1])) == cell
-
+
def test_show_all_columns_if_there_are_duplicate_recipient_columns(
client_request,