From e8f3718e67f76b503abd6c348b4c802c11ddf1cf Mon Sep 17 00:00:00 2001 From: Akshay Hosur <107408187+akshay-online@users.noreply.github.com> Date: Tue, 10 Dec 2024 12:45:54 +0530 Subject: [PATCH] Fix code scanning alert no. 1: Information exposure through transmitted data Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- src/ADOGenerator/Services/ProjectService.cs | 1 + src/API/Service/ServiceEndPoint.cs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ADOGenerator/Services/ProjectService.cs b/src/ADOGenerator/Services/ProjectService.cs index 526ea54..9f8901c 100644 --- a/src/ADOGenerator/Services/ProjectService.cs +++ b/src/ADOGenerator/Services/ProjectService.cs @@ -2870,6 +2870,7 @@ public static string SanitizeJson(string json) { jsonObject["password"] = "****"; } + // Add more sanitization logic as needed return jsonObject.ToString(); } } diff --git a/src/API/Service/ServiceEndPoint.cs b/src/API/Service/ServiceEndPoint.cs index 6bf620a..d8065fb 100644 --- a/src/API/Service/ServiceEndPoint.cs +++ b/src/API/Service/ServiceEndPoint.cs @@ -25,7 +25,8 @@ public ServiceEndpointModel CreateServiceEndPoint(string json, string project) using (var client = GetHttpClient()) { - var jsonContent = new StringContent(json, Encoding.UTF8, "application/json"); + var sanitizedJson = Utility.SanitizeJson(json); + var jsonContent = new StringContent(sanitizedJson, Encoding.UTF8, "application/json"); var method = new HttpMethod("POST"); var request = new HttpRequestMessage(method, project + "/_apis/distributedtask/serviceendpoints?api-version=" + _configuration.VersionNumber) { Content = jsonContent };