Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions shared/AppInsightsCore/src/JavaScriptSDK/EnvUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

/**
Expand Down Expand Up @@ -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;
Expand Down