Skip to content

Commit 5e3cd07

Browse files
committed
Revert "added sensitive data redaction for powershell host"
This reverts commit c70630c.
1 parent c70630c commit 5e3cd07

File tree

6 files changed

+3
-211
lines changed

6 files changed

+3
-211
lines changed

generator/AWSPSGeneratorLib/FormatConfig/ConfigModel.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ internal HashSet<string> TypeInclusionSet
7171
}
7272

7373
/// <summary>
74-
/// Specific types to exclude from the emitted formats. This list will be
74+
/// Specific types to exlude from the emitted formats. This list will be
7575
/// automatically extended to include any types found in custom format files.
7676
/// </summary>
7777
[XmlArray]
@@ -245,21 +245,16 @@ public class ColumnConfig
245245
public HeaderAlignment HeaderAlignment { get; set; }
246246
[XmlAttribute]
247247
public int HeaderOrder { get; set; }
248-
[XmlIgnore]
249-
public bool IsSensitive { get; set; }
250248

251249
[XmlAttribute]
252250
public string ScriptBlock { get; set; }
253251
[XmlAttribute]
254252
public string PropertyName { get; set; }
255253

256-
257-
258254
public ColumnConfig()
259255
{
260256
ScriptBlock = null;
261257
PropertyName = null;
262-
IsSensitive = false;
263258

264259
HeaderLabel = null;
265260
HeaderWidth = 0;
@@ -273,7 +268,6 @@ public void Merge(ColumnConfig other)
273268
HeaderWidth = other.HeaderWidth != 0 ? other.HeaderWidth : this.HeaderWidth;
274269
HeaderAlignment = other.HeaderAlignment != HeaderAlignment.None ? other.HeaderAlignment : this.HeaderAlignment;
275270
HeaderOrder = other.HeaderOrder != 0 ? other.HeaderOrder : this.HeaderOrder;
276-
IsSensitive = other.IsSensitive || this.IsSensitive;
277271

278272
ScriptBlock = other.ScriptBlock ?? this.ScriptBlock;
279273
PropertyName = other.PropertyName ?? this.PropertyName;

generator/AWSPSGeneratorLib/Generators/FormatGenerator.cs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ public class FormatGenerator : Generator
3232
private ConfigModelCollection ConfigCollection { get; set; }
3333

3434
private const string AwsToolsPrefix = "AWS.Tools.";
35-
36-
private const string SensitiveDataRedactionMessage = "*** sensitive data redacted from host ***";
3735
#endregion
3836

3937

@@ -177,8 +175,7 @@ private void GenerateView(ConfigModel config, XmlWriter writer, Type type)
177175
existingColumn.Merge(new ColumnConfig
178176
{
179177
HeaderLabel = name,
180-
PropertyName = name,
181-
IsSensitive = property.IsSensitive()
178+
PropertyName = name
182179
});
183180

184181
newConfig.Columns.Add(existingColumn);
@@ -325,16 +322,7 @@ private void GenerateView_NonReflective(ConfigModel config, XmlWriter writer, Ty
325322
{
326323
writer.WriteStartElement(isTableView ? "TableColumnItem" : "ListItem");
327324
{
328-
if (column.IsSensitive)
329-
{
330-
if (!isTableView)
331-
writer.WriteElementString("Label", column.PropertyName);
332-
333-
string scriptBlockValue =
334-
$"if((Test-Path variable:AWSPowerShell_Show_Sensitive_Data) -and $false.Equals((Get-Variable AWSPowerShell_Show_Sensitive_Data).Value)){{'{SensitiveDataRedactionMessage}'}} else{{$_.{column.PropertyName}}}";
335-
writer.WriteElementString("ScriptBlock", scriptBlockValue);
336-
}
337-
else if (!string.IsNullOrEmpty(column.PropertyName))
325+
if (!string.IsNullOrEmpty(column.PropertyName))
338326
writer.WriteElementString("PropertyName", column.PropertyName);
339327
else if (!string.IsNullOrEmpty(column.ScriptBlock))
340328
writer.WriteElementString("ScriptBlock", column.ScriptBlock);

generator/AWSPSGeneratorLib/Utils/Extensions.cs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Text;
55
using System.Xml.Serialization;
66
using System.IO;
7-
using System.Reflection;
87

98
namespace AWSPowerShellGenerator.Utils
109
{
@@ -46,27 +45,5 @@ public static string GetTypeFullCodeName(this Type t)
4645

4746
return typeName + "<" + args + ">";
4847
}
49-
50-
public static bool IsSensitive(this PropertyInfo propertyInfo)
51-
{
52-
dynamic awsPropertyAttribute = propertyInfo
53-
.GetCustomAttributes().SingleOrDefault(attribute => attribute.GetType().FullName == "Amazon.Runtime.Internal.AWSPropertyAttribute");
54-
55-
return awsPropertyAttribute != null && awsPropertyAttribute.Sensitive;
56-
}
57-
58-
/// <summary>
59-
/// Checks if the type contains any sensitive data by going recursively over all the internal properties
60-
/// </summary>
61-
public static bool ContainsSensitiveData(this Type type, HashSet<Type> visitedTypes = null)
62-
{
63-
visitedTypes ??= [];
64-
65-
if (!visitedTypes.Add(type))
66-
return false;
67-
68-
return type.GetProperties().Any(childProperty => IsSensitive(childProperty) || ContainsSensitiveData(childProperty.PropertyType, visitedTypes));
69-
}
70-
7148
}
7249
}

modules/AWSPowerShell/Common/CommonCmdlets.cs

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -526,80 +526,4 @@ protected override void ProcessRecord()
526526
}
527527
}
528528
}
529-
530-
/// <summary>
531-
/// Controls the display of sensitive information in the PowerShell console output.
532-
/// When set to false (default), sensitive data is masked in the console display.
533-
/// When set to true, sensitive data is shown in plain text.
534-
/// Note: This setting only affects console display - stored variables retain the original unmasked data regardless of this setting.
535-
/// This cmdlet sets a shell variable AWSPowerShell_Show_Sensitive_Data using the scope.
536-
/// </summary>
537-
[Cmdlet("Set", "AWSSensitiveDataConfiguration")]
538-
[AWSCmdlet("Controls the display of sensitive information in the PowerShell console output. When set to true, sensitive data is shown in plain text in the console output.")]
539-
[OutputType("None")]
540-
public class SetAWSSensitiveDataConfigurationCmdlet : PSCmdlet
541-
{
542-
#region Parameter ShowSensitiveData
543-
544-
/// <summary>
545-
/// Controls whether sensitive data appears in PowerShell console output.
546-
/// When set to true, displays un-redacted sensitive data in the console.
547-
/// When set to false (default), automatically masks sensitive data in console output.
548-
/// </summary>
549-
[Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)]
550-
public bool ShowSensitiveData { get; set; }
551-
552-
#endregion
553-
554-
#region Parameter Scope
555-
/// <summary>
556-
/// <para>
557-
/// Sets the scope of the shell variable AWSPowerShell_Show_Sensitive_Data.
558-
/// For details about variables scopes, see https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_scopes.
559-
/// </para>
560-
/// </summary>
561-
[Parameter(ValueFromPipelineByPropertyName = true)]
562-
public VariableScope Scope { get; set; }
563-
#endregion
564-
565-
protected override void ProcessRecord()
566-
{
567-
base.ProcessRecord();
568-
WriteVerbose($"Setting AWSShowSensitiveData to {ShowSensitiveData}");
569-
string scope = MyInvocation.BoundParameters.ContainsKey("Scope") ? Scope.ToString() + ":" : "";
570-
571-
this.SessionState.PSVariable.Set(scope+ SessionKeys.AWSShowSensitiveData, ShowSensitiveData);
572-
}
573-
}
574-
575-
/// <summary>
576-
/// Returns the current configuration value that controls how sensitive data is displayed in the PowerShell console.
577-
/// This cmdlet returns a Boolean value indicating whether sensitive data is shown or redacted in console output.
578-
/// </summary>
579-
[Cmdlet("Get", "AWSSensitiveDataConfiguration")]
580-
[AWSCmdlet("Gets the current configuration settings for sensitive data display in PowerShell output.")]
581-
[OutputType("PSObject")]
582-
public class GetAWSSensitiveDataConfigurationCmdlet : PSCmdlet
583-
{
584-
protected override void ProcessRecord()
585-
{
586-
base.ProcessRecord();
587-
var showSensitiveData = this.SessionState.PSVariable.Get(SessionKeys.AWSShowSensitiveData);
588-
var result = new PSObject();
589-
590-
// in v4 default ShowSensitiveData is true
591-
const bool defaultShowSensitiveData = true;
592-
593-
var noteProperty = new PSNoteProperty("ShowSensitiveData", defaultShowSensitiveData);
594-
595-
if (showSensitiveData != null)
596-
{
597-
noteProperty.Value = (bool)showSensitiveData.Value;
598-
599-
}
600-
601-
result.Properties.Add(noteProperty);
602-
WriteObject(result);
603-
}
604-
}
605529
}

modules/AWSPowerShell/Common/CredentialsArguments.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,6 @@ internal static class SessionKeys
799799
public const string AWSCredentialsVariableName = "StoredAWSCredentials";
800800
public const string AWSRegionVariableName = "StoredAWSRegion";
801801
public const string AWSCallHistoryName = "AWSHistory";
802-
public const string AWSShowSensitiveData = "AWSPowerShell_Show_Sensitive_Data";
803802
public const string AWSProxyVariableName = "AWSProxy";
804803
}
805804

tests/Common/Common.AWSSensitiveDataConfiguration.Tests.ps1

Lines changed: 0 additions & 90 deletions
This file was deleted.

0 commit comments

Comments
 (0)