Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass ApplicationName to Microsoft Defender for Cloud #1061

Merged
merged 4 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,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,
Expand Down
5 changes: 3 additions & 2 deletions backend/security/ms_defender_utils.py
Original file line number Diff line number Diff line change
@@ -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']
Expand All @@ -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)
return json.dumps(user_args)
Loading