From d34091366fbce687dc5bc56ef106783d3f5cc3f1 Mon Sep 17 00:00:00 2001 From: Vincent Dai <23257217+vidai-msft@users.noreply.github.com> Date: Wed, 10 Apr 2024 01:39:39 -0700 Subject: [PATCH] Add new warning message when output is plain text instead of object. (#1328) --- powershell/cmdlets/class.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/powershell/cmdlets/class.ts b/powershell/cmdlets/class.ts index eb26823118..ef56381701 100644 --- a/powershell/cmdlets/class.ts +++ b/powershell/cmdlets/class.ts @@ -670,9 +670,13 @@ export class CmdletClass extends Class { else { yield `var telemetryInfo = ${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.GetTelemetryInfo?.Invoke(__correlationId);`; yield If('telemetryInfo != null', function* () { + yield 'telemetryInfo.TryGetValue("ShowSecretsWarning", out var showSecretsWarning);'; yield 'telemetryInfo.TryGetValue("SanitizedProperties", out var sanitizedProperties);'; yield 'telemetryInfo.TryGetValue("InvocationName", out var invocationName);'; - yield If('!string.IsNullOrEmpty(sanitizedProperties)', 'WriteWarning($"The output of cmdlet {invocationName ?? "Unknown"} may compromise security by showing the following secrets: {sanitizedProperties}. Learn more at https://go.microsoft.com/fwlink/?linkid=2258844");'); + yield If('showSecretsWarning == "true"', function* () { + yield If('string.IsNullOrEmpty(sanitizedProperties)', 'WriteWarning($"The output of cmdlet {invocationName} may compromise security by showing secrets. Learn more at https://go.microsoft.com/fwlink/?linkid=2258844");'); + yield Else('WriteWarning($"The output of cmdlet {invocationName} may compromise security by showing the following secrets: {sanitizedProperties}. Learn more at https://go.microsoft.com/fwlink/?linkid=2258844");'); + }); }); } });