mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 13:39:41 -04:00
Add audit event for suspending a service
This is particularly important for broadcast services, where a rogue service or platform admin could launch a DoS attack by suspending a service at a critical moment when it needs to send alerts.
This commit is contained in:
@@ -67,6 +67,17 @@ def create_broadcast_account_type_change_event(
|
||||
)
|
||||
|
||||
|
||||
def create_suspend_service_event(
|
||||
service_id,
|
||||
suspended_by_id,
|
||||
):
|
||||
_send_event(
|
||||
'suspend_service',
|
||||
service_id=service_id,
|
||||
suspended_by_id=suspended_by_id,
|
||||
)
|
||||
|
||||
|
||||
def _send_event(event_type, **kwargs):
|
||||
event_data = _construct_event_data(request)
|
||||
event_data.update(kwargs)
|
||||
|
||||
@@ -28,7 +28,10 @@ from app import (
|
||||
service_api_client,
|
||||
user_api_client,
|
||||
)
|
||||
from app.event_handlers import create_broadcast_account_type_change_event
|
||||
from app.event_handlers import (
|
||||
create_broadcast_account_type_change_event,
|
||||
create_suspend_service_event,
|
||||
)
|
||||
from app.extensions import zendesk_client
|
||||
from app.formatters import email_safe
|
||||
from app.main import main
|
||||
@@ -443,6 +446,7 @@ def archive_service(service_id):
|
||||
def suspend_service(service_id):
|
||||
if request.method == 'POST':
|
||||
service_api_client.suspend_service(service_id)
|
||||
create_suspend_service_event(service_id, suspended_by_id=current_user.id)
|
||||
return redirect(url_for('.service_settings', service_id=service_id))
|
||||
else:
|
||||
flash("This will suspend the service and revoke all api keys. Are you sure you want to suspend this service?",
|
||||
|
||||
Reference in New Issue
Block a user