Skip to content

Commit

Permalink
Add new warning message when output is plain text instead of object. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
vidai-msft authored Apr 10, 2024
1 parent f6c2148 commit d340913
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion powershell/cmdlets/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");');
});
});
}
});
Expand Down

0 comments on commit d340913

Please sign in to comment.