Closed jeffy-mathew closed 1 month ago
API Changes
no api changes detected
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪ |
🧪 PR contains tests |
🔒 No security concerns identified |
⚡ Key issues to review Logic Check Ensure that setting `Endpoints` to nil under certain conditions does not unintentionally affect other parts of the system that might expect this property to be present. |
Category | Suggestion | Score |
Possible bug |
Add a check to ensure the key exists in the map before accessing it___ **Consider checking for the presence of the key"d" in s.AccessRights before accessing it to avoid potential panics due to missing keys.** [gateway/policy_test.go [904-905]](https://github.com/TykTechnologies/tyk/pull/6491/files#diff-40d701767204255c38c7dd64939d6bb8df621640c4bddfe5f56080380476a18aR904-R905) ```diff assert.NotEmpty(t, s.AccessRights) -assert.Empty(t, s.AccessRights["d"].Endpoints) +if _, ok := s.AccessRights["d"]; ok { + assert.Empty(t, s.AccessRights["d"].Endpoints) +} ``` Suggestion importance[1-10]: 9Why: This suggestion addresses a potential bug by adding a check for the presence of the key "d" in the map before accessing it, which prevents possible panics due to missing keys. | 9 |
Add a nil check before setting
___
**Ensure that | 8 | |
Enhancement |
Use unique IDs for each policy configuration___ **Ensure unique IDs for different policy configurations to avoid conflicts orunintended behavior due to ID collisions.** [gateway/testdata/policies.json [731]](https://github.com/TykTechnologies/tyk/pull/6491/files#diff-d20906fb23674ef58fee794635f5c1f668eb36f9dc4ce0f4b7d3dbd816e13eb5R731-R731) ```diff -"id": "endpoint_rate_limits_on_rate_limit_partition_disabled", +"id": "unique_policy_id_for_each_configuration", ``` Suggestion importance[1-10]: 7Why: Ensuring unique IDs for different policy configurations is important to prevent conflicts or unintended behavior due to ID collisions, enhancing the robustness of the system. | 7 |
Best practice |
Use non-negative values for
___
**Consider using positive values for | 6 |
Failed conditions
0.0% Coverage on New Code (required ≥ 80%)
User description
ignore endpoint rate limit configurations when rate limit partition is disabled
Description
This PR makes apply policies ignore endpoint rate limits when rate limit partition is disabled
Related Issue
JIRA link : https://tyktech.atlassian.net/browse/TT-12964
Motivation and Context
How This Has Been Tested
Screenshots (if appropriate)
Types of changes
Checklist
PR Type
enhancement, tests
Description
Apply
function to ignore endpoint rate limits when the rate limit partition is disabled, ensuring that endpoints are set to nil in such cases.policy_test.go
to verify the behavior of endpoint rate limits when partitions are disabled or combined.policies.json
with new policy configurations to support the new test cases, including specific endpoint paths and methods.Changes walkthrough 📝
policy_test.go
Add test cases for endpoint rate limits with partitioning
gateway/policy_test.go
partition is disabled.
policies.json
Add policy configurations for endpoint rate limit tests
gateway/testdata/policies.json
ACL and quota partitions.
apply.go
Ignore endpoint rate limits when partition is disabled
internal/policy/apply.go
Apply
function to ignore endpoint rate limits when ratelimit partition is disabled.
Endpoints
to nil if rate limit is not applied.