-
Notifications
You must be signed in to change notification settings - Fork 391
HealthChecker: Fix IIS URL rewrite rule display bugs #2548
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -612,6 +612,14 @@ function Invoke-AnalyzerIISInformation { | |
| $currentSection = $urlRewriteRules[$key] | ||
|
|
||
| if ($currentSection.Count -ne 0) { | ||
| # Collect <remove> entries so inherited rules that are removed at a lower level are excluded. | ||
| $excludeRules = @() | ||
| foreach ($section in $currentSection) { | ||
| if ($null -ne $section.Remove) { | ||
| $excludeRules += $section.Remove.Name | ||
| } | ||
| } | ||
|
|
||
| foreach ($rule in $currentSection.rule) { | ||
|
|
||
| if ($null -eq $rule) { | ||
|
|
@@ -621,12 +629,24 @@ function Invoke-AnalyzerIISInformation { | |
| # skip over disabled rules. | ||
| Write-Verbose "skipping over disabled rule: $($rule.Name) for vDir '$key'" | ||
| continue | ||
| } elseif ($rule.Name -in $excludeRules) { | ||
| Write-Verbose "skipping removed rule: $($rule.Name) for vDir '$key'" | ||
| continue | ||
| } | ||
|
|
||
| #multiple match type possibilities, but should only be one per rule. | ||
| $propertyType = ($rule.match | Get-Member | Where-Object { $_.MemberType -eq "Property" }).Name | ||
| $isUrlMatchProblem = $propertyType -eq "url" -and $rule.match.$propertyType -eq "*" | ||
| $matchProperty = "$propertyType - $($rule.match.$propertyType)" | ||
| $allProperties = @(($rule.match | Get-Member | Where-Object { $_.MemberType -eq "Property" }).Name) | ||
| # When <match> has extra attributes (negate, ignoreCase), Get-Member returns multiple properties. | ||
| # Filter to the actual match target property for display and the URL Match Problem check. | ||
| $propertyType = ($allProperties | Where-Object { $_ -eq "url" -or $_ -eq "serverVariable" } | Select-Object -First 1) | ||
|
|
||
| if ($null -eq $propertyType) { | ||
| $propertyType = $allProperties | Select-Object -First 1 | ||
| } | ||
|
|
||
| $matchValue = $rule.match.$propertyType | ||
| $isUrlMatchProblem = $propertyType -eq "url" -and $matchValue -eq "*" | ||
| $matchProperty = "$propertyType - $matchValue" | ||
|
|
||
| $displayObject = [PSCustomObject]@{ | ||
| RewriteRuleName = $rule.name | ||
|
|
@@ -682,6 +702,13 @@ function Invoke-AnalyzerIISInformation { | |
| $currentSection = $urlOutboundRewriteRules[$key] | ||
|
|
||
| if ($currentSection.Count -ne 0) { | ||
| $excludeOutboundRules = @() | ||
| foreach ($section in $currentSection) { | ||
| if ($null -ne $section.Remove) { | ||
| $excludeOutboundRules += $section.Remove.Name | ||
| } | ||
| } | ||
|
Comment on lines
+705
to
+710
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Valid edge case. The concern is about the "remove-then-readd" pattern where a rule is removed and re-added with different settings in the same section: <rules>
<remove name="InheritedRule" />
<!-- Override inherited version with different config -->
<rule name="InheritedRule" stopProcessing="false">
<match url="different-pattern" />
<action type="Rewrite" url="new-destination" />
</rule>
</rules>IIS processes this as: remove the inherited version, then add the new local version. Our up-front exclude collection would incorrectly hide the re-added rule because the name matches the However, this pattern is not used in Exchange environments. The typical Exchange pattern is a simple |
||
|
|
||
| foreach ($rule in $currentSection.rule) { | ||
|
|
||
| if ($null -eq $rule) { | ||
|
|
@@ -690,6 +717,9 @@ function Invoke-AnalyzerIISInformation { | |
| } elseif ($rule.enabled -eq "false") { | ||
| Write-Verbose "skipping over disabled outbound rule: $($rule.Name) for vDir '$key'" | ||
| continue | ||
| } elseif ($rule.Name -in $excludeOutboundRules) { | ||
| Write-Verbose "skipping removed outbound rule: $($rule.Name) for vDir '$key'" | ||
| continue | ||
| } | ||
|
|
||
| $displayObject = [PSCustomObject]@{ | ||
|
|
||
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.
Same response as the inbound comment — this is the same pattern applied to outbound rules. Not a concern for Exchange environments.