Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TT-1944/TT-12550/TT-12865] Backport critical fixes (#6513)
### **User description** <!-- Provide a general summary of your changes in the Title above --> ## Description Backport critical fixes from PRs in order #6480 #6437 #6475 #6506 ## Related Issue https://tyktech.atlassian.net/browse/TT-1944 https://tyktech.atlassian.net/browse/TT-12550 https://tyktech.atlassian.net/browse/TT-12865 ## Motivation and Context <!-- Why is this change required? What problem does it solve? --> ## How This Has Been Tested <!-- Please describe in detail how you tested your changes --> <!-- Include details of your testing environment, and the tests --> <!-- you ran to see how your change affects other areas of the code, etc. --> <!-- This information is helpful for reviewers and QA. --> ## Screenshots (if appropriate) ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply --> <!-- If there are no documentation updates required, mark the item as checked. --> <!-- Raise up any additional concerns not covered by the checklist. --> - [ ] I ensured that the documentation is up to date - [ ] I explained why this PR updates go.mod in detail with reasoning why it's required - [ ] I would like a code coverage CI quality gate exception and have explained why ___ ### **PR Type** Enhancement, Bug fix, Tests ___ ### **Description** - Introduced new configuration options for path prefix and suffix matching to enhance URL matching capabilities. - Refactored URLSpec to improve regex generation and logging for URL matching. - Enhanced GranularAccessMiddleware with improved URL matching logic and error handling. - Added utility functions for handling path regex preparation and matching, with caching for performance. - Updated and added test cases to verify new URL matching logic and configurations. - Added regression tests for issue 12865 to ensure stability and correctness of new features. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>4 files</summary><table> <tr> <td> <details> <summary><strong>config.go</strong><dd><code>Introduce path prefix and suffix matching configuration</code> </dd></summary> <hr> config/config.go <li>Added new configuration options for path prefix and suffix matching.<br> <li> Enhanced documentation for new URL matching behavior.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6513/files#diff-fe44f09c4d5977b5f5eaea29170b6a0748819c9d02271746a20d81a5f3efca17">+43/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>api_definition.go</strong><dd><code>Refactor and enhance URLSpec for better URL matching</code> </dd></summary> <hr> gateway/api_definition.go <li>Refactored URLSpec to use private fields.<br> <li> Enhanced regex generation for URL matching.<br> <li> Improved logging for URL matching process.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6513/files#diff-0cf80174bbafb36f6d4f4308ebbd971b2833b76a936bad568220aa1a4ba0ee8b">+52/-36</a> </td> </tr> <tr> <td> <details> <summary><strong>mw_granular_access.go</strong><dd><code>Enhance URL matching and error handling in GranularAccessMiddleware</code></dd></summary> <hr> gateway/mw_granular_access.go <li>Enhanced URL matching in GranularAccessMiddleware.<br> <li> Improved error handling and logging.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6513/files#diff-618f7d55751d572562a29506a13beba2da969436e974f8b51df7d9708c925436">+79/-12</a> </td> </tr> <tr> <td> <details> <summary><strong>mux.go</strong><dd><code>Add utility functions for path regex handling</code> </dd></summary> <hr> internal/httputil/mux.go <li>Introduced utility functions for path regex preparation and matching.<br> <li> Implemented caching for path regex patterns.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6513/files#diff-3d9ee5f5e946d72e6f2ae662ff03ee5253bbdc15203d2e4f6e9f46c13011ebf8">+139/-0</a> </td> </tr> </table></details></td></tr><tr><td><strong>Tests</strong></td><td><details><summary>4 files</summary><table> <tr> <td> <details> <summary><strong>api_definition_test.go</strong><dd><code>Update and add test cases for enhanced URL matching</code> </dd></summary> <hr> gateway/api_definition_test.go <li>Updated test cases to reflect changes in URL matching logic.<br> <li> Added new test scenarios for prefix and suffix matching.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6513/files#diff-2394daab6fdc5f8dc234699c80c0548947ee3d68d2e33858258d73a8b5eb6f44">+15/-33</a> </td> </tr> <tr> <td> <details> <summary><strong>mw_granular_access_test.go</strong><dd><code>Add tests for enhanced URL matching in GranularAccessMiddleware</code></dd></summary> <hr> gateway/mw_granular_access_test.go <li>Added tests for new URL matching logic in GranularAccessMiddleware.<br> <li> Verified behavior with different path configurations.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6513/files#diff-8e0d7cfef26688edd7d08334d955039dab5deb3caf860d29eff6d09894eaba20">+50/-24</a> </td> </tr> <tr> <td> <details> <summary><strong>mux_test.go</strong><dd><code>Add tests for path regex utility functions</code> </dd></summary> <hr> internal/httputil/mux_test.go <li>Added tests for new path regex utility functions.<br> <li> Verified regex preparation and matching logic.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6513/files#diff-8f7ce1891e221d7adb9e68f2e951f33edfbde2128187abb6e837ac01952d7888">+162/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>issue_12865_test.go</strong><dd><code>Add regression tests for issue 12865</code> </dd></summary> <hr> tests/regression/issue_12865_test.go <li>Added regression tests for issue 12865.<br> <li> Tested various path matching configurations.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6513/files#diff-1a4f9c47cb4152844d641098b6e7ca8e5e8739eefdec7178f9437750d11db6ec">+171/-0</a> </td> </tr> </table></details></td></tr><tr><td><strong>Configuration changes</strong></td><td><details><summary>1 files</summary><table> <tr> <td> <details> <summary><strong>schema.json</strong><dd><code>Update schema for new path matching options</code> </dd></summary> <hr> cli/linter/schema.json - Updated schema to include new path matching configuration options. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6513/files#diff-103cec746d3e61d391c5a67c171963f66fea65d651d704d5540e60aa5d574f46">+6/-0</a> </td> </tr> </table></details></td></tr></tr></tbody></table> ___ > 💡 **PR-Agent usage**: >Comment `/help` on the PR to get a list of all available PR-Agent tools and their descriptions --------- Co-authored-by: Tit Petric <tit.petric@monotek.net> Co-authored-by: Tit Petric <tit@tyk.io>
- Loading branch information