Skip to content

Make URL Redaction more dynamic#2716

Merged
rads-1996 merged 13 commits intomicrosoft:mainfrom
rads-1996:dynamic-config-for-url-redaction
Mar 27, 2026
Merged

Make URL Redaction more dynamic#2716
rads-1996 merged 13 commits intomicrosoft:mainfrom
rads-1996:dynamic-config-for-url-redaction

Conversation

@rads-1996
Copy link
Copy Markdown
Member

No description provided.

@rads-1996 rads-1996 marked this pull request as ready for review March 12, 2026 23:02
@rads-1996 rads-1996 requested a review from a team as a code owner March 12, 2026 23:02
Copilot AI review requested due to automatic review settings March 12, 2026 23:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the URL field redaction configuration in AppInsightsCore by separating control of credential redaction vs query-parameter redaction, and expands unit test coverage for the new configuration behavior.

Changes:

  • Introduces separate query-parameter redaction configuration (redactQueryParams boolean + append/replace query param lists).
  • Updates fieldRedaction() / query-parameter redaction selection logic to respect the new configuration shape.
  • Adjusts and adds unit tests covering disabled redaction, credential-only redaction, and custom query param modes.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
shared/AppInsightsCore/Tests/Unit/src/ai/ApplicationInsightsCore.Tests.ts Adds/updates FieldRedaction unit tests for new query-param config modes and flag interactions.
shared/AppInsightsCore/Tests/Unit/src/ai/AppInsightsCommon.tests.ts Updates dataSanitizeUrl test config usage and adds coverage for “replace default sensitive params” behavior.
shared/AppInsightsCore/src/utils/EnvUtils.ts Updates query-param redaction selection and splits credential vs query redaction behavior in fieldRedaction().
shared/AppInsightsCore/src/interfaces/ai/IConfiguration.ts Changes the public config surface for URL redaction (new boolean + new append/replace arrays).
Comments suppressed due to low confidence (1)

shared/AppInsightsCore/Tests/Unit/src/ai/ApplicationInsightsCore.Tests.ts:2264

  • Test name/assert message say this covers an "empty redactQueryParams array", but the test now uses let config = {} as IConfiguration; (no empty array / no query-param config at all). Either pass an explicit empty list (for the new config shape) or rename the test/message so it matches what’s being exercised.
        this.testCase({
            name: "FieldRedaction: should handle empty redactQueryParams array",
            test: () => {
                let config = {} as IConfiguration;
                
                // Should still redact default parameters
                const url = "https://example.com/path?Signature=secret&custom_param=value";
                const redactedLocation = fieldRedaction(url, config);
                Assert.equal(redactedLocation, "https://example.com/path?Signature=REDACTED&custom_param=value",
                    "URL with default sensitive parameters should still be redacted with empty custom array");

You can also share your feedback on Copilot code review. Take the survey.

@rads-1996
Copy link
Copy Markdown
Member Author

Will document all the changes once decide all the config changes.

@rads-1996 rads-1996 force-pushed the dynamic-config-for-url-redaction branch from 71e3d85 to b4d41fd Compare March 12, 2026 23:37
@MSNev MSNev self-requested a review March 19, 2026 00:27
if (config && config.redactQueryParams) {
const option = config ? config.redactUrls : undefined;

if (option === UrlRedactionOptions.appendToDefault) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these ones should be referencing the eUrlRedactOptions so that during conversion from TypeScript to JavaScript TS will replace with the "number", by referencing the type the code is not minifyable


const option = config ? config.redactUrls : undefined;

const isRedactionDisabled = option === false || option === UrlRedactionOptions.false;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same again use the const enum eUrlRedactOptions

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add all other references

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add all other references

Did you mean "And all other references"

Copy link
Copy Markdown
Collaborator

@MSNev MSNev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of minor fixes for minification purposes -- should not affect the functionality

@rads-1996 rads-1996 merged commit 847c292 into microsoft:main Mar 27, 2026
8 checks passed
@rads-1996 rads-1996 deleted the dynamic-config-for-url-redaction branch March 27, 2026 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants