You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running PSRule against APIM policies that sucessfully deploys on Azure, the rule fails due to being unable to convert the XML of the policy
Error messages
##[error]AZR-000371: apim-name/api-name failed Azure.APIM.PolicyBase with the error 'Cannot convert value "<!-- Add policies as children to the <inbound>, <outbound>, <backend>, and <on-error> elements -->
<policies>
<!-- Throttle, authorize, validate, cache, or transform the requests -->
<inbound>
<base />
<set-backend-service base-url="{{backend}}" />
<authentication-managed-identity resource="{{audiencee}}" />
<set-variable name="originalHost" value="@(context.Rquest.Headers.GetValueOrDefault("X-Original-Host", "NotAvailable"))" />
</inbound>
<!-- Control if and how the requests are forwarded to services -->
<backend>
<base />
</backend>
<!-- Customize the responses -->
<outbound>
<base />
</outbound>
<!-- Handle exceptions and customize error responses -->
<on-error>
<base />
</on-error>
</policies>" to type "System.Xml.XmlDocument". Error: "'X-Original-Host' is an unexpected token. Expecting whitespace. Line 15, position 89."'.
At /usr/local/share/powershell/Modules/PSRule.Rules.Azure/1.39.3/rules/Azure.APIM.Rule.ps1:384 char:21
+ $policies | ForEach-Object {
+ ~~~~~~~~~~~~~~~~
at <ScriptBlock>, /usr/local/share/powershell/Modules/PSRule.Rules.Azure/1.39.3/rules/Azure.APIM.Rule.ps1: line 386
at global:GetAPIMPolicyNode<Process>, /usr/local/share/powershell/Modules/PSRule.Rules.Azure/1.39.3/rules/Azure.APIM.Rule.ps1: line 384
at <ScriptBlock>, /usr/local/share/powershell/Modules/PSRule.Rules.Azure/1.39.3/rules/Azure.APIM.Rule.ps1: line 326
at Rule 'Azure.APIM.PolicyBase', /usr/local/share/powershell/Modules/PSRule.Rules.Azure/1.39.3/rules/Azure.APIM.Rule.ps1: line 325
Reproduction
Try to run PSRule against a bicep template that deploys the following policy for an API with rawxml as the format
<!--
- Policies are applied in the order they appear.
- Position <base/> inside a section to inherit policies from the outer scope.
- Comments within policies are not preserved.
-->
<!-- Add policies as children to the <inbound>, <outbound>, <backend>, and <on-error> elements -->
<policies>
<!-- Throttle, authorize, validate, cache, or transform the requests -->
<inbound>
<base />
<set-backend-service base-url="{{backend}}" />
<authentication-managed-identity resource="{{audiencee}}" />
<set-variable name="originalHost" value="@(context.Rquest.Headers.GetValueOrDefault("X-Original-Host", "NotAvailable"))" />
</inbound>
<!-- Control if and how the requests are forwarded to services -->
<backend>
<base />
</backend>
<!-- Customize the responses -->
<outbound>
<base />
</outbound>
<!-- Handle exceptions and customize error responses -->
<on-error>
<base />
</on-error>
</policies>
The rule will fails but a deployment of the template to Azure will succeed
Version of PSRule
2.9.0
Version of PSRule for Azure
1.39.3
Additional context
No response
The text was updated successfully, but these errors were encountered:
GABRIELNGBTUC
changed the title
[BUG] APIM policies with C# code rules fail to convert valid XML into type System.XML.XmlDocument
[BUG] APIM policies rules parsing policies with C# code fail to convert valid XML into type System.XML.XmlDocument
Nov 22, 2024
GABRIELNGBTUC
changed the title
[BUG] APIM policies rules parsing policies with C# code fail to convert valid XML into type System.XML.XmlDocument
[BUG] APIM policies rules parsing policies with C# code fail to convert deployable XML into type System.XML.XmlDocument
Nov 22, 2024
Existing rule
Azure.APIM.CORSPolicy and Azure.APIM.PolicyBase
Description of the issue
When running PSRule against APIM policies that sucessfully deploys on Azure, the rule fails due to being unable to convert the XML of the policy
Error messages
Reproduction
Try to run PSRule against a bicep template that deploys the following policy for an API with
rawxml
as the formatThe rule will fails but a deployment of the template to Azure will succeed
Version of PSRule
2.9.0
Version of PSRule for Azure
1.39.3
Additional context
No response
The text was updated successfully, but these errors were encountered: