Skip to content

Commit

Permalink
feat: add nil checks on RoleManager (#1371)
Browse files Browse the repository at this point in the history
  • Loading branch information
MuZhou233 committed Mar 9, 2024
1 parent 5acc404 commit 46136ed
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 11 deletions.
18 changes: 16 additions & 2 deletions enforcer.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ func (e *Enforcer) SetLogger(logger log.Logger) {
for k := range e.rmMap {
e.rmMap[k].SetLogger(e.logger)
}
for k := range e.condRmMap {
e.condRmMap[k].SetLogger(e.logger)
}
}

func (e *Enforcer) initialize() {
Expand Down Expand Up @@ -273,12 +276,20 @@ func (e *Enforcer) SetWatcher(watcher persist.Watcher) error {

// GetRoleManager gets the current role manager.
func (e *Enforcer) GetRoleManager() rbac.RoleManager {
return e.rmMap["g"]
if e.rmMap != nil && e.rmMap["g"] != nil {
return e.rmMap["g"]
} else {
return nil
}
}

// GetNamedRoleManager gets the role manager for the named policy.
func (e *Enforcer) GetNamedRoleManager(ptype string) rbac.RoleManager {
return e.rmMap[ptype]
if e.rmMap != nil && e.rmMap[ptype] != nil {
return e.rmMap[ptype]
} else {
return nil
}
}

// SetRoleManager sets the current role manager.
Expand Down Expand Up @@ -535,6 +546,9 @@ func (e *Enforcer) EnableAcceptJsonRequest(acceptJsonRequest bool) {

// BuildRoleLinks manually rebuild the role inheritance relations.
func (e *Enforcer) BuildRoleLinks() error {
if e.rmMap == nil {
return errors.New("rmMap is nil")
}
for _, rm := range e.rmMap {
err := rm.Clear()
if err != nil {
Expand Down
11 changes: 9 additions & 2 deletions management_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,15 @@ func (e *Enforcer) GetFilteredNamedPolicyWithMatcher(ptype string, matcher strin
functions := e.fm.GetFunctions()
if _, ok := e.model["g"]; ok {
for key, ast := range e.model["g"] {
rm := ast.RM
functions[key] = util.GenerateGFunction(rm)
// g must be a normal role definition (ast.RM != nil)
// or a conditional role definition (ast.CondRM != nil)
// ast.RM and ast.CondRM shouldn't be nil at the same time
if ast.RM != nil {
functions[key] = util.GenerateGFunction(ast.RM)
}
if ast.CondRM != nil {
functions[key] = util.GenerateConditionalGFunction(ast.CondRM)
}
}
}

Expand Down
22 changes: 20 additions & 2 deletions rbac_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package casbin

import (
"fmt"
"strings"

"github.com/casbin/casbin/v2/constant"
Expand All @@ -24,13 +25,21 @@ import (

// GetRolesForUser gets the roles that a user has.
func (e *Enforcer) GetRolesForUser(name string, domain ...string) ([]string, error) {
res, err := e.model["g"]["g"].RM.GetRoles(name, domain...)
rm := e.GetRoleManager()
if rm == nil {
return nil, fmt.Errorf("role manager is not initialized")
}
res, err := rm.GetRoles(name, domain...)
return res, err
}

// GetUsersForRole gets the users that has a role.
func (e *Enforcer) GetUsersForRole(name string, domain ...string) ([]string, error) {
res, err := e.model["g"]["g"].RM.GetUsers(name, domain...)
rm := e.GetRoleManager()
if rm == nil {
return nil, fmt.Errorf("role manager is not initialized")
}
res, err := rm.GetUsers(name, domain...)
return res, err
}

Expand Down Expand Up @@ -298,6 +307,9 @@ func (e *Enforcer) GetImplicitPermissionsForUser(user string, domain ...string)
func (e *Enforcer) GetNamedImplicitPermissionsForUser(ptype string, user string, domain ...string) ([][]string, error) {
permission := make([][]string, 0)
rm := e.GetRoleManager()
if rm == nil {
return nil, fmt.Errorf("role manager is not initialized")
}
domainIndex, _ := e.GetFieldIndex(ptype, constant.DomainIndex)
for _, rule := range e.model["p"][ptype].Policy {
if len(domain) == 0 {
Expand Down Expand Up @@ -483,6 +495,9 @@ func (e *Enforcer) GetImplicitUsersForResource(resource string) ([][]string, err
subjectIndex, _ := e.GetFieldIndex("p", "sub")
objectIndex, _ := e.GetFieldIndex("p", "obj")
rm := e.GetRoleManager()
if rm == nil {
return nil, fmt.Errorf("role manager is not initialized")
}

isRole := make(map[string]bool)
for _, role := range e.GetAllRoles() {
Expand Down Expand Up @@ -525,6 +540,9 @@ func (e *Enforcer) GetImplicitUsersForResourceByDomain(resource string, domain s
objectIndex, _ := e.GetFieldIndex("p", "obj")
domIndex, _ := e.GetFieldIndex("p", "dom")
rm := e.GetRoleManager()
if rm == nil {
return nil, fmt.Errorf("role manager is not initialized")
}

isRole := make(map[string]bool)

Expand Down
25 changes: 20 additions & 5 deletions rbac_api_with_domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,26 @@

package casbin

import "github.com/casbin/casbin/v2/constant"
import (
"fmt"
"github.com/casbin/casbin/v2/constant"
)

// GetUsersForRoleInDomain gets the users that has a role inside a domain. Add by Gordon
func (e *Enforcer) GetUsersForRoleInDomain(name string, domain string) []string {
res, _ := e.model["g"]["g"].RM.GetUsers(name, domain)
if e.GetRoleManager() == nil {
return nil
}
res, _ := e.GetRoleManager().GetUsers(name, domain)
return res
}

// GetRolesForUserInDomain gets the roles that a user has inside a domain.
func (e *Enforcer) GetRolesForUserInDomain(name string, domain string) []string {
res, _ := e.model["g"]["g"].RM.GetRoles(name, domain)
if e.GetRoleManager() == nil {
return nil
}
res, _ := e.GetRoleManager().GetRoles(name, domain)
return res
}

Expand All @@ -49,7 +58,10 @@ func (e *Enforcer) DeleteRoleForUserInDomain(user string, role string, domain st
// DeleteRolesForUserInDomain deletes all roles for a user inside a domain.
// Returns false if the user does not have any roles (aka not affected).
func (e *Enforcer) DeleteRolesForUserInDomain(user string, domain string) (bool, error) {
roles, err := e.model["g"]["g"].RM.GetRoles(user, domain)
if e.GetRoleManager() == nil {
return false, fmt.Errorf("role manager is not initialized")
}
roles, err := e.GetRoleManager().GetRoles(user, domain)
if err != nil {
return false, err
}
Expand Down Expand Up @@ -142,7 +154,10 @@ func (e *Enforcer) DeleteDomains(domains ...string) (bool, error) {

// GetAllDomains would get all domains.
func (e *Enforcer) GetAllDomains() ([]string, error) {
return e.model["g"]["g"].RM.GetAllDomains()
if e.GetRoleManager() == nil {
return nil, fmt.Errorf("role manager is not initialized")
}
return e.GetRoleManager().GetAllDomains()
}

// GetAllRolesByDomain would get all roles associated with the domain.
Expand Down

2 comments on commit 46136ed

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 46136ed Previous: 5acc404 Ratio
BenchmarkCachedRaw 17.56 ns/op 0 B/op 0 allocs/op 17.63 ns/op 0 B/op 0 allocs/op 1.00
BenchmarkCachedRaw - ns/op 17.56 ns/op 17.63 ns/op 1.00
BenchmarkCachedRaw - B/op 0 B/op 0 B/op 1
BenchmarkCachedRaw - allocs/op 0 allocs/op 0 allocs/op 1
BenchmarkCachedBasicModel 169.1 ns/op 104 B/op 4 allocs/op 167 ns/op 104 B/op 4 allocs/op 1.01
BenchmarkCachedBasicModel - ns/op 169.1 ns/op 167 ns/op 1.01
BenchmarkCachedBasicModel - B/op 104 B/op 104 B/op 1
BenchmarkCachedBasicModel - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedRBACModel 170.4 ns/op 104 B/op 4 allocs/op 164.8 ns/op 104 B/op 4 allocs/op 1.03
BenchmarkCachedRBACModel - ns/op 170.4 ns/op 164.8 ns/op 1.03
BenchmarkCachedRBACModel - B/op 104 B/op 104 B/op 1
BenchmarkCachedRBACModel - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedRBACModelSmall 187 ns/op 104 B/op 4 allocs/op 174.1 ns/op 104 B/op 4 allocs/op 1.07
BenchmarkCachedRBACModelSmall - ns/op 187 ns/op 174.1 ns/op 1.07
BenchmarkCachedRBACModelSmall - B/op 104 B/op 104 B/op 1
BenchmarkCachedRBACModelSmall - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedRBACModelMedium 195.8 ns/op 104 B/op 4 allocs/op 176.3 ns/op 104 B/op 4 allocs/op 1.11
BenchmarkCachedRBACModelMedium - ns/op 195.8 ns/op 176.3 ns/op 1.11
BenchmarkCachedRBACModelMedium - B/op 104 B/op 104 B/op 1
BenchmarkCachedRBACModelMedium - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedRBACModelLarge 163.6 ns/op 96 B/op 3 allocs/op 164.5 ns/op 96 B/op 3 allocs/op 0.99
BenchmarkCachedRBACModelLarge - ns/op 163.6 ns/op 164.5 ns/op 0.99
BenchmarkCachedRBACModelLarge - B/op 96 B/op 96 B/op 1
BenchmarkCachedRBACModelLarge - allocs/op 3 allocs/op 3 allocs/op 1
BenchmarkCachedRBACModelWithResourceRoles 173.8 ns/op 104 B/op 4 allocs/op 166.4 ns/op 104 B/op 4 allocs/op 1.04
BenchmarkCachedRBACModelWithResourceRoles - ns/op 173.8 ns/op 166.4 ns/op 1.04
BenchmarkCachedRBACModelWithResourceRoles - B/op 104 B/op 104 B/op 1
BenchmarkCachedRBACModelWithResourceRoles - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedRBACModelWithDomains 183.6 ns/op 120 B/op 4 allocs/op 173.6 ns/op 120 B/op 4 allocs/op 1.06
BenchmarkCachedRBACModelWithDomains - ns/op 183.6 ns/op 173.6 ns/op 1.06
BenchmarkCachedRBACModelWithDomains - B/op 120 B/op 120 B/op 1
BenchmarkCachedRBACModelWithDomains - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedABACModel 2741 ns/op 1542 B/op 18 allocs/op 2871 ns/op 1538 B/op 18 allocs/op 0.95
BenchmarkCachedABACModel - ns/op 2741 ns/op 2871 ns/op 0.95
BenchmarkCachedABACModel - B/op 1542 B/op 1538 B/op 1.00
BenchmarkCachedABACModel - allocs/op 18 allocs/op 18 allocs/op 1
BenchmarkCachedKeyMatchModel 186.9 ns/op 152 B/op 4 allocs/op 180.4 ns/op 152 B/op 4 allocs/op 1.04
BenchmarkCachedKeyMatchModel - ns/op 186.9 ns/op 180.4 ns/op 1.04
BenchmarkCachedKeyMatchModel - B/op 152 B/op 152 B/op 1
BenchmarkCachedKeyMatchModel - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedRBACModelWithDeny 170.6 ns/op 104 B/op 4 allocs/op 164.6 ns/op 104 B/op 4 allocs/op 1.04
BenchmarkCachedRBACModelWithDeny - ns/op 170.6 ns/op 164.6 ns/op 1.04
BenchmarkCachedRBACModelWithDeny - B/op 104 B/op 104 B/op 1
BenchmarkCachedRBACModelWithDeny - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedPriorityModel 171.1 ns/op 104 B/op 4 allocs/op 170.5 ns/op 104 B/op 4 allocs/op 1.00
BenchmarkCachedPriorityModel - ns/op 171.1 ns/op 170.5 ns/op 1.00
BenchmarkCachedPriorityModel - B/op 104 B/op 104 B/op 1
BenchmarkCachedPriorityModel - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedWithEnforceContext 294 ns/op 240 B/op 5 allocs/op 295.5 ns/op 240 B/op 5 allocs/op 0.99
BenchmarkCachedWithEnforceContext - ns/op 294 ns/op 295.5 ns/op 0.99
BenchmarkCachedWithEnforceContext - B/op 240 B/op 240 B/op 1
BenchmarkCachedWithEnforceContext - allocs/op 5 allocs/op 5 allocs/op 1
BenchmarkCachedRBACModelMediumParallel 174.7 ns/op 106 B/op 4 allocs/op 168.1 ns/op 106 B/op 4 allocs/op 1.04
BenchmarkCachedRBACModelMediumParallel - ns/op 174.7 ns/op 168.1 ns/op 1.04
BenchmarkCachedRBACModelMediumParallel - B/op 106 B/op 106 B/op 1
BenchmarkCachedRBACModelMediumParallel - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkHasPolicySmall 461.2 ns/op 150 B/op 6 allocs/op 462.4 ns/op 150 B/op 6 allocs/op 1.00
BenchmarkHasPolicySmall - ns/op 461.2 ns/op 462.4 ns/op 1.00
BenchmarkHasPolicySmall - B/op 150 B/op 150 B/op 1
BenchmarkHasPolicySmall - allocs/op 6 allocs/op 6 allocs/op 1
BenchmarkHasPolicyMedium 492.1 ns/op 157 B/op 6 allocs/op 486.9 ns/op 157 B/op 6 allocs/op 1.01
BenchmarkHasPolicyMedium - ns/op 492.1 ns/op 486.9 ns/op 1.01
BenchmarkHasPolicyMedium - B/op 157 B/op 157 B/op 1
BenchmarkHasPolicyMedium - allocs/op 6 allocs/op 6 allocs/op 1
BenchmarkHasPolicyLarge 530 ns/op 165 B/op 7 allocs/op 522.1 ns/op 165 B/op 7 allocs/op 1.02
BenchmarkHasPolicyLarge - ns/op 530 ns/op 522.1 ns/op 1.02
BenchmarkHasPolicyLarge - B/op 165 B/op 165 B/op 1
BenchmarkHasPolicyLarge - allocs/op 7 allocs/op 7 allocs/op 1
BenchmarkAddPolicySmall 486 ns/op 152 B/op 6 allocs/op 492.3 ns/op 152 B/op 6 allocs/op 0.99
BenchmarkAddPolicySmall - ns/op 486 ns/op 492.3 ns/op 0.99
BenchmarkAddPolicySmall - B/op 152 B/op 152 B/op 1
BenchmarkAddPolicySmall - allocs/op 6 allocs/op 6 allocs/op 1
BenchmarkAddPolicyMedium 554.5 ns/op 175 B/op 7 allocs/op 593.4 ns/op 172 B/op 7 allocs/op 0.93
BenchmarkAddPolicyMedium - ns/op 554.5 ns/op 593.4 ns/op 0.93
BenchmarkAddPolicyMedium - B/op 175 B/op 172 B/op 1.02
BenchmarkAddPolicyMedium - allocs/op 7 allocs/op 7 allocs/op 1
BenchmarkAddPolicyLarge 1090 ns/op 470 B/op 9 allocs/op 1198 ns/op 473 B/op 9 allocs/op 0.91
BenchmarkAddPolicyLarge - ns/op 1090 ns/op 1198 ns/op 0.91
BenchmarkAddPolicyLarge - B/op 470 B/op 473 B/op 0.99
BenchmarkAddPolicyLarge - allocs/op 9 allocs/op 9 allocs/op 1
BenchmarkRemovePolicySmall 502.5 ns/op 166 B/op 7 allocs/op 461.1 ns/op 166 B/op 7 allocs/op 1.09
BenchmarkRemovePolicySmall - ns/op 502.5 ns/op 461.1 ns/op 1.09
BenchmarkRemovePolicySmall - B/op 166 B/op 166 B/op 1
BenchmarkRemovePolicySmall - allocs/op 7 allocs/op 7 allocs/op 1
BenchmarkRemovePolicyMedium 543.1 ns/op 176 B/op 7 allocs/op 539.9 ns/op 176 B/op 7 allocs/op 1.01
BenchmarkRemovePolicyMedium - ns/op 543.1 ns/op 539.9 ns/op 1.01
BenchmarkRemovePolicyMedium - B/op 176 B/op 176 B/op 1
BenchmarkRemovePolicyMedium - allocs/op 7 allocs/op 7 allocs/op 1
BenchmarkRemovePolicyLarge 1325 ns/op 288 B/op 13 allocs/op 1206 ns/op 286 B/op 13 allocs/op 1.10
BenchmarkRemovePolicyLarge - ns/op 1325 ns/op 1206 ns/op 1.10
BenchmarkRemovePolicyLarge - B/op 288 B/op 286 B/op 1.01
BenchmarkRemovePolicyLarge - allocs/op 13 allocs/op 13 allocs/op 1
BenchmarkRaw 17.48 ns/op 0 B/op 0 allocs/op 17.58 ns/op 0 B/op 0 allocs/op 0.99
BenchmarkRaw - ns/op 17.48 ns/op 17.58 ns/op 0.99
BenchmarkRaw - B/op 0 B/op 0 B/op 1
BenchmarkRaw - allocs/op 0 allocs/op 0 allocs/op 1
BenchmarkBasicModel 3608 ns/op 1509 B/op 17 allocs/op 3647 ns/op 1508 B/op 17 allocs/op 0.99
BenchmarkBasicModel - ns/op 3608 ns/op 3647 ns/op 0.99
BenchmarkBasicModel - B/op 1509 B/op 1508 B/op 1.00
BenchmarkBasicModel - allocs/op 17 allocs/op 17 allocs/op 1
BenchmarkRBACModel 5341 ns/op 2059 B/op 35 allocs/op 5423 ns/op 2061 B/op 35 allocs/op 0.98
BenchmarkRBACModel - ns/op 5341 ns/op 5423 ns/op 0.98
BenchmarkRBACModel - B/op 2059 B/op 2061 B/op 1.00
BenchmarkRBACModel - allocs/op 35 allocs/op 35 allocs/op 1
BenchmarkRBACModelSizes/small 51775 ns/op 20315 B/op 480 allocs/op 48230 ns/op 20261 B/op 480 allocs/op 1.07
BenchmarkRBACModelSizes/small - ns/op 51775 ns/op 48230 ns/op 1.07
BenchmarkRBACModelSizes/small - B/op 20315 B/op 20261 B/op 1.00
BenchmarkRBACModelSizes/small - allocs/op 480 allocs/op 480 allocs/op 1
BenchmarkRBACModelSizes/medium 491760 ns/op 191785 B/op 4828 allocs/op 516998 ns/op 191748 B/op 4827 allocs/op 0.95
BenchmarkRBACModelSizes/medium - ns/op 491760 ns/op 516998 ns/op 0.95
BenchmarkRBACModelSizes/medium - B/op 191785 B/op 191748 B/op 1.00
BenchmarkRBACModelSizes/medium - allocs/op 4828 allocs/op 4827 allocs/op 1.00
BenchmarkRBACModelSizes/large 5222509 ns/op 1898988 B/op 48143 allocs/op 5336522 ns/op 1906072 B/op 48353 allocs/op 0.98
BenchmarkRBACModelSizes/large - ns/op 5222509 ns/op 5336522 ns/op 0.98
BenchmarkRBACModelSizes/large - B/op 1898988 B/op 1906072 B/op 1.00
BenchmarkRBACModelSizes/large - allocs/op 48143 allocs/op 48353 allocs/op 1.00
BenchmarkRBACModelSmall 62104 ns/op 20370 B/op 615 allocs/op 56481 ns/op 20362 B/op 615 allocs/op 1.10
BenchmarkRBACModelSmall - ns/op 62104 ns/op 56481 ns/op 1.10
BenchmarkRBACModelSmall - B/op 20370 B/op 20362 B/op 1.00
BenchmarkRBACModelSmall - allocs/op 615 allocs/op 615 allocs/op 1
BenchmarkRBACModelMedium 573635 ns/op 194825 B/op 6021 allocs/op 565580 ns/op 194598 B/op 6020 allocs/op 1.01
BenchmarkRBACModelMedium - ns/op 573635 ns/op 565580 ns/op 1.01
BenchmarkRBACModelMedium - B/op 194825 B/op 194598 B/op 1.00
BenchmarkRBACModelMedium - allocs/op 6021 allocs/op 6020 allocs/op 1.00
BenchmarkRBACModelLarge 6030064 ns/op 1941690 B/op 60656 allocs/op 5991834 ns/op 1940335 B/op 60599 allocs/op 1.01
BenchmarkRBACModelLarge - ns/op 6030064 ns/op 5991834 ns/op 1.01
BenchmarkRBACModelLarge - B/op 1941690 B/op 1940335 B/op 1.00
BenchmarkRBACModelLarge - allocs/op 60656 allocs/op 60599 allocs/op 1.00
BenchmarkRBACModelWithResourceRoles 5212 ns/op 2733 B/op 28 allocs/op 4539 ns/op 1843 B/op 27 allocs/op 1.15
BenchmarkRBACModelWithResourceRoles - ns/op 5212 ns/op 4539 ns/op 1.15
BenchmarkRBACModelWithResourceRoles - B/op 2733 B/op 1843 B/op 1.48
BenchmarkRBACModelWithResourceRoles - allocs/op 28 allocs/op 27 allocs/op 1.04
BenchmarkRBACModelWithDomains 5017 ns/op 1826 B/op 25 allocs/op 5093 ns/op 1827 B/op 25 allocs/op 0.99
BenchmarkRBACModelWithDomains - ns/op 5017 ns/op 5093 ns/op 0.99
BenchmarkRBACModelWithDomains - B/op 1826 B/op 1827 B/op 1.00
BenchmarkRBACModelWithDomains - allocs/op 25 allocs/op 25 allocs/op 1
BenchmarkABACModel 2782 ns/op 1534 B/op 17 allocs/op 2893 ns/op 1534 B/op 17 allocs/op 0.96
BenchmarkABACModel - ns/op 2782 ns/op 2893 ns/op 0.96
BenchmarkABACModel - B/op 1534 B/op 1534 B/op 1
BenchmarkABACModel - allocs/op 17 allocs/op 17 allocs/op 1
BenchmarkABACRuleModel 4036196 ns/op 1328785 B/op 40092 allocs/op 4034367 ns/op 1326375 B/op 40092 allocs/op 1.00
BenchmarkABACRuleModel - ns/op 4036196 ns/op 4034367 ns/op 1.00
BenchmarkABACRuleModel - B/op 1328785 B/op 1326375 B/op 1.00
BenchmarkABACRuleModel - allocs/op 40092 allocs/op 40092 allocs/op 1
BenchmarkKeyMatchModel 6082 ns/op 3067 B/op 37 allocs/op 6192 ns/op 3058 B/op 37 allocs/op 0.98
BenchmarkKeyMatchModel - ns/op 6082 ns/op 6192 ns/op 0.98
BenchmarkKeyMatchModel - B/op 3067 B/op 3058 B/op 1.00
BenchmarkKeyMatchModel - allocs/op 37 allocs/op 37 allocs/op 1
BenchmarkRBACModelWithDeny 6922 ns/op 2480 B/op 49 allocs/op 6880 ns/op 2476 B/op 49 allocs/op 1.01
BenchmarkRBACModelWithDeny - ns/op 6922 ns/op 6880 ns/op 1.01
BenchmarkRBACModelWithDeny - B/op 2480 B/op 2476 B/op 1.00
BenchmarkRBACModelWithDeny - allocs/op 49 allocs/op 49 allocs/op 1
BenchmarkPriorityModel 4199 ns/op 1761 B/op 22 allocs/op 4246 ns/op 1761 B/op 22 allocs/op 0.99
BenchmarkPriorityModel - ns/op 4199 ns/op 4246 ns/op 0.99
BenchmarkPriorityModel - B/op 1761 B/op 1761 B/op 1
BenchmarkPriorityModel - allocs/op 22 allocs/op 22 allocs/op 1
BenchmarkRBACModelWithDomainPatternLarge 23391 ns/op 16732 B/op 164 allocs/op 24387 ns/op 16745 B/op 164 allocs/op 0.96
BenchmarkRBACModelWithDomainPatternLarge - ns/op 23391 ns/op 24387 ns/op 0.96
BenchmarkRBACModelWithDomainPatternLarge - B/op 16732 B/op 16745 B/op 1.00
BenchmarkRBACModelWithDomainPatternLarge - allocs/op 164 allocs/op 164 allocs/op 1
BenchmarkRoleManagerSmall 70045 ns/op 11955 B/op 797 allocs/op 70383 ns/op 11955 B/op 797 allocs/op 1.00
BenchmarkRoleManagerSmall - ns/op 70045 ns/op 70383 ns/op 1.00
BenchmarkRoleManagerSmall - B/op 11955 B/op 11955 B/op 1
BenchmarkRoleManagerSmall - allocs/op 797 allocs/op 797 allocs/op 1
BenchmarkRoleManagerMedium 707450 ns/op 125915 B/op 8741 allocs/op 748653 ns/op 125915 B/op 8741 allocs/op 0.94
BenchmarkRoleManagerMedium - ns/op 707450 ns/op 748653 ns/op 0.94
BenchmarkRoleManagerMedium - B/op 125915 B/op 125915 B/op 1
BenchmarkRoleManagerMedium - allocs/op 8741 allocs/op 8741 allocs/op 1
BenchmarkRoleManagerLarge 7642968 ns/op 1349923 B/op 89741 allocs/op 8191233 ns/op 1349922 B/op 89741 allocs/op 0.93
BenchmarkRoleManagerLarge - ns/op 7642968 ns/op 8191233 ns/op 0.93
BenchmarkRoleManagerLarge - B/op 1349923 B/op 1349922 B/op 1.00
BenchmarkRoleManagerLarge - allocs/op 89741 allocs/op 89741 allocs/op 1
BenchmarkBuildRoleLinksWithPatternLarge 6256557958 ns/op 5346899296 B/op 60949825 allocs/op 6188018487 ns/op 5346308392 B/op 60950166 allocs/op 1.01
BenchmarkBuildRoleLinksWithPatternLarge - ns/op 6256557958 ns/op 6188018487 ns/op 1.01
BenchmarkBuildRoleLinksWithPatternLarge - B/op 5346899296 B/op 5346308392 B/op 1.00
BenchmarkBuildRoleLinksWithPatternLarge - allocs/op 60949825 allocs/op 60950166 allocs/op 1.00
BenchmarkBuildRoleLinksWithDomainPatternLarge 171326965 ns/op 141524824 B/op 1676490 allocs/op 167324166 ns/op 141336646 B/op 1676529 allocs/op 1.02
BenchmarkBuildRoleLinksWithDomainPatternLarge - ns/op 171326965 ns/op 167324166 ns/op 1.02
BenchmarkBuildRoleLinksWithDomainPatternLarge - B/op 141524824 B/op 141336646 B/op 1.00
BenchmarkBuildRoleLinksWithDomainPatternLarge - allocs/op 1676490 allocs/op 1676529 allocs/op 1.00
BenchmarkBuildRoleLinksWithPatternAndDomainPatternLarge 6449048820 ns/op 5482896960 B/op 62559958 allocs/op 6322665690 ns/op 5485058616 B/op 62560942 allocs/op 1.02
BenchmarkBuildRoleLinksWithPatternAndDomainPatternLarge - ns/op 6449048820 ns/op 6322665690 ns/op 1.02
BenchmarkBuildRoleLinksWithPatternAndDomainPatternLarge - B/op 5482896960 B/op 5485058616 B/op 1.00
BenchmarkBuildRoleLinksWithPatternAndDomainPatternLarge - allocs/op 62559958 allocs/op 62560942 allocs/op 1.00
BenchmarkHasLinkWithPatternLarge 10565 ns/op 7608 B/op 111 allocs/op 10698 ns/op 7609 B/op 111 allocs/op 0.99
BenchmarkHasLinkWithPatternLarge - ns/op 10565 ns/op 10698 ns/op 0.99
BenchmarkHasLinkWithPatternLarge - B/op 7608 B/op 7609 B/op 1.00
BenchmarkHasLinkWithPatternLarge - allocs/op 111 allocs/op 111 allocs/op 1
BenchmarkHasLinkWithDomainPatternLarge 481.8 ns/op 80 B/op 5 allocs/op 497.3 ns/op 80 B/op 5 allocs/op 0.97
BenchmarkHasLinkWithDomainPatternLarge - ns/op 481.8 ns/op 497.3 ns/op 0.97
BenchmarkHasLinkWithDomainPatternLarge - B/op 80 B/op 80 B/op 1
BenchmarkHasLinkWithDomainPatternLarge - allocs/op 5 allocs/op 5 allocs/op 1
BenchmarkHasLinkWithPatternAndDomainPatternLarge 10329 ns/op 7610 B/op 111 allocs/op 10858 ns/op 7607 B/op 111 allocs/op 0.95
BenchmarkHasLinkWithPatternAndDomainPatternLarge - ns/op 10329 ns/op 10858 ns/op 0.95
BenchmarkHasLinkWithPatternAndDomainPatternLarge - B/op 7610 B/op 7607 B/op 1.00
BenchmarkHasLinkWithPatternAndDomainPatternLarge - allocs/op 111 allocs/op 111 allocs/op 1

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.10.

Benchmark suite Current: 46136ed Previous: 5acc404 Ratio
BenchmarkCachedRBACModelMedium 195.8 ns/op 104 B/op 4 allocs/op 176.3 ns/op 104 B/op 4 allocs/op 1.11
BenchmarkCachedRBACModelMedium - ns/op 195.8 ns/op 176.3 ns/op 1.11
BenchmarkRBACModelWithResourceRoles 5212 ns/op 2733 B/op 28 allocs/op 4539 ns/op 1843 B/op 27 allocs/op 1.15
BenchmarkRBACModelWithResourceRoles - ns/op 5212 ns/op 4539 ns/op 1.15
BenchmarkRBACModelWithResourceRoles - B/op 2733 B/op 1843 B/op 1.48

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.