diff --git a/shared/AppInsightsCore/Tests/Unit/src/ApplicationInsightsCore.Tests.ts b/shared/AppInsightsCore/Tests/Unit/src/ApplicationInsightsCore.Tests.ts index 66162dfd4..5dcd26d82 100644 --- a/shared/AppInsightsCore/Tests/Unit/src/ApplicationInsightsCore.Tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/ApplicationInsightsCore.Tests.ts @@ -2325,6 +2325,7 @@ export class ApplicationInsightsCoreTests extends AITestClass { name: "FieldRedaction: should handle non-standard port with encoded credentials", test: () => { let config = {} as IConfiguration; + //[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="Test file with mock credentials - not actual secrets")] const url = "https://admin%21:secret%21@server.com:9443/admin"; const redactedLocation = fieldRedaction(url, config); Assert.equal(redactedLocation, "https://REDACTED:REDACTED@server.com:9443/admin", diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/EnvUtils.ts b/shared/AppInsightsCore/src/JavaScriptSDK/EnvUtils.ts index 2b8e9dcfc..d8806cd8d 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK/EnvUtils.ts +++ b/shared/AppInsightsCore/src/JavaScriptSDK/EnvUtils.ts @@ -362,7 +362,7 @@ export function sendCustomEvent(evtName: string, cfg?: any, customDetails?: any) * @returns The URL with user information redacted */ function redactUserInfo(url: string): string { - return url.replace(/^([a-zA-Z][a-zA-Z0-9+.-]*:\/\/)([^:@]{1,200}):([^@]{1,200})@(.*)$/, "$1REDACTED:REDACTED@$4"); //(/^([a-zA-Z][a-zA-Z0-9+.-]{0,50}:\/\/)([^:@]{0,200})(?::([^@]{0,200}))?@(.*)$/, "$1REDACTED:REDACTED@$4"); + return url.replace(/^([a-zA-Z][a-zA-Z0-9+.-]*:\/\/)([^:@]{1,200}):([^@]{1,200})@(.*)$/, "$1REDACTED:REDACTED@$4"); } /** @@ -461,7 +461,7 @@ function redactQueryParameters(url: string, config?: IConfiguration): string { * @returns The redacted URL string or the original string if no redaction was needed or possible. */ export function fieldRedaction(input: string, config: IConfiguration): string { - if (!input ||input.indexOf(" ") !== -1) { + if (!input || input.indexOf(" ") !== -1) { return input; } const isRedactionDisabled = config && config.redactUrls === false;