Skip to content

Fix the issue that string is returned instead of object and add one more property in the telemetry #415

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2024

Conversation

vidai-msft
Copy link
Contributor

This pull request primarily focuses on improving the handling of secret detection in the Azure PowerShell Cmdlet. The changes include a more nuanced approach to secret detection warnings, improved null safety, and adjustments to the SanitizerTelemetry class.

The most important changes are:

Improved Secret Detection Warnings:

  • [src/Common/AzurePSCmdlet.cs]: The WriteSecretsWarningMessage() method now checks for sanitizerInfo.SecretsDetected before showing a secrets warning. It also differentiates the warning message based on whether any properties were detected.
  • src/Common/Properties/Resources.Designer.cs and src/Common/Properties/Resources.resx: Added a new resource string DisplaySecretsWarningMessageWithoutProperty for the case where no specific properties were detected.

Null Safety Improvements:

  • [src/Common/AzurePSCmdlet.cs]: Null safety has been improved in several places by using the null-conditional operator. This includes the OutputSanitizer property and the SanitizeOutput() and InitializeQosEvent() methods.

Changes to SanitizerTelemetry:

  • [src/Common/Sanitizer/SanitizerTelemetry.cs]: Added a new property SecretsDetected to track whether secrets were detected. Also added a new constructor that takes a showSecretsWarning parameter.
  • [src/Common/MetricHelper.cs]: The PopulateSanitizerPropertiesFromQos() method now uses the new SecretsDetected property and adjusts the secrets-detected-properties value based on whether any properties were detected.

…sage is added to accommodate this situation.
@vidai-msft vidai-msft force-pushed the vidai/sanitizer-handler branch from 3230152 to 940d279 Compare April 11, 2024 01:58
@@ -29,11 +31,17 @@ public class SanitizerTelemetry

public TimeSpan SanitizeDuration { get; set; }

public SanitizerTelemetry(bool showSecretsWarning)
Copy link
Member

Choose a reason for hiding this comment

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

This is technically a breaking change, because the default constructor (the one without parameters) will be hidden by this. Are we sure about the backward compatibility?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The change was due to the value in the telemetry may be not consistent with the DisplaySecretsWarning option. Previously the ShowSecretsWarning in the telemetry relied on if the real detection method was invoked. If not, then the value would be the default (false). However, the real value of DisplaySecretsWarning may be true. The initialization of the SanitizerTelemetry just happens in Az.Accounts module (For SDK, Authentication proj; for AutoRest, AzModule). So it won't cause any real breaking change and build error.

Copy link
Member

@isra-fel isra-fel left a comment

Choose a reason for hiding this comment

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

LGTM

@Nickcandy Nickcandy merged commit cf91f5b into main Apr 11, 2024
2 checks passed
@vidai-msft vidai-msft deleted the vidai/sanitizer-handler branch September 18, 2024 09:16
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.

3 participants