Skip to content
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

[TT-12897] Merge path based permissions when combining policies #6597

Merged
merged 2 commits into from
Oct 10, 2024

Conversation

titpetric
Copy link
Contributor

@titpetric titpetric commented Oct 1, 2024

User description

TT-12897
Summary [Security]Path-Based Permissions permissions in policies are not preserved when policies are combined
Type Bug Bug
Status In Dev
Points N/A
Labels customer_bug, jira_escalated

PR uses custom policies to combine several policies with access rights set.

Since a map was in the path, user API for custom policies needed an extension to preserve policy ID order. The existing function returning a map didn't handle json decode errors properly and go semantics when looping over maps don't preserve this order, but it's random so tests would fail. Verified with task stress.

Issue: https://tyktech.atlassian.net/browse/TT-12897


PR Type

Bug fix, Enhancement, Tests


Description

  • Enhanced policy application logic by introducing MergeAllowedURLs to merge allowed URLs efficiently.
  • Refactored Store to use a slice for policies, and introduced StoreMap for unordered policy storage.
  • Improved custom policy handling by adding GetCustomPolicies to preserve policy order.
  • Updated tests to ensure proper application of policies and added new tests for MergeAllowedURLs.
  • Updated Taskfile to include a new stress task for running stress tests.

Changes walkthrough 📝

Relevant files
Enhancement
apply.go
Enhance policy application logic and logging                         

internal/policy/apply.go

  • Introduced MergeAllowedURLs function to merge allowed URLs.
  • Updated Logger function to return a logrus.Entry.
  • Changed session.CustomPolicies() to session.GetCustomPolicies().
  • +9/-17   
    store.go
    Refactor Store to use slice for policies                                 

    internal/policy/store.go

  • Changed Store to use a slice for policies.
  • Updated methods to accommodate slice-based storage.
  • +20/-7   
    store_map.go
    Add StoreMap for unordered policy storage                               

    internal/policy/store_map.go

  • Introduced StoreMap for unordered policy storage.
  • Implemented methods for StoreMap.
  • +46/-0   
    util.go
    Introduce MergeAllowedURLs and remove unused functions     

    internal/policy/util.go

  • Added MergeAllowedURLs function for merging URL access specs.
  • Removed copyAllowedURLs and contains functions.
  • +46/-70 
    custom_policies.go
    Enhance custom policies handling with order preservation 

    user/custom_policies.go

  • Added GetCustomPolicies to preserve policy order.
  • Updated CustomPolicies to use GetCustomPolicies.
  • +21/-7   
    Tests
    apply_test.go
    Update tests for policy application                                           

    internal/policy/apply_test.go

  • Added initialization of policy.Service in tests.
  • Ensured Apply method is tested with assert.NoError.
  • +29/-28 
    util_test.go
    Add tests for MergeAllowedURLs function                                   

    internal/policy/util_test.go

    • Added tests for MergeAllowedURLs function.
    +64/-0   
    Configuration changes
    Taskfile.yml
    Update Taskfile with stress test task                                       

    internal/policy/Taskfile.yml

  • Added stress task for running stress tests.
  • Updated default task to include test.
  • +16/-0   

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    @buger
    Copy link
    Member

    buger commented Oct 1, 2024

    I'm a bot and I 👍 this PR title. 🤖

    @titpetric titpetric changed the title Merge path based permissions when combining policies [TT-12897] Merge path based permissions when combining policies Oct 1, 2024
    Copy link
    Contributor

    github-actions bot commented Oct 1, 2024

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Function Redundancy
    The function appendIfMissing in util.go has been modified to use the slices package for checking containment, which simplifies the function but may not be necessary if the function is only used in one place. Consider if the added dependency is justified or if the function can be further optimized.

    Logic Change
    The change in the method of merging allowed URLs from copyAllowedURLs to MergeAllowedURLs in apply.go could potentially alter the behavior of URL merging logic. This needs thorough testing to ensure that the new merging logic correctly handles all edge cases as expected.

    Copy link
    Contributor

    github-actions bot commented Oct 1, 2024

    API Changes

    --- prev.txt	2024-10-10 13:49:20.936564915 +0000
    +++ current.txt	2024-10-10 13:49:15.005508863 +0000
    @@ -7651,6 +7651,13 @@
     	MsgCertificateExpired                      = "Certificate has expired"
     )
     const (
    +	Pass      = model.Pass
    +	Fail      = model.Fail
    +	Warn      = model.Warn
    +	Datastore = model.Datastore
    +	System    = model.System
    +)
    +const (
     	// Zero value - the service is open and ready to use
     	OPEN = 0
     
    @@ -8790,6 +8797,13 @@
     func (gw *Gateway) SetNodeID(nodeID string)
         SetNodeID writes NodeID safely.
     
    +func (gw *Gateway) SetPolicies(pols map[string]user.Policy)
    +    SetPolicies updates the internal policy map with a new policy map.
    +
    +func (gw *Gateway) SetPoliciesByID(pols ...user.Policy)
    +    SetPoliciesByID will update the internal policiesByID map with new policies.
    +    The key used will be the policy ID.
    +
     func (gw *Gateway) SetupNewRelic() (app newrelic.Application)
         SetupNewRelic creates new newrelic.Application instance
     
    @@ -9031,6 +9045,12 @@
     	RevProxyTransform RevProxyTransform `mapstructure:"rev_proxy_header_cleanup" bson:"rev_proxy_header_cleanup" json:"rev_proxy_header_cleanup"`
     }
     
    +type HealthCheckItem = model.HealthCheckItem
    +
    +type HealthCheckResponse = model.HealthCheckResponse
    +
    +type HealthCheckStatus = model.HealthCheckStatus
    +
     type HealthCheckValues struct {
     	ThrottledRequestsPS float64 `bson:"throttle_reqests_per_second,omitempty" json:"throttle_reqests_per_second"`
     	QuotaViolationsPS   float64 `bson:"quota_violations_per_second,omitempty" json:"quota_violations_per_second"`
    @@ -12389,6 +12409,23 @@
     
     package coprocess // import "github.com/TykTechnologies/tyk/tests/coprocess"
     
    +# Package: ./tests/policy
    +
    +package policy // import "github.com/TykTechnologies/tyk/tests/policy"
    +
    +
    +CONSTANTS
    +
    +const DefaultOrg = "default-org-id"
    +
    +VARIABLES
    +
    +var StartTest = gateway.StartTest
    +
    +TYPES
    +
    +type APISpec = gateway.APISpec
    +
     # Package: ./tests/proxy
     
     package proxy // import "github.com/TykTechnologies/tyk/tests/proxy"
    @@ -12898,6 +12935,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
    @@ -12937,6 +12980,7 @@
         Reset marks the session as not modified, skipping related updates.
     
     func (s *SessionState) SetCustomPolicies(list []Policy)
    +    SetCustomPolicies sets custom policies into session metadata.
     
     func (s *SessionState) SetKeyHash(hash string)
     

    Copy link
    Contributor

    github-actions bot commented Oct 1, 2024

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible bug
    Improve the merging logic in MergeAllowedURLs to handle duplicate URLs more effectively

    Ensure that MergeAllowedURLs correctly handles the merging of methods for URLs that
    appear in both s1 and s2 to prevent any potential data loss or errors in access
    control.

    internal/policy/apply.go [30]

    -merged[url] = appendIfMissing(v, r.Methods...)
    +if existingMethods, exists := merged[url]; exists {
    +  merged[url] = appendIfMissing(existingMethods, r.Methods...)
    +} else {
    +  merged[url] = r.Methods
    +}
    Suggestion importance[1-10]: 7

    Why: This suggestion addresses a potential bug by ensuring that the merging logic correctly handles duplicate URLs, which is important for maintaining accurate access control.

    7
    Best practice
    Ensure consistent usage of store initialization methods to prevent data handling inconsistencies

    Validate that NewStore and NewStoreMap are used consistently throughout the codebase
    to prevent inconsistencies in data handling and storage mechanisms.

    internal/policy/apply.go [117]

    -storage := NewStore(customPolicies)
    +storage := NewStoreMap(customPolicies)  # Ensure consistent usage of either NewStore or NewStoreMap
    Suggestion importance[1-10]: 6

    Why: Ensuring consistent usage of store initialization methods can prevent data handling inconsistencies, which is beneficial for maintainability and correctness.

    6
    Add error handling or logging for duplicate methods in URL access specifications

    Consider handling the case where slices.Contains(dest, v) returns true by logging or
    handling the duplicate method to avoid silent failures or unexpected behaviors.

    internal/policy/util.go [53-58]

     for _, v := range in {
       if slices.Contains(dest, v) {
    +    // Handle or log duplicate method
         continue
       }
       dest = append(dest, v)
     }
    Suggestion importance[1-10]: 5

    Why: The suggestion to handle or log duplicate methods in URL access specifications can improve code robustness by preventing silent failures, although it is not critical for functionality.

    5

    @titpetric titpetric enabled auto-merge (squash) October 10, 2024 07:58
    @titpetric titpetric merged commit e31a08f into master Oct 10, 2024
    25 of 39 checks passed
    @titpetric titpetric deleted the update/merge-allowed-urls branch October 10, 2024 14:11
    Copy link

    sonarcloud bot commented Oct 10, 2024

    @titpetric
    Copy link
    Contributor Author

    /release to release-5.3

    Copy link

    tykbot bot commented Oct 10, 2024

    Working on it! Note that it can take a few minutes.

    tykbot bot pushed a commit that referenced this pull request Oct 10, 2024
    <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></td>
        </tr>
      </table>
    </details>
    <!--
      do not remove this marker as it will break jira-lint's functionality.
      added_by_jira_lint
    -->
    
    ---
    
    PR uses custom policies to combine several policies with access rights
    set.
    
    Since a `map` was in the path, user API for custom policies needed an
    extension to preserve policy ID order. The existing function returning a
    map didn't handle json decode errors properly and go semantics when
    looping over maps don't preserve this order, but it's random so tests
    would fail. Verified with `task stress`.
    
    Issue: https://tyktech.atlassian.net/browse/TT-12897
    
    ___
    
    Bug fix, Enhancement, Tests
    
    ___
    
    - Enhanced policy application logic by introducing `MergeAllowedURLs` to
    merge allowed URLs efficiently.
    - Refactored `Store` to use a slice for policies, and introduced
    `StoreMap` for unordered policy storage.
    - Improved custom policy handling by adding `GetCustomPolicies` to
    preserve policy order.
    - Updated tests to ensure proper application of policies and added new
    tests for `MergeAllowedURLs`.
    - Updated Taskfile to include a new `stress` task for running stress
    tests.
    
    ___
    
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>apply.go</strong><dd><code>Enhance policy application
    logic and logging</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    internal/policy/apply.go
    
    <li>Introduced <code>MergeAllowedURLs</code> function to merge allowed
    URLs.<br> <li> Updated <code>Logger</code> function to return a
    <code>logrus.Entry</code>.<br> <li> Changed
    <code>session.CustomPolicies()</code> to
    <code>session.GetCustomPolicies()</code>.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6597/files#diff-59b92e9d31f142f1d99b746eb3ff7db4e26bf6c3044c9b87b58034a947ee04d1">+9/-17</a>&nbsp;
    &nbsp; </td>
    
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>store.go</strong><dd><code>Refactor Store to use slice
    for policies</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    internal/policy/store.go
    
    <li>Changed <code>Store</code> to use a slice for policies.<br> <li>
    Updated methods to accommodate slice-based storage.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6597/files#diff-13dec7bc453c9ff99550c83d2f86a017bbf7fb863584dc30603af15d29ef9d3d">+20/-7</a>&nbsp;
    &nbsp; </td>
    
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>store_map.go</strong><dd><code>Add StoreMap for
    unordered policy storage</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    internal/policy/store_map.go
    
    <li>Introduced <code>StoreMap</code> for unordered policy storage.<br>
    <li> Implemented methods for <code>StoreMap</code>.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6597/files#diff-24a7a95a1cf4f14b59a3475127dc45541357638d6949323255faeeb2ed657d27">+46/-0</a>&nbsp;
    &nbsp; </td>
    
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>util.go</strong><dd><code>Introduce MergeAllowedURLs
    and remove unused functions</code>&nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    internal/policy/util.go
    
    <li>Added <code>MergeAllowedURLs</code> function for merging URL access
    specs.<br> <li> Removed <code>copyAllowedURLs</code> and
    <code>contains</code> functions.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6597/files#diff-0323c3da13f08a9ccd340ac04208d680856354fd566dffcad925fa6645639955">+46/-70</a>&nbsp;
    </td>
    
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>custom_policies.go</strong><dd><code>Enhance custom
    policies handling with order preservation</code>&nbsp; </dd></summary>
    <hr>
    
    user/custom_policies.go
    
    <li>Added <code>GetCustomPolicies</code> to preserve policy order.<br>
    <li> Updated <code>CustomPolicies</code> to use
    <code>GetCustomPolicies</code>.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6597/files#diff-911674993eef6c43a04edc0e90ea1f2e6d595792eef840d23b2e3deb1c8265c5">+21/-7</a>&nbsp;
    &nbsp; </td>
    
    </tr>
    </table></td></tr><tr><td><strong>Tests</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>apply_test.go</strong><dd><code>Update tests for policy
    application</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    internal/policy/apply_test.go
    
    <li>Added initialization of <code>policy.Service</code> in tests.<br>
    <li> Ensured <code>Apply</code> method is tested with
    <code>assert.NoError</code>.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6597/files#diff-5af7e299a6b0ce11e22f8aa4a01854b1151f4b54dccc68f0cd1cbedee5aed7c8">+29/-28</a>&nbsp;
    </td>
    
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>util_test.go</strong><dd><code>Add tests for
    MergeAllowedURLs function</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    internal/policy/util_test.go
    
    - Added tests for `MergeAllowedURLs` function.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6597/files#diff-c750a1b8a01d19dacf02ba7512b8e2b987bf8147cf3345a4374504d9d5b3840e">+64/-0</a>&nbsp;
    &nbsp; </td>
    
    </tr>
    </table></td></tr><tr><td><strong>Configuration
    changes</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>Taskfile.yml</strong><dd><code>Update Taskfile with
    stress test task</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    internal/policy/Taskfile.yml
    
    <li>Added <code>stress</code> task for running stress tests.<br> <li>
    Updated <code>default</code> task to include <code>test</code>.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6597/files#diff-e0f19d4dd27acb397e19ccb080f3142a09f5978699da5843bfc71e7ffa4bb775">+16/-0</a>&nbsp;
    &nbsp; </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 <tit@tyk.io>
    
    (cherry picked from commit e31a08f)
    Copy link

    tykbot bot commented Oct 10, 2024

    @titpetric Succesfully merged PR

    titpetric added a commit that referenced this pull request Oct 10, 2024
    <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></td>
        </tr>
      </table>
    </details>
    <!--
      do not remove this marker as it will break jira-lint's functionality.
      added_by_jira_lint
    -->
    
    ---
    
    PR uses custom policies to combine several policies with access rights
    set.
    
    Since a `map` was in the path, user API for custom policies needed an
    extension to preserve policy ID order. The existing function returning a
    map didn't handle json decode errors properly and go semantics when
    looping over maps don't preserve this order, but it's random so tests
    would fail. Verified with `task stress`.
    
    Issue: https://tyktech.atlassian.net/browse/TT-12897
    
    ___
    
    Bug fix, Enhancement, Tests
    
    ___
    
    - Enhanced policy application logic by introducing `MergeAllowedURLs` to
    merge allowed URLs efficiently.
    - Refactored `Store` to use a slice for policies, and introduced
    `StoreMap` for unordered policy storage.
    - Improved custom policy handling by adding `GetCustomPolicies` to
    preserve policy order.
    - Updated tests to ensure proper application of policies and added new
    tests for `MergeAllowedURLs`.
    - Updated Taskfile to include a new `stress` task for running stress
    tests.
    
    ___
    
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>apply.go</strong><dd><code>Enhance policy application
    logic and logging</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    internal/policy/apply.go
    
    <li>Introduced <code>MergeAllowedURLs</code> function to merge allowed
    URLs.<br> <li> Updated <code>Logger</code> function to return a
    <code>logrus.Entry</code>.<br> <li> Changed
    <code>session.CustomPolicies()</code> to
    <code>session.GetCustomPolicies()</code>.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6597/files#diff-59b92e9d31f142f1d99b746eb3ff7db4e26bf6c3044c9b87b58034a947ee04d1">+9/-17</a>&nbsp;
    &nbsp; </td>
    
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>store.go</strong><dd><code>Refactor Store to use slice
    for policies</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    internal/policy/store.go
    
    <li>Changed <code>Store</code> to use a slice for policies.<br> <li>
    Updated methods to accommodate slice-based storage.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6597/files#diff-13dec7bc453c9ff99550c83d2f86a017bbf7fb863584dc30603af15d29ef9d3d">+20/-7</a>&nbsp;
    &nbsp; </td>
    
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>store_map.go</strong><dd><code>Add StoreMap for
    unordered policy storage</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    internal/policy/store_map.go
    
    <li>Introduced <code>StoreMap</code> for unordered policy storage.<br>
    <li> Implemented methods for <code>StoreMap</code>.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6597/files#diff-24a7a95a1cf4f14b59a3475127dc45541357638d6949323255faeeb2ed657d27">+46/-0</a>&nbsp;
    &nbsp; </td>
    
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>util.go</strong><dd><code>Introduce MergeAllowedURLs
    and remove unused functions</code>&nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    internal/policy/util.go
    
    <li>Added <code>MergeAllowedURLs</code> function for merging URL access
    specs.<br> <li> Removed <code>copyAllowedURLs</code> and
    <code>contains</code> functions.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6597/files#diff-0323c3da13f08a9ccd340ac04208d680856354fd566dffcad925fa6645639955">+46/-70</a>&nbsp;
    </td>
    
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>custom_policies.go</strong><dd><code>Enhance custom
    policies handling with order preservation</code>&nbsp; </dd></summary>
    <hr>
    
    user/custom_policies.go
    
    <li>Added <code>GetCustomPolicies</code> to preserve policy order.<br>
    <li> Updated <code>CustomPolicies</code> to use
    <code>GetCustomPolicies</code>.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6597/files#diff-911674993eef6c43a04edc0e90ea1f2e6d595792eef840d23b2e3deb1c8265c5">+21/-7</a>&nbsp;
    &nbsp; </td>
    
    </tr>
    </table></td></tr><tr><td><strong>Tests</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>apply_test.go</strong><dd><code>Update tests for policy
    application</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    internal/policy/apply_test.go
    
    <li>Added initialization of <code>policy.Service</code> in tests.<br>
    <li> Ensured <code>Apply</code> method is tested with
    <code>assert.NoError</code>.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6597/files#diff-5af7e299a6b0ce11e22f8aa4a01854b1151f4b54dccc68f0cd1cbedee5aed7c8">+29/-28</a>&nbsp;
    </td>
    
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>util_test.go</strong><dd><code>Add tests for
    MergeAllowedURLs function</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    internal/policy/util_test.go
    
    - Added tests for `MergeAllowedURLs` function.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6597/files#diff-c750a1b8a01d19dacf02ba7512b8e2b987bf8147cf3345a4374504d9d5b3840e">+64/-0</a>&nbsp;
    &nbsp; </td>
    
    </tr>
    </table></td></tr><tr><td><strong>Configuration
    changes</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>Taskfile.yml</strong><dd><code>Update Taskfile with
    stress test task</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    internal/policy/Taskfile.yml
    
    <li>Added <code>stress</code> task for running stress tests.<br> <li>
    Updated <code>default</code> task to include <code>test</code>.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6597/files#diff-e0f19d4dd27acb397e19ccb080f3142a09f5978699da5843bfc71e7ffa4bb775">+16/-0</a>&nbsp;
    &nbsp; </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 <tit@tyk.io>
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    3 participants