-
-
Notifications
You must be signed in to change notification settings - Fork 228
feat: fix escapeAssertion to preserve string literals #514
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
Conversation
|
|
Co-authored-by: nomeguy <[email protected]>
Co-authored-by: nomeguy <[email protected]>
Co-authored-by: nomeguy <[email protected]>
|
Co-authored-by: nomeguy <[email protected]>
Done in commit c67e086:
The Go implementation naturally handles string literals correctly because quotes are not in the regex character class, so patterns like |
# [5.42.0](v5.41.0...v5.42.0) (2025-12-08) ### Features * configure CI workflow to trigger on master branch ([#521](#521)) ([02ec045](02ec045)) * fix duplicate CI runs on pull requests ([#513](#513)) ([67ab8ee](67ab8ee)) * fix escapeAssertion to preserve string literals ([#514](#514)) ([7801732](7801732)) * Support multiple policy definitions (p, p2) ([#518](#518)) ([1b1f1bb](1b1f1bb))
escapeAssertionwas blindly replacingr.andp.patterns everywhere, including inside string literals. This broke policy rules containing strings like"r.my_resource", which became"r_my_resource".Changes
src/util/util.tsescapeAssertionimplementation with Go Casbin's exact implementation/([()\s|&,=!><+\-*/]|^)((r|p)[0-9]*)\./gwhich naturally avoids string literals"and') are not in the character class, so patterns inside strings are never matchedr.obj.owner.id→r_obj.owner.idTests
util_test.goFixes #473
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.