Conversation
There was a problem hiding this comment.
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 (
redactQueryParamsboolean + 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.
shared/AppInsightsCore/Tests/Unit/src/ai/ApplicationInsightsCore.Tests.ts
Show resolved
Hide resolved
|
Will document all the changes once decide all the config changes. |
71e3d85 to
b4d41fd
Compare
| } | ||
|
|
||
| if (config && config.redactQueryParams) { | ||
| const option = config ? config.redactUrls : undefined; |
There was a problem hiding this comment.
I added this check here to avoid having to change the function arguments.
| * Controls how the user can configure which parts of the URL should be redacted. Example, certain query parameters, username and password, etc. | ||
| */ | ||
|
|
||
| export const enum UrlRedactionOptions { |
There was a problem hiding this comment.
OK, looking good just a couple of comments
- const enum is excellent and it's what we want to use internally (like you have)
minor changes
- the const enum should be named with a leading lowercase "e"
- As this is usable from the
IConfigurationit also needs to be exported from the index - Because of the exporting requirement we "should" probably also create a user usable enum using createEnumStyle
- We should also export a type (the name you have now without a leading lowercase "e") and use this in the IConfiguration (so that files doesn't need to change)
Examples of what I'm talking about for the enum definitions are in https://github.com/microsoft/ApplicationInsights-JS/blob/main/shared/AppInsightsCore/src/enums/ai/EventsDiscardedReason.ts
There was a problem hiding this comment.
I have addressed the comments. PTAL when you have time. Thanks!
No description provided.