Skip to content

fix: fix bug in add policy for priority effectors#313

Merged
hsluoyz merged 1 commit into
apache:masterfrom
aditya-nambiar:aditya/fix
Aug 10, 2023
Merged

fix: fix bug in add policy for priority effectors#313
hsluoyz merged 1 commit into
apache:masterfrom
aditya-nambiar:aditya/fix

Conversation

@aditya-nambiar
Copy link
Copy Markdown
Contributor

@aditya-nambiar aditya-nambiar commented Aug 10, 2023

Fix: #310

Description:

Fixes a bug in assigning an index to a new policy was added when using the priority effector.

The bug is that when we loop from range(i, 0, -1), i stops at 1 ( since range is exclusive for the end parameter ), and hence we cant assign a policy to index 0 in this logic ( in case the newly added policy indeed has the lowest priority )

I swapped it for a simpler logic that bubbles up the inserted policy to the correct index.

Related Issue:
#310

Tests:

Ran - python3 -m unittest discover

..['alice']
..............Request: bob, data1, read ---> False
Request: bob, data1, write ---> False
Request: bob, data2, read ---> False
.............................................
----------------------------------------------------------------------
Ran 462 tests in 0.807s

OK

@casbin-bot
Copy link
Copy Markdown

@Nekotoxin please review

@casbin-bot casbin-bot requested a review from Nekotoxin August 10, 2023 03:14
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Aug 10, 2023

CLA assistant check
All committers have signed the CLA.

@aditya-nambiar aditya-nambiar changed the title priority effector: Fix bug in add policy for priority effectors fix: Fix bug in add policy for priority effectors Aug 10, 2023
@aditya-nambiar aditya-nambiar changed the title fix: Fix bug in add policy for priority effectors fix: fix bug in add policy for priority effectors Aug 10, 2023
@hsluoyz
Copy link
Copy Markdown
Member

hsluoyz commented Aug 10, 2023

@BustDot plz review

@hsluoyz hsluoyz merged commit 8d30537 into apache:master Aug 10, 2023
github-actions Bot pushed a commit that referenced this pull request Aug 10, 2023
## [1.23.1](v1.23.0...v1.23.1) (2023-08-10)

### Bug Fixes

* fix bug in add policy for priority effectors ([#313](#313)) ([8d30537](8d30537))
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 1.23.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Chimou0 pushed a commit to Chimou0/pycasbin that referenced this pull request Jul 17, 2025
Chimou0 pushed a commit to Chimou0/pycasbin that referenced this pull request Jul 17, 2025
## [1.23.1](apache/casbin-pycasbin@v1.23.0...v1.23.1) (2023-08-10)

### Bug Fixes

* fix bug in add policy for priority effectors ([apache#313](apache#313)) ([8d30537](apache@8d30537))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug in priority effectors

4 participants