Arshil-Khan opened a new pull request, #1761:
URL: https://github.com/apache/casbin/pull/1761

   What's the problem?
   SetEquals and SetEqualsInt in util/util.go call sort.Strings / sort.Ints 
directly on their arguments. Go's sort functions operate in-place, which means 
every time a caller compares two sets the original slices get silently 
reordered as a side effect.
   
   This breaks any code that:
   
   keeps a reference to the slices after the call, or
   calls the function more than once and expects the original order to be 
stable.
   
   package main
   <img width="389" height="378" alt="Screenshot 2026-09-09 at 11 05 43 PM" 
src="https://github.com/user-attachments/assets/487276a9-b12c-4758-9851-2a972959e198";
 />
   
   Steps:
   
   Clone the repo and run the snippet above (or the new test TestSetEquals with 
the mutation assertions).
   Observe that roles is [admin editor viewer] after the call, not the original 
[editor admin viewer].
   
   <img width="353" height="287" alt="Screenshot 2026-09-09 at 11 06 04 PM" 
src="https://github.com/user-attachments/assets/c16417e5-c7ee-4cef-a8c4-9f56c5f6795f";
 />
   
   The same change is applied to SetEqualsInt.
   
   Tests
   Extended TestSetEquals with assertions that verify the original slices are 
not reordered after the call.
   Added TestSetEqualsInt (the function had no dedicated test before) with both 
a correctness check and the same mutation guard.
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to