Skip to content

Commit 356972c

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

File tree

42 files changed

+951
-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.

42 files changed

+951
-13
lines changed

src/FirmwareAnalysis/FirmwareAnalysis.Autorest/Az.FirmwareAnalysis.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.FirmwareAnalysis.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/FirmwareAnalysis/FirmwareAnalysis.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.FirmwareAnalysis
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.FirmwareAnalysis.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.FirmwareAnalysis";
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/FirmwareAnalysis/FirmwareAnalysis.Autorest/generated/cmdlets/GetAzFirmwareAnalysisBinaryHardening_List.cs

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

239249
/// <summary>
@@ -407,6 +417,21 @@ protected override void StopProcessing()
407417
base.StopProcessing();
408418
}
409419

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

src/FirmwareAnalysis/FirmwareAnalysis.Autorest/generated/cmdlets/GetAzFirmwareAnalysisCryptoCertificate_List.cs

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

239249
/// <summary>
@@ -407,6 +417,21 @@ protected override void StopProcessing()
407417
base.StopProcessing();
408418
}
409419

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

src/FirmwareAnalysis/FirmwareAnalysis.Autorest/generated/cmdlets/GetAzFirmwareAnalysisCryptoKey_List.cs

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

239249
/// <summary>
@@ -407,6 +417,21 @@ protected override void StopProcessing()
407417
base.StopProcessing();
408418
}
409419

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

src/FirmwareAnalysis/FirmwareAnalysis.Autorest/generated/cmdlets/GetAzFirmwareAnalysisCve_List.cs

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

239249
/// <summary>
@@ -407,6 +417,21 @@ protected override void StopProcessing()
407417
base.StopProcessing();
408418
}
409419

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

src/FirmwareAnalysis/FirmwareAnalysis.Autorest/generated/cmdlets/GetAzFirmwareAnalysisFirmware_Get.cs

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

234244
/// <summary>
@@ -402,6 +412,21 @@ protected override void StopProcessing()
402412
base.StopProcessing();
403413
}
404414

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

src/FirmwareAnalysis/FirmwareAnalysis.Autorest/generated/cmdlets/GetAzFirmwareAnalysisFirmware_GetViaIdentity.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,16 @@ protected override void EndProcessing()
175175
// Flush buffer
176176
WriteObject(_firstResponse);
177177
}
178+
var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.FirmwareAnalysis.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId);
179+
if (telemetryInfo != null)
180+
{
181+
telemetryInfo.TryGetValue("SanitizedProperties", out var sanitizedProperties);
182+
telemetryInfo.TryGetValue("InvocationName", out var invocationName);
183+
if (!string.IsNullOrEmpty(sanitizedProperties))
184+
{
185+
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");
186+
}
187+
}
178188
}
179189

180190
/// <summary>
@@ -369,6 +379,21 @@ protected override void StopProcessing()
369379
base.StopProcessing();
370380
}
371381

382+
/// <param name="sendToPipeline"></param>
383+
new protected void WriteObject(object sendToPipeline)
384+
{
385+
Microsoft.Azure.PowerShell.Cmdlets.FirmwareAnalysis.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
386+
base.WriteObject(sendToPipeline);
387+
}
388+
389+
/// <param name="sendToPipeline"></param>
390+
/// <param name="enumerateCollection"></param>
391+
new protected void WriteObject(object sendToPipeline, bool enumerateCollection)
392+
{
393+
Microsoft.Azure.PowerShell.Cmdlets.FirmwareAnalysis.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
394+
base.WriteObject(sendToPipeline, enumerateCollection);
395+
}
396+
372397
/// <summary>
373398
/// a delegate that is called when the remote service returns default (any response code not handled elsewhere).
374399
/// </summary>

src/FirmwareAnalysis/FirmwareAnalysis.Autorest/generated/cmdlets/GetAzFirmwareAnalysisFirmware_GetViaIdentityWorkspace.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,16 @@ protected override void EndProcessing()
190190
// Flush buffer
191191
WriteObject(_firstResponse);
192192
}
193+
var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.FirmwareAnalysis.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId);
194+
if (telemetryInfo != null)
195+
{
196+
telemetryInfo.TryGetValue("SanitizedProperties", out var sanitizedProperties);
197+
telemetryInfo.TryGetValue("InvocationName", out var invocationName);
198+
if (!string.IsNullOrEmpty(sanitizedProperties))
199+
{
200+
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");
201+
}
202+
}
193203
}
194204

195205
/// <summary>
@@ -381,6 +391,21 @@ protected override void StopProcessing()
381391
base.StopProcessing();
382392
}
383393

394+
/// <param name="sendToPipeline"></param>
395+
new protected void WriteObject(object sendToPipeline)
396+
{
397+
Microsoft.Azure.PowerShell.Cmdlets.FirmwareAnalysis.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
398+
base.WriteObject(sendToPipeline);
399+
}
400+
401+
/// <param name="sendToPipeline"></param>
402+
/// <param name="enumerateCollection"></param>
403+
new protected void WriteObject(object sendToPipeline, bool enumerateCollection)
404+
{
405+
Microsoft.Azure.PowerShell.Cmdlets.FirmwareAnalysis.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
406+
base.WriteObject(sendToPipeline, enumerateCollection);
407+
}
408+
384409
/// <summary>
385410
/// a delegate that is called when the remote service returns default (any response code not handled elsewhere).
386411
/// </summary>

0 commit comments

Comments
 (0)