Skip to content

Commit d6e3adc

Browse files
Migrate ConnectedMachine from generation to vidai/secrets-detection-autorest (#24456)
* Move ConnectedMachine to vidai/secrets-detection-autorest * Update ChangeLog.md --------- Co-authored-by: Vincent Dai <[email protected]>
1 parent 2af89d8 commit d6e3adc

File tree

94 files changed

+2251
-13
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+2251
-13
lines changed

src/ConnectedMachine/ConnectedMachine.Autorest/Az.ConnectedMachine.psm1

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,37 +47,41 @@
4747

4848
# Ask for the shared functionality table
4949
$VTable = Register-AzModule
50-
50+
5151
# Tweaks the pipeline on module load
5252
$instance.OnModuleLoad = $VTable.OnModuleLoad
5353

5454
# Following two delegates are added for telemetry
5555
$instance.GetTelemetryId = $VTable.GetTelemetryId
5656
$instance.Telemetry = $VTable.Telemetry
57-
57+
58+
# Delegate to sanitize the output object
59+
$instance.SanitizeOutput = $VTable.SanitizerHandler
60+
61+
# Delegate to get the telemetry info
62+
$instance.GetTelemetryInfo = $VTable.GetTelemetryInfo
5863

5964
# Tweaks the pipeline per call
6065
$instance.OnNewRequest = $VTable.OnNewRequest
61-
66+
6267
# Gets shared parameter values
6368
$instance.GetParameterValue = $VTable.GetParameterValue
64-
69+
6570
# Allows shared module to listen to events from this module
6671
$instance.EventListener = $VTable.EventListener
67-
72+
6873
# Gets shared argument completers
6974
$instance.ArgumentCompleter = $VTable.ArgumentCompleter
70-
75+
7176
# The name of the currently selected Azure profile
7277
$instance.ProfileName = $VTable.ProfileName
7378

74-
7579
# Load the custom module
7680
$customModulePath = Join-Path $PSScriptRoot './custom/Az.ConnectedMachine.custom.psm1'
7781
if(Test-Path $customModulePath) {
7882
$null = Import-Module -Name $customModulePath
7983
}
80-
84+
8185
# Export nothing to clear implicit exports
8286
Export-ModuleMember
8387

@@ -97,12 +101,12 @@
97101
# Load the last folder if no profile is selected
98102
$profileDirectory = $directories | Select-Object -Last 1
99103
}
100-
104+
101105
if($profileDirectory) {
102106
Write-Information "Loaded Azure profile '$($profileDirectory.Name)' for module '$($instance.Name)'"
103107
$exportsPath = $profileDirectory.FullName
104108
}
105-
109+
106110
if($exportsPath) {
107111
Get-ChildItem -Path $exportsPath -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
108112
$cmdletNames = Get-ScriptCmdlet -ScriptFolder $exportsPath

src/ConnectedMachine/ConnectedMachine.Autorest/generated/Module.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine
1717
using SignalDelegate = global::System.Func<string, global::System.Threading.CancellationToken, global::System.Func<global::System.EventArgs>, global::System.Threading.Tasks.Task>;
1818
using EventListenerDelegate = global::System.Func<string, global::System.Threading.CancellationToken, global::System.Func<global::System.EventArgs>, global::System.Func<string, global::System.Threading.CancellationToken, global::System.Func<global::System.EventArgs>, global::System.Threading.Tasks.Task>, global::System.Management.Automation.InvocationInfo, string, string, string, global::System.Exception, global::System.Threading.Tasks.Task>;
1919
using NextDelegate = global::System.Func<global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken, global::System.Action, global::System.Func<string, global::System.Threading.CancellationToken, global::System.Func<global::System.EventArgs>, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task<global::System.Net.Http.HttpResponseMessage>>;
20+
using SanitizerDelegate = global::System.Action<object, string>;
21+
using GetTelemetryInfoDelegate = global::System.Func<string, global::System.Collections.Generic.Dictionary<global::System.String,global::System.String>>;
2022

2123
/// <summary>A class that contains the module-common code and data.</summary>
2224
public partial class Module
@@ -59,6 +61,9 @@ public partial class Module
5961
/// <summary>The delegate to get the telemetry Id.</summary>
6062
public GetTelemetryIdDelegate GetTelemetryId { get; set; }
6163

64+
/// <summary>The delegate to get the telemetry info.</summary>
65+
public GetTelemetryInfoDelegate GetTelemetryInfo { get; set; }
66+
6267
/// <summary>the singleton of this module class</summary>
6368
public static Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Module Instance { get { if (_instance == null) { lock (_singletonLock) { if (_instance == null) { _instance = new Module(); }}} return _instance; } }
6469

@@ -77,6 +82,9 @@ public partial class Module
7782
/// <summary>The ResourceID for this module (azure arm).</summary>
7883
public string ResourceId => @"Az.ConnectedMachine";
7984

85+
/// <summary>The delegate to call in WriteObject to sanitize the output object.</summary>
86+
public SanitizerDelegate SanitizeOutput { get; set; }
87+
8088
/// <summary>The delegate for creating a telemetry.</summary>
8189
public TelemetryDelegate Telemetry { get; set; }
8290

src/ConnectedMachine/ConnectedMachine.Autorest/generated/cmdlets/GetAzConnectedExtensionMetadata_Get.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,16 @@ protected override void EndProcessing()
248248
// Flush buffer
249249
WriteObject(_firstResponse);
250250
}
251+
var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId);
252+
if (telemetryInfo != null)
253+
{
254+
telemetryInfo.TryGetValue("SanitizedProperties", out var sanitizedProperties);
255+
telemetryInfo.TryGetValue("InvocationName", out var invocationName);
256+
if (!string.IsNullOrEmpty(sanitizedProperties))
257+
{
258+
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");
259+
}
260+
}
251261
}
252262

253263
/// <summary>
@@ -421,6 +431,21 @@ protected override void StopProcessing()
421431
base.StopProcessing();
422432
}
423433

434+
/// <param name="sendToPipeline"></param>
435+
new protected void WriteObject(object sendToPipeline)
436+
{
437+
Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
438+
base.WriteObject(sendToPipeline);
439+
}
440+
441+
/// <param name="sendToPipeline"></param>
442+
/// <param name="enumerateCollection"></param>
443+
new protected void WriteObject(object sendToPipeline, bool enumerateCollection)
444+
{
445+
Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
446+
base.WriteObject(sendToPipeline, enumerateCollection);
447+
}
448+
424449
/// <summary>
425450
/// a delegate that is called when the remote service returns default (any response code not handled elsewhere).
426451
/// </summary>

src/ConnectedMachine/ConnectedMachine.Autorest/generated/cmdlets/GetAzConnectedExtensionMetadata_List.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,16 @@ protected override void EndProcessing()
232232
// Flush buffer
233233
WriteObject(_firstResponse);
234234
}
235+
var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId);
236+
if (telemetryInfo != null)
237+
{
238+
telemetryInfo.TryGetValue("SanitizedProperties", out var sanitizedProperties);
239+
telemetryInfo.TryGetValue("InvocationName", out var invocationName);
240+
if (!string.IsNullOrEmpty(sanitizedProperties))
241+
{
242+
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");
243+
}
244+
}
235245
}
236246

237247
/// <summary>
@@ -405,6 +415,21 @@ protected override void StopProcessing()
405415
base.StopProcessing();
406416
}
407417

418+
/// <param name="sendToPipeline"></param>
419+
new protected void WriteObject(object sendToPipeline)
420+
{
421+
Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
422+
base.WriteObject(sendToPipeline);
423+
}
424+
425+
/// <param name="sendToPipeline"></param>
426+
/// <param name="enumerateCollection"></param>
427+
new protected void WriteObject(object sendToPipeline, bool enumerateCollection)
428+
{
429+
Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
430+
base.WriteObject(sendToPipeline, enumerateCollection);
431+
}
432+
408433
/// <summary>
409434
/// a delegate that is called when the remote service returns default (any response code not handled elsewhere).
410435
/// </summary>

src/ConnectedMachine/ConnectedMachine.Autorest/generated/cmdlets/GetAzConnectedMachineExtension_Get.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,16 @@ protected override void EndProcessing()
232232
// Flush buffer
233233
WriteObject(_firstResponse);
234234
}
235+
var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId);
236+
if (telemetryInfo != null)
237+
{
238+
telemetryInfo.TryGetValue("SanitizedProperties", out var sanitizedProperties);
239+
telemetryInfo.TryGetValue("InvocationName", out var invocationName);
240+
if (!string.IsNullOrEmpty(sanitizedProperties))
241+
{
242+
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");
243+
}
244+
}
235245
}
236246

237247
/// <summary>
@@ -405,6 +415,21 @@ protected override void StopProcessing()
405415
base.StopProcessing();
406416
}
407417

418+
/// <param name="sendToPipeline"></param>
419+
new protected void WriteObject(object sendToPipeline)
420+
{
421+
Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
422+
base.WriteObject(sendToPipeline);
423+
}
424+
425+
/// <param name="sendToPipeline"></param>
426+
/// <param name="enumerateCollection"></param>
427+
new protected void WriteObject(object sendToPipeline, bool enumerateCollection)
428+
{
429+
Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
430+
base.WriteObject(sendToPipeline, enumerateCollection);
431+
}
432+
408433
/// <summary>
409434
/// a delegate that is called when the remote service returns default (any response code not handled elsewhere).
410435
/// </summary>

src/ConnectedMachine/ConnectedMachine.Autorest/generated/cmdlets/GetAzConnectedMachineExtension_List.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,16 @@ protected override void EndProcessing()
238238
// Flush buffer
239239
WriteObject(_firstResponse);
240240
}
241+
var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId);
242+
if (telemetryInfo != null)
243+
{
244+
telemetryInfo.TryGetValue("SanitizedProperties", out var sanitizedProperties);
245+
telemetryInfo.TryGetValue("InvocationName", out var invocationName);
246+
if (!string.IsNullOrEmpty(sanitizedProperties))
247+
{
248+
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");
249+
}
250+
}
241251
}
242252

243253
/// <summary>
@@ -411,6 +421,21 @@ protected override void StopProcessing()
411421
base.StopProcessing();
412422
}
413423

424+
/// <param name="sendToPipeline"></param>
425+
new protected void WriteObject(object sendToPipeline)
426+
{
427+
Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
428+
base.WriteObject(sendToPipeline);
429+
}
430+
431+
/// <param name="sendToPipeline"></param>
432+
/// <param name="enumerateCollection"></param>
433+
new protected void WriteObject(object sendToPipeline, bool enumerateCollection)
434+
{
435+
Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
436+
base.WriteObject(sendToPipeline, enumerateCollection);
437+
}
438+
414439
/// <summary>
415440
/// a delegate that is called when the remote service returns default (any response code not handled elsewhere).
416441
/// </summary>

src/ConnectedMachine/ConnectedMachine.Autorest/generated/cmdlets/GetAzConnectedMachineRunCommand_Get.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,16 @@ protected override void EndProcessing()
232232
// Flush buffer
233233
WriteObject(_firstResponse);
234234
}
235+
var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId);
236+
if (telemetryInfo != null)
237+
{
238+
telemetryInfo.TryGetValue("SanitizedProperties", out var sanitizedProperties);
239+
telemetryInfo.TryGetValue("InvocationName", out var invocationName);
240+
if (!string.IsNullOrEmpty(sanitizedProperties))
241+
{
242+
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");
243+
}
244+
}
235245
}
236246

237247
/// <summary>
@@ -405,6 +415,21 @@ protected override void StopProcessing()
405415
base.StopProcessing();
406416
}
407417

418+
/// <param name="sendToPipeline"></param>
419+
new protected void WriteObject(object sendToPipeline)
420+
{
421+
Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
422+
base.WriteObject(sendToPipeline);
423+
}
424+
425+
/// <param name="sendToPipeline"></param>
426+
/// <param name="enumerateCollection"></param>
427+
new protected void WriteObject(object sendToPipeline, bool enumerateCollection)
428+
{
429+
Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
430+
base.WriteObject(sendToPipeline, enumerateCollection);
431+
}
432+
408433
/// <summary>
409434
/// a delegate that is called when the remote service returns default (any response code not handled elsewhere).
410435
/// </summary>

src/ConnectedMachine/ConnectedMachine.Autorest/generated/cmdlets/GetAzConnectedMachineRunCommand_List.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,16 @@ protected override void EndProcessing()
238238
// Flush buffer
239239
WriteObject(_firstResponse);
240240
}
241+
var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId);
242+
if (telemetryInfo != null)
243+
{
244+
telemetryInfo.TryGetValue("SanitizedProperties", out var sanitizedProperties);
245+
telemetryInfo.TryGetValue("InvocationName", out var invocationName);
246+
if (!string.IsNullOrEmpty(sanitizedProperties))
247+
{
248+
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");
249+
}
250+
}
241251
}
242252

243253
/// <summary>
@@ -411,6 +421,21 @@ protected override void StopProcessing()
411421
base.StopProcessing();
412422
}
413423

424+
/// <param name="sendToPipeline"></param>
425+
new protected void WriteObject(object sendToPipeline)
426+
{
427+
Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
428+
base.WriteObject(sendToPipeline);
429+
}
430+
431+
/// <param name="sendToPipeline"></param>
432+
/// <param name="enumerateCollection"></param>
433+
new protected void WriteObject(object sendToPipeline, bool enumerateCollection)
434+
{
435+
Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
436+
base.WriteObject(sendToPipeline, enumerateCollection);
437+
}
438+
414439
/// <summary>
415440
/// a delegate that is called when the remote service returns default (any response code not handled elsewhere).
416441
/// </summary>

src/ConnectedMachine/ConnectedMachine.Autorest/generated/cmdlets/GetAzConnectedMachine_Get.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,16 @@ protected override void EndProcessing()
235235
// Flush buffer
236236
WriteObject(_firstResponse);
237237
}
238+
var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId);
239+
if (telemetryInfo != null)
240+
{
241+
telemetryInfo.TryGetValue("SanitizedProperties", out var sanitizedProperties);
242+
telemetryInfo.TryGetValue("InvocationName", out var invocationName);
243+
if (!string.IsNullOrEmpty(sanitizedProperties))
244+
{
245+
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");
246+
}
247+
}
238248
}
239249

240250
/// <summary>
@@ -408,6 +418,21 @@ protected override void StopProcessing()
408418
base.StopProcessing();
409419
}
410420

421+
/// <param name="sendToPipeline"></param>
422+
new protected void WriteObject(object sendToPipeline)
423+
{
424+
Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
425+
base.WriteObject(sendToPipeline);
426+
}
427+
428+
/// <param name="sendToPipeline"></param>
429+
/// <param name="enumerateCollection"></param>
430+
new protected void WriteObject(object sendToPipeline, bool enumerateCollection)
431+
{
432+
Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
433+
base.WriteObject(sendToPipeline, enumerateCollection);
434+
}
435+
411436
/// <summary>
412437
/// a delegate that is called when the remote service returns default (any response code not handled elsewhere).
413438
/// </summary>

0 commit comments

Comments
 (0)