Skip to content

Commit 6b0bbbd

Browse files
feature: mask sensitive values (#83)
1 parent 9781c2d commit 6b0bbbd

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/ALZ/Private/Convert-HCLVariablesToUserInputConfig.ps1

+8
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ function Convert-HCLVariablesToUserInputConfig {
5858
$inputType = "AzureSubscriptionIds"
5959
}
6060

61+
$sensitive = $false
62+
if($variable.Value[0].PSObject.Properties.Name -contains "sensitive") {
63+
$sensitive = $true
64+
}
65+
6166
$dataType = $variable.Value[0].type
6267
$dataType = $dataType.Replace("`${", "").Replace("}", "")
6368

@@ -66,6 +71,7 @@ function Convert-HCLVariablesToUserInputConfig {
6671
$starterModuleConfigurationInstance | Add-Member -NotePropertyName "Type" -NotePropertyValue $inputType
6772
$starterModuleConfigurationInstance | Add-Member -NotePropertyName "Value" -NotePropertyValue ""
6873
$starterModuleConfigurationInstance | Add-Member -NotePropertyName "DataType" -NotePropertyValue $dataType
74+
$starterModuleConfigurationInstance | Add-Member -NotePropertyName "Sensitive" -NotePropertyValue $sensitive
6975

7076
if($variable.Value[0].PSObject.Properties.Name -contains "default") {
7177
$defaultValue = $variable.Value[0].default
@@ -84,6 +90,8 @@ function Convert-HCLVariablesToUserInputConfig {
8490
$starterModuleConfigurationInstance | Add-Member -NotePropertyName "DefaultValue" -NotePropertyValue $defaultValue
8591
}
8692

93+
94+
8795
if($hasValidation) {
8896
$validator = $validators.PSObject.Properties[$validationType].Value
8997
$description = "$description ($($validator.Description))"

src/ALZ/Private/Request-ConfigurationValue.ps1

+6-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ function Request-ConfigurationValue {
4242
Write-InformationColored ": " -NoNewline -InformationAction Continue
4343
}
4444

45-
$readValue = Read-Host
45+
if($configValue.Sensitive) {
46+
$readValue = Read-Host -MaskInput
47+
} else {
48+
$readValue = Read-Host
49+
}
4650

4751
$previousValue = $configValue.Value
4852

@@ -55,7 +59,7 @@ function Request-ConfigurationValue {
5559
$hasNotSpecifiedValue = ($null -eq $configValue.Value -or "" -eq $configValue.Value) -and ($configValue.Value -ne $configValue.DefaultValue)
5660
$isDisallowedValue = $hasAllowedValues -and $allowedValues.Contains($configValue.Value) -eq $false
5761
$skipValidationForEmptyDefault = $treatEmptyDefaultAsValid -and $hasDefaultValue -and $defaultValue -eq "" -and $configValue.Value -eq ""
58-
62+
5963
if($skipValidationForEmptyDefault) {
6064
$isNotValid = $false
6165
} else {

0 commit comments

Comments
 (0)