From 498dd4d3342aed7d74be7a1cecb2d5261cee3277 Mon Sep 17 00:00:00 2001 From: Slava Reznitsky <30771358+slreznit@users.noreply.github.com> Date: Tue, 20 Aug 2024 19:09:33 +0300 Subject: [PATCH 1/2] Update ms_defender_utils.py --- backend/security/ms_defender_utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/security/ms_defender_utils.py b/backend/security/ms_defender_utils.py index 8785c253fb..7989983784 100644 --- a/backend/security/ms_defender_utils.py +++ b/backend/security/ms_defender_utils.py @@ -1,6 +1,6 @@ import json -def get_msdefender_user_json(authenticated_user_details, request_headers, conversation_id): +def get_msdefender_user_json(authenticated_user_details, request_headers, conversation_id, application_name): auth_provider = authenticated_user_details.get('auth_provider') source_ip = request_headers.get('Remote-Addr', '') header_names = ['User-Agent', 'X-Forwarded-For', 'Forwarded', 'X-Real-IP', 'True-Client-IP', 'CF-Connecting-IP'] @@ -10,5 +10,6 @@ def get_msdefender_user_json(authenticated_user_details, request_headers, conver "SourceIp": source_ip.split(':')[0], #remove port "SourceRequestHeaders": {header: request_headers[header] for header in header_names if header in request_headers}, "ConversationId": conversation_id, + "ApplicationName": application_name, } - return json.dumps(user_args) \ No newline at end of file + return json.dumps(user_args) From 3f3289cb886c24992132a963e186f82bce4626e1 Mon Sep 17 00:00:00 2001 From: Slava Reznitsky <30771358+slreznit@users.noreply.github.com> Date: Tue, 20 Aug 2024 19:12:02 +0300 Subject: [PATCH 2/2] Update app.py --- app.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 7c3a86c646..8fc22f0015 100644 --- a/app.py +++ b/app.py @@ -228,8 +228,9 @@ def prepare_model_args(request_body, request_headers): user_json = None if (MS_DEFENDER_ENABLED): authenticated_user_details = get_authenticated_user_details(request_headers) - conversation_id = request_body.get("conversation_id", None) - user_json = get_msdefender_user_json(authenticated_user_details, request_headers, conversation_id) + conversation_id = request_body.get("conversation_id", None) + application_name = app_settings.ui.title + user_json = get_msdefender_user_json(authenticated_user_details, request_headers, conversation_id, application_name) model_args = { "messages": messages,