Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Resources/Authorization.Autorest/Az.Authorization.psd1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@{
GUID = '35fb50e5-5759-4cce-99c9-41fcbe73bee8'
GUID = '6e38b027-1850-467b-9682-953545209e51'
RootModule = './Az.Authorization.psm1'
ModuleVersion = '0.1.0'
CompatiblePSEditions = 'Core', 'Desktop'
Expand Down
24 changes: 14 additions & 10 deletions src/Resources/Authorization.Autorest/Az.Authorization.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -47,37 +47,41 @@

# Ask for the shared functionality table
$VTable = Register-AzModule

# Tweaks the pipeline on module load
$instance.OnModuleLoad = $VTable.OnModuleLoad

# Following two delegates are added for telemetry
$instance.GetTelemetryId = $VTable.GetTelemetryId
$instance.Telemetry = $VTable.Telemetry


# Delegate to sanitize the output object
$instance.SanitizeOutput = $VTable.SanitizerHandler

# Delegate to get the telemetry info
$instance.GetTelemetryInfo = $VTable.GetTelemetryInfo

# Tweaks the pipeline per call
$instance.OnNewRequest = $VTable.OnNewRequest

# Gets shared parameter values
$instance.GetParameterValue = $VTable.GetParameterValue

# Allows shared module to listen to events from this module
$instance.EventListener = $VTable.EventListener

# Gets shared argument completers
$instance.ArgumentCompleter = $VTable.ArgumentCompleter

# The name of the currently selected Azure profile
$instance.ProfileName = $VTable.ProfileName


# Load the custom module
$customModulePath = Join-Path $PSScriptRoot './custom/Az.Authorization.custom.psm1'
if(Test-Path $customModulePath) {
$null = Import-Module -Name $customModulePath
}

# Export nothing to clear implicit exports
Export-ModuleMember

Expand All @@ -97,12 +101,12 @@
# Load the last folder if no profile is selected
$profileDirectory = $directories | Select-Object -Last 1
}

if($profileDirectory) {
Write-Information "Loaded Azure profile '$($profileDirectory.Name)' for module '$($instance.Name)'"
$exportsPath = $profileDirectory.FullName
}

if($exportsPath) {
Get-ChildItem -Path $exportsPath -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
$cmdletNames = Get-ScriptCmdlet -ScriptFolder $exportsPath
Expand Down
8 changes: 8 additions & 0 deletions src/Resources/Authorization.Autorest/generated/Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.Resources.Authorization
using SignalDelegate = global::System.Func<string, global::System.Threading.CancellationToken, global::System.Func<global::System.EventArgs>, global::System.Threading.Tasks.Task>;
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>;
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>>;
using SanitizerDelegate = global::System.Action<object, string>;
using GetTelemetryInfoDelegate = global::System.Func<string, global::System.Collections.Generic.Dictionary<global::System.String,global::System.String>>;

/// <summary>A class that contains the module-common code and data.</summary>
public partial class Module
Expand Down Expand Up @@ -51,6 +53,9 @@ public partial class Module
/// <summary>The delegate to get the telemetry Id.</summary>
public GetTelemetryIdDelegate GetTelemetryId { get; set; }

/// <summary>The delegate to get the telemetry info.</summary>
public GetTelemetryInfoDelegate GetTelemetryInfo { get; set; }

/// <summary>Backing field for <see cref="Instance" /> property.</summary>
private static Microsoft.Azure.PowerShell.Cmdlets.Resources.Authorization.Module _instance;

Expand All @@ -72,6 +77,9 @@ public partial class Module
/// <summary>The ResourceID for this module (azure arm).</summary>
public string ResourceId => @"Az.Authorization";

/// <summary>The delegate to call in WriteObject to sanitize the output object.</summary>
public SanitizerDelegate SanitizeOutput { get; set; }

/// <summary>The delegate for creating a telemetry.</summary>
public TelemetryDelegate Telemetry { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,24 @@ protected override void BeginProcessing()
/// <summary>Performs clean-up after the command execution</summary>
protected override void EndProcessing()
{

var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.Resources.Authorization.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId);
if (telemetryInfo != null)
{
telemetryInfo.TryGetValue("ShowSecretsWarning", out var showSecretsWarning);
telemetryInfo.TryGetValue("SanitizedProperties", out var sanitizedProperties);
telemetryInfo.TryGetValue("InvocationName", out var invocationName);
if (showSecretsWarning == "true")
{
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");
}
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");
}
}
}
}

/// <summary>
Expand Down Expand Up @@ -316,6 +333,21 @@ protected override void StopProcessing()
base.StopProcessing();
}

/// <param name="sendToPipeline"></param>
new protected void WriteObject(object sendToPipeline)
{
Microsoft.Azure.PowerShell.Cmdlets.Resources.Authorization.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
base.WriteObject(sendToPipeline);
}

/// <param name="sendToPipeline"></param>
/// <param name="enumerateCollection"></param>
new protected void WriteObject(object sendToPipeline, bool enumerateCollection)
{
Microsoft.Azure.PowerShell.Cmdlets.Resources.Authorization.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
base.WriteObject(sendToPipeline, enumerateCollection);
}

/// <summary>
/// a delegate that is called when the remote service returns default (any response code not handled elsewhere).
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,24 @@ protected override void BeginProcessing()
/// <summary>Performs clean-up after the command execution</summary>
protected override void EndProcessing()
{

var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.Resources.Authorization.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId);
if (telemetryInfo != null)
{
telemetryInfo.TryGetValue("ShowSecretsWarning", out var showSecretsWarning);
telemetryInfo.TryGetValue("SanitizedProperties", out var sanitizedProperties);
telemetryInfo.TryGetValue("InvocationName", out var invocationName);
if (showSecretsWarning == "true")
{
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");
}
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");
}
}
}
}

/// <summary>
Expand Down Expand Up @@ -311,6 +328,21 @@ protected override void StopProcessing()
base.StopProcessing();
}

/// <param name="sendToPipeline"></param>
new protected void WriteObject(object sendToPipeline)
{
Microsoft.Azure.PowerShell.Cmdlets.Resources.Authorization.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
base.WriteObject(sendToPipeline);
}

/// <param name="sendToPipeline"></param>
/// <param name="enumerateCollection"></param>
new protected void WriteObject(object sendToPipeline, bool enumerateCollection)
{
Microsoft.Azure.PowerShell.Cmdlets.Resources.Authorization.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
base.WriteObject(sendToPipeline, enumerateCollection);
}

/// <summary>
/// a delegate that is called when the remote service returns default (any response code not handled elsewhere).
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,24 @@ protected override void BeginProcessing()
/// <summary>Performs clean-up after the command execution</summary>
protected override void EndProcessing()
{

var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.Resources.Authorization.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId);
if (telemetryInfo != null)
{
telemetryInfo.TryGetValue("ShowSecretsWarning", out var showSecretsWarning);
telemetryInfo.TryGetValue("SanitizedProperties", out var sanitizedProperties);
telemetryInfo.TryGetValue("InvocationName", out var invocationName);
if (showSecretsWarning == "true")
{
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");
}
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");
}
}
}
}

/// <summary>
Expand Down Expand Up @@ -326,6 +343,21 @@ protected override void StopProcessing()
base.StopProcessing();
}

/// <param name="sendToPipeline"></param>
new protected void WriteObject(object sendToPipeline)
{
Microsoft.Azure.PowerShell.Cmdlets.Resources.Authorization.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
base.WriteObject(sendToPipeline);
}

/// <param name="sendToPipeline"></param>
/// <param name="enumerateCollection"></param>
new protected void WriteObject(object sendToPipeline, bool enumerateCollection)
{
Microsoft.Azure.PowerShell.Cmdlets.Resources.Authorization.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
base.WriteObject(sendToPipeline, enumerateCollection);
}

/// <summary>
/// a delegate that is called when the remote service returns default (any response code not handled elsewhere).
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,24 @@ protected override void BeginProcessing()
/// <summary>Performs clean-up after the command execution</summary>
protected override void EndProcessing()
{

var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.Resources.Authorization.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId);
if (telemetryInfo != null)
{
telemetryInfo.TryGetValue("ShowSecretsWarning", out var showSecretsWarning);
telemetryInfo.TryGetValue("SanitizedProperties", out var sanitizedProperties);
telemetryInfo.TryGetValue("InvocationName", out var invocationName);
if (showSecretsWarning == "true")
{
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");
}
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");
}
}
}
}

/// <summary>
Expand Down Expand Up @@ -316,6 +333,21 @@ protected override void StopProcessing()
base.StopProcessing();
}

/// <param name="sendToPipeline"></param>
new protected void WriteObject(object sendToPipeline)
{
Microsoft.Azure.PowerShell.Cmdlets.Resources.Authorization.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
base.WriteObject(sendToPipeline);
}

/// <param name="sendToPipeline"></param>
/// <param name="enumerateCollection"></param>
new protected void WriteObject(object sendToPipeline, bool enumerateCollection)
{
Microsoft.Azure.PowerShell.Cmdlets.Resources.Authorization.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
base.WriteObject(sendToPipeline, enumerateCollection);
}

/// <summary>
/// a delegate that is called when the remote service returns default (any response code not handled elsewhere).
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,24 @@ protected override void BeginProcessing()
/// <summary>Performs clean-up after the command execution</summary>
protected override void EndProcessing()
{

var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.Resources.Authorization.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId);
if (telemetryInfo != null)
{
telemetryInfo.TryGetValue("ShowSecretsWarning", out var showSecretsWarning);
telemetryInfo.TryGetValue("SanitizedProperties", out var sanitizedProperties);
telemetryInfo.TryGetValue("InvocationName", out var invocationName);
if (showSecretsWarning == "true")
{
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");
}
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");
}
}
}
}

/// <summary>
Expand Down Expand Up @@ -311,6 +328,21 @@ protected override void StopProcessing()
base.StopProcessing();
}

/// <param name="sendToPipeline"></param>
new protected void WriteObject(object sendToPipeline)
{
Microsoft.Azure.PowerShell.Cmdlets.Resources.Authorization.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
base.WriteObject(sendToPipeline);
}

/// <param name="sendToPipeline"></param>
/// <param name="enumerateCollection"></param>
new protected void WriteObject(object sendToPipeline, bool enumerateCollection)
{
Microsoft.Azure.PowerShell.Cmdlets.Resources.Authorization.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
base.WriteObject(sendToPipeline, enumerateCollection);
}

/// <summary>
/// a delegate that is called when the remote service returns default (any response code not handled elsewhere).
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,24 @@ protected override void BeginProcessing()
/// <summary>Performs clean-up after the command execution</summary>
protected override void EndProcessing()
{

var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.Resources.Authorization.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId);
if (telemetryInfo != null)
{
telemetryInfo.TryGetValue("ShowSecretsWarning", out var showSecretsWarning);
telemetryInfo.TryGetValue("SanitizedProperties", out var sanitizedProperties);
telemetryInfo.TryGetValue("InvocationName", out var invocationName);
if (showSecretsWarning == "true")
{
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");
}
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");
}
}
}
}

/// <summary>
Expand Down Expand Up @@ -327,6 +344,21 @@ protected override void StopProcessing()
base.StopProcessing();
}

/// <param name="sendToPipeline"></param>
new protected void WriteObject(object sendToPipeline)
{
Microsoft.Azure.PowerShell.Cmdlets.Resources.Authorization.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
base.WriteObject(sendToPipeline);
}

/// <param name="sendToPipeline"></param>
/// <param name="enumerateCollection"></param>
new protected void WriteObject(object sendToPipeline, bool enumerateCollection)
{
Microsoft.Azure.PowerShell.Cmdlets.Resources.Authorization.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);
base.WriteObject(sendToPipeline, enumerateCollection);
}

/// <summary>
/// a delegate that is called when the remote service returns default (any response code not handled elsewhere).
/// </summary>
Expand Down
Loading