fix: correct operator precedence in isDestinationMatched deny pattern#28854
fix: correct operator precedence in isDestinationMatched deny pattern#28854magic-peach wants to merge 2 commits into
Conversation
The && dstNamespaceMatched condition only applied to the server deny pattern due to && binding tighter than ||. Name-based deny patterns incorrectly rejected destinations without considering namespace, breaking project destination deny-list enforcement symmetry with the match logic. Signed-off-by: Akanksha Trehun <akankshatrehun@gmail.com>
❗ Preview Environment deployment failed on BunnyshellSee: Environment Details | Pipeline Logs Available commands (reply to this comment):
|
PR Summary by QodoFix deny-pattern operator precedence in isDestinationMatched
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
15 rules🟡 Remediation Recommended 1.
|
nitishfy
left a comment
There was a problem hiding this comment.
The changes looks good to me. Can you add some tests to verify these changes?
| case matched: | ||
| anyDestinationMatched = true | ||
| case (!dstNameMatched && isDenyPattern(item.Name)) || (!dstServerMatched && isDenyPattern(item.Server)) && dstNamespaceMatched: | ||
| case ((!dstNameMatched && isDenyPattern(item.Name)) || (!dstServerMatched && isDenyPattern(item.Server))) && dstNamespaceMatched: |
Bundle ReportBundle size has no change ✅ |
Cover the name-deny + namespace-mismatch case that was broken by the operator precedence bug in isDestinationMatched. Signed-off-by: Akanksha Trehun <akankshatrehun@gmail.com>
Summary
Fixed an operator precedence bug in
isDestinationMatchedatpkg/apis/application/v1alpha1/app_project_types.go:519.Problem
Due to
&&binding tighter than||, the&& dstNamespaceMatchedcondition only applied to the server deny pattern, not the name deny pattern:Name-based deny patterns (like
!prod-*) rejected destinations regardless of namespace, while server-based deny patterns (like!https://staging) correctly required namespace match first. This broke symmetry with the match logic on line 515:Fix
Added parentheses to enforce intended grouping:
Both name and server deny patterns now correctly require namespace match, consistent with the match logic.