-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Included the change to auto remediate the Redis Cache BRS #255
base: main
Are you sure you want to change the base?
Conversation
Write-Host "Connecting to Azure account..." | ||
Connect-AzAccount -Subscription $SubscriptionId -ErrorAction Stop | Out-Null | ||
Write-Host "Connected to Azure account." -ForegroundColor $([Constants]::MessageType.Update) | ||
Write-Host "No active Azure login session found. Exiting..." -ForegroundColor $([Constants]::MessageType.Error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also tell the user what action to perform in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Vamsee, tried to add msg as ' please try to reconnect your azure account as 'connect-az account' with subs id.
pls help to have a look
{ | ||
if (-not (Test-Path -Path $Path)) | ||
{ | ||
Write-Host "File containing failing controls details [$($Path)] not found. Skipping remediation..." -ForegroundColor $([Constants]::MessageType.Error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What action user has to take in this case? Can we guide the user better?
Especially in auto remediation, last option which user should have is to reach out to us.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added the msg to verify if path is correct and failed control are placed on the same path
$logResource.Add("ResourceName",($_.ResourceName)) | ||
$logResource.Add("Reason","Encountered error while disabling Non-SSL port on Redis Cache(s) configuration") | ||
$logSkippedResources += $logResource | ||
Write-Host "Skipping this resource..." -ForegroundColor $([Constants]::MessageType.Warning) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the user action needed in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will require some research as this is on the control level and how it failed.
|
||
# Connect to Azure account | ||
$context = Get-AzContext | ||
|
||
if ([String]::IsNullOrWhiteSpace($context)) | ||
{ | ||
Write-Host $([Constants]::SingleDashLine) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why removed these lines?
|
||
if ($PerformPreReqCheck) | ||
{ | ||
try | ||
{ | ||
Write-Host "[Step 1 of 4] Validating and installing the modules required to run the script and validating the user..." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this was better way for describing this step?
Write-Host $([Constants]::SingleDashLine) | ||
|
||
# list for storing Redis Cache(s) for which Non-SSL port is enabled. | ||
$RedisCacheWithNonSSLPortEnabled = @() | ||
|
||
Write-Host "Separating Redis Cache(s) for which Non-SSL port is enabled..." | ||
Write-Host "Separate Redis Cache(s) for which Non-SSL port is enabled." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a step right? so separating was better here also make it info
@@ -306,10 +382,14 @@ function Disable-NonSSLPortOnRedisCache | |||
if ($totalRedisCacheWithNonSSLPortEnabled -eq 0) | |||
{ | |||
Write-Host "No Redis Cache(s) found with Non-SSL port enabled.. Exiting..." -ForegroundColor $([Constants]::MessageType.Warning) | |||
break | |||
Write-Host $([Constants]::DoubleDashLine) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since here we are returning the control back/ending execution.
Though we have 0 redis cache having non ssl port enabled but if we have any redis cache resource we should show that in log file right? as they all skipped.
So add that code block here =>
if($AutoRemediation -and $totalCloudService -gt 0)
{
$log = Get-content -Raw -path $logFile | ConvertFrom-Json
foreach($logControl in $log.ControlList){
if($logControl.ControlId -eq $controlIds){
$logControl.RemediatedResources=$logRemediatedResources
$logControl.SkippedResources=$logSkippedResources
}
}
$log | ConvertTo-json -depth 100 | Out-File $logFile
}
similar to this
@@ -363,12 +445,14 @@ function Disable-NonSSLPortOnRedisCache | |||
if($userInput -ne "Y") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(-not force) one should have an wrapper condtion of if(-not $Autoremediation) as for autoremediation feature we won't be asking input from user again
@@ -439,7 +585,7 @@ function Disable-NonSSLPortOnRedisCache | |||
Write-Host $([Constants]::DoubleDashLine) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Step 4 of 4 :
remove ... from last
} | ||
|
||
if ($($RedisCacheSkipped | Measure-Object).Count -gt 0) | ||
{ | ||
Write-Host "`nError disabling Non-SSL port on the following Redis Cache(s)in the subscription:" -ForegroundColor $([Constants]::MessageType.Error) | ||
|
||
$RedisCacheSkipped | Format-Table -Property $colsProperty -Wrap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to display table when autoremediation feature is in use.
|
||
$RedisCacheRemediated | Format-Table -Property $colsProperty -Wrap | ||
|
||
$RedisCacheRemediated | Format-Table -Property $colsProperty -Wrap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed when autoremediation feature is in use
} | ||
} | ||
else | ||
{ | ||
Write-Host "[Step 1 of 3] Validating the user..." | ||
Write-Host "[Step 1 of 3] Validate the user..." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove '...' from end
} | ||
} | ||
else | ||
{ | ||
Write-Host "[Step 1 of 3] Validating the user..." | ||
Write-Host "[Step 1 of 3] Validate the user..." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly from Step 1 of 3, remove '...' from end.
@@ -508,12 +654,14 @@ function Enable-NonSSLPortOnRedisCache | |||
catch | |||
{ | |||
Write-Host "Error occurred while setting up prerequisites. Error: $($_)" -ForegroundColor $([Constants]::MessageType.Error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error: [$($_)]
|
||
Write-Host $([Constants]::DoubleDashLine) | ||
Write-Host "[Step 2 of 3] Preparing to fetch all Redis Cache(s)..." | ||
Write-Host "[Step 2 of 3] Prepare to fetch all Redis Cache(s)..." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove '...' from end
} | ||
|
||
Write-Host "Fetching all Redis Cache(s) from" -NoNewline | ||
Write-Host "Fetch all Redis Cache(s) from" -NoNewline |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here it will be fetching as we are performing an action
@@ -582,7 +733,7 @@ function Enable-NonSSLPortOnRedisCache | |||
|
|||
|
|||
Write-Host $([Constants]::DoubleDashLine) | |||
Write-Host "[Step 3 of 3] Enabling SSL port for all Redis Cache(s) in the Subscription..." | |||
Write-Host "[Step 3 of 3] Enable SSL port for all Redis Cache(s) in the Subscription..." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove '...' from end
Hey Saurabh,
Please help to review and approve. thanks