-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Merging to release-5.3: [TT-12897/TT-13284] Add additional partitioned test case, fix ordering issue (#6635) #6639
Merging to release-5.3: [TT-12897/TT-13284] Add additional partitioned test case, fix ordering issue (#6635) #6639
Conversation
…g issue (#6635) <details open> <summary><a href="https://tyktech.atlassian.net/browse/TT-12897" title="TT-12897" target="_blank">TT-12897</a></summary> <br /> <table> <tr> <th>Summary</th> <td>[Security]Path-Based Permissions permissions in policies are not preserved when policies are combined</td> </tr> <tr> <th>Type</th> <td> <img alt="Bug" src="https://tyktech.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10303?size=medium" /> Bug </td> </tr> <tr> <th>Status</th> <td>In Dev</td> </tr> <tr> <th>Points</th> <td>N/A</td> </tr> <tr> <th>Labels</th> <td><a href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20customer_bug%20ORDER%20BY%20created%20DESC" title="customer_bug">customer_bug</a>, <a href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20jira_escalated%20ORDER%20BY%20created%20DESC" title="jira_escalated">jira_escalated</a>, <a href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20QA_Fail%20ORDER%20BY%20created%20DESC" title="QA_Fail">QA_Fail</a></td> </tr> </table> </details> <!-- do not remove this marker as it will break jira-lint's functionality. added_by_jira_lint --> --- Subtask: https://tyktech.atlassian.net/browse/TT-13284 Parent: https://tyktech.atlassian.net/browse/TT-12897 ___ Bug fix, Tests ___ - Fixed a bug in `applyPartitions` function to ensure `rights` map is filled with known APIs, ensuring policies with ACL rights are honored even if not first. - Improved merging logic for `RestrictedTypes`, `AllowedTypes`, and `FieldAccessRights` to handle empty cases and intersections correctly. - Added test cases to verify the correct application of ACL and rate limits from custom policies, ensuring the order of policies does not affect the outcome. ___ <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Bug fix</strong></td><td><table> <tr> <td> <details> <summary><strong>apply.go</strong><dd><code>Fix policy merging and ordering issues in partitioned policies</code></dd></summary> <hr> internal/policy/apply.go <li>Ensure <code>rights</code> map is filled with known APIs to honor policies.<br> <li> Modify merging logic for <code>RestrictedTypes</code>, <code>AllowedTypes</code>, and <br><code>FieldAccessRights</code>.<br> <li> Fix ordering issue in policy application by using previously seen <br>rights.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6635/files#diff-59b92e9d31f142f1d99b746eb3ff7db4e26bf6c3044c9b87b58034a947ee04d1">+41/-21</a> </td> </tr> </table></td></tr><tr><td><strong>Tests</strong></td><td><table> <tr> <td> <details> <summary><strong>apply_test.go</strong><dd><code>Add test cases for ACL and rate limit application</code> </dd></summary> <hr> internal/policy/apply_test.go <li>Add test cases for applying ACL from custom policies.<br> <li> Verify correct application of rate limits and access rights.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6635/files#diff-5af7e299a6b0ce11e22f8aa4a01854b1151f4b54dccc68f0cd1cbedee5aed7c8">+47/-0</a> </td> </tr> </table></td></tr></tr></tbody></table> ___ > 💡 **PR-Agent usage**: Comment `/help "your question"` on any pull request to receive relevant information Co-authored-by: Tit Petric <[email protected]> (cherry picked from commit 24058e8)
API Changes --- prev.txt 2024-10-15 11:08:51.066752071 +0000
+++ current.txt 2024-10-15 11:08:48.145748965 +0000
@@ -11710,6 +11710,10 @@
type APISpec = gateway.APISpec
+type BaseMiddleware = gateway.BaseMiddleware
+
+type Gateway = gateway.Gateway
+
# Package: ./tests/quota
# Package: ./tests/regression
@@ -12118,6 +12122,12 @@
Clone returns a fresh copy of s
func (s *SessionState) CustomPolicies() (map[string]Policy, error)
+ CustomPolicies returns a map of custom policies on the session. To preserve
+ policy order, use GetCustomPolicies instead.
+
+func (s *SessionState) GetCustomPolicies() ([]Policy, error)
+ GetCustomPolicies is like CustomPolicies but returns the list, preserving
+ order.
func (s *SessionState) GetQuotaLimitByAPIID(apiID string) (int64, int64, int64, int64)
GetQuotaLimitByAPIID return quota max, quota remaining, quota renewal rate
@@ -12150,6 +12160,7 @@
ApplyPolicies is empty.
func (s *SessionState) SetCustomPolicies(list []Policy)
+ SetCustomPolicies sets custom policies into session metadata.
func (s *SessionState) SetKeyHash(hash string)
|
ca559cd
to
54c6f36
Compare
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
User description
[TT-12897/TT-13284] Add additional partitioned test case, fix ordering issue (#6635)
User description
TT-12897
Subtask: https://tyktech.atlassian.net/browse/TT-13284
Parent: https://tyktech.atlassian.net/browse/TT-12897
PR Type
Bug fix, Tests
Description
applyPartitions
function to ensurerights
map isfilled with known APIs, ensuring policies with ACL rights are honored
even if not first.
RestrictedTypes
,AllowedTypes
, andFieldAccessRights
to handle empty cases and intersections correctly.limits from custom policies, ensuring the order of policies does not
affect the outcome.
Changes walkthrough 📝
apply.go
Fix policy merging and ordering issues in partitioned policies
internal/policy/apply.go
rights
map is filled with known APIs to honor policies.RestrictedTypes
,AllowedTypes
, andFieldAccessRights
.rights.
apply_test.go
Add test cases for ACL and rate limit application
internal/policy/apply_test.go
Co-authored-by: Tit Petric [email protected]
PR Type
Bug fix, Tests
Description
ApplyPolicies
function to ensurerights
map is filled with known APIs, ensuring policies with ACL rights are honored even if not first.RestrictedTypes
,AllowedTypes
, andFieldAccessRights
to handle empty cases and intersections correctly.GetCustomPolicies
to preserve policy order and improve error handling.Changes walkthrough 📝
middleware.go
Fix policy merging and ordering issues in partitioned policies
gateway/middleware.go
rights
map is filled with known APIs to honor policies.RestrictedTypes
,AllowedTypes
, andFieldAccessRights
.rights.
apply_acl_test.go
Add test cases for ACL and rate limit application
tests/policy/apply_acl_test.go
shim.go
Add type aliases for gateway components
tests/policy/shim.go
Gateway
,APISpec
, andBaseMiddleware
.custom_policies.go
Enhance custom policies handling with order preservation
user/custom_policies.go
GetCustomPolicies
to preserve policy order.CustomPolicies
to useGetCustomPolicies
.