Skip to content

Commit eb39be7

Browse files
Fix code ql by logging the response and not sending it in exception (#5085)
* Fix code ql by logging the response and not sending it in exception * Update src/client/Microsoft.Identity.Client/MsalErrorMessage.cs Co-authored-by: Gladwin Johnson <[email protected]> --------- Co-authored-by: Gladwin Johnson <[email protected]>
1 parent 5de0661 commit eb39be7

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/client/Microsoft.Identity.Client/MsalErrorMessage.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ public static string iOSBrokerKeySaveFailed(string keyChainResult)
189189
public const string PlatformNotSupported = "Platform Not Supported";
190190

191191
public const string FederatedServiceReturnedErrorTemplate = "Federated service at {0} returned error: {1} ";
192-
public const string ParsingWsTrustResponseFailedErrorTemplate = "Federated service at {0} parse error: Body {1} ";
192+
public const string ParsingWsTrustResponseFailedErrorTemplate = "Federated service at {0} parse error. Enable logging with PII to see more details. See https://aka.ms/msal-net-logging.";
193+
193194
public const string UnknownUserType = "Unknown User Type";
194195
public const string ParsingWsTrustResponseFailedDueToConfiguration = "There was an error parsing the WS-Trust response from the endpoint. " +
195196
"\nThis may occur if there are issues with your ADFS configuration. See https://aka.ms/msal-net-iwa-troubleshooting for more details." +

src/client/Microsoft.Identity.Client/WsTrust/WsTrustWebRequestManager.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,12 @@ public async Task<WsTrustResponse> GetWsTrustResponseAsync(
151151
}
152152
catch (System.Xml.XmlException ex)
153153
{
154+
requestContext.Logger.ErrorPii("Error parsing WS-Trust response: \n" + resp.Body, "Error parsing WS-Trust response. ");
155+
154156
string message = string.Format(
155157
CultureInfo.CurrentCulture,
156158
MsalErrorMessage.ParsingWsTrustResponseFailedErrorTemplate,
157-
wsTrustEndpoint.Uri,
158-
resp.Body);
159+
wsTrustEndpoint.Uri);
159160

160161
throw new MsalClientException(
161162
MsalError.ParsingWsTrustResponseFailed, message, ex);

tests/Microsoft.Identity.Test.Unit/CoreTests/WsTrustTests/WsTrustTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public async Task WsTrustRequestParseErrorTestAsync()
9999
{
100100
const string body = "Non-Parsable";
101101
const string uri = "https://some/address/usernamemixed";
102-
string expectedMessage = string.Format(CultureInfo.CurrentCulture, MsalErrorMessage.ParsingWsTrustResponseFailedErrorTemplate, uri, body);
102+
string expectedMessage = string.Format(CultureInfo.CurrentCulture, MsalErrorMessage.ParsingWsTrustResponseFailedErrorTemplate, uri);
103103

104104
var endpoint = new WsTrustEndpoint(new Uri(uri), WsTrustVersion.WsTrust13);
105105

0 commit comments

Comments
 (0)