-
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
Added Azure.APIM.PolicyBase #2140
Added Azure.APIM.PolicyBase #2140
Conversation
Hi @BernieWhite I need some feedback and suggestions if needed. Correct design? Currently this should find if the sections has a base property. It does not check if its added before or after an statement, but that does not really matter that much, if an customer have added it after an statement it is probably done for an reason. Global policies is not needed, so excluded, any idea how we can solve that within the function to not break the other cors rule? |
I think for this rule ordering doesn't matter. We want to make sure that base is referenced in each element for all non-global polices. However it is a good idea for a new rule to limit which properties can be used above base such as Does that help? |
Yes. What do you think about the rule logic provided in this PR? Something that should be done otherwise? I also have to find a way to exclude globals here that may be configured within the parent or create a new helper function. Help?
|
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.
@BenjaminEngeset The design is fine. We just need to exclude the global (all APIs) policy.
The policy will be type Microsoft.ApiManagement/service/policies
with name policy
. We should be able to add this to the pre-condition within GetAPIMPolicyNode
. Put it here:
if ($_.properties.format -in 'rawxml', 'xml' -and $_.properties.value) { |
@BernieWhite Gotcha I think, please check latest update. But doesn't this cause |
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.
Yes you will need to add something like a switch to allow this to work correctly and not break the other rule.
@BernieWhite I'm having some issues and debugging has not given me the faulty code yet. I am getting failed test results where I expect it to pass. Probably the rule is configured wrong somewhere. TargetName: api-policy-C
RuleName Outcome Recommendation
-------- ------- --------------
Azure.APIM.PolicyBase Fail Base element for any policy element in a section should be configured.
PS C:\Users\benjamine\PSRule.Rules.Azure\PSRule.Rules.Azure> $ruleResult[5].detail
Reason
------
{Path base: Does not exist., Path base: Does not exist., Path base: Does not exist., Path base: Does not exist.} When testing with the policy value outside PSRule, I am able to see that all sections contain the base member.
|
@BernieWhite Thanks for the catch! I'm still struggling with one particular test case, where not all sections has a This is a
|
@BenjaminEngeset I can't find an issue with your code. Looks like a PSRule bug handling XML nodes. I've updated the rule slightly which works around the issue, but need to do some further investigation and release a fix. I'll log the issue on the PSRule repo. |
Great, thanks! |
@BernieWhite Ready for review, let me know what you think. |
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.
Great work @BenjaminEngeset! Just a few documentation tweaks and we should be good to merge.
Hi @BernieWhite, thanks for the great feedback! Adjusted accordingly, what do you think? |
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.
Thanks @BenjaminEngeset. All good to merge.
PR Summary
Fixes #2072
Added Azure.APIM.PolicyBase rule.
PR Checklist