diff --git a/src/ADOGenerator/Services/ProjectService.cs b/src/ADOGenerator/Services/ProjectService.cs index c41db57..526ea54 100644 --- a/src/ADOGenerator/Services/ProjectService.cs +++ b/src/ADOGenerator/Services/ProjectService.cs @@ -2859,3 +2859,17 @@ public bool CheckForInstalledExtensions(string extensionJsonFile, string token, } } +public static class Utility +{ + public static string SanitizeJson(string json) + { + // Implement sanitization logic to remove or mask sensitive information + // For example, remove password fields + var jsonObject = JObject.Parse(json); + if (jsonObject["password"] != null) + { + jsonObject["password"] = "****"; + } + return jsonObject.ToString(); + } +} diff --git a/src/RestAPI/Service/ServiceEndPoint.cs b/src/RestAPI/Service/ServiceEndPoint.cs index 023a764..243cb59 100644 --- a/src/RestAPI/Service/ServiceEndPoint.cs +++ b/src/RestAPI/Service/ServiceEndPoint.cs @@ -26,7 +26,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 }; @@ -47,7 +48,7 @@ public ServiceEndpointModel CreateServiceEndPoint(string json, string project) } catch (Exception ex) { - logger.Debug(DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss") + "\t" + "CreateServiceEndPoint" + "\t" + ex.Message + "\t" + "\n" + ex.StackTrace + "\n"); + logger.Debug(DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss") + "\t" + "CreateServiceEndPoint" + "\t" + "An error occurred while creating the service endpoint." + "\n"); } return new ServiceEndpointModel(); }