Skip to content

e.GetFilteredPolicy Empty string treated as wildcard #1708

@DatScreamer

Description

@DatScreamer

Expected behaviour:
In GetFilteredPolicy, "" empty string should be treated as empty string, and "*" should be treated as wildcard.

Actual behaviour:
"" empty string acts as a wildcard in this line of GetFilteredPolicy:
if fieldValue != "" && rule[fieldIndex+i] != fieldValue {

Suggested fix:
GetStrictFilteredPolicy which treats "" empty string as empty string, and treats "*" as wildcard.

GetStrictFilteredPolicy so as to not introduce a breaking change in GetFilteredPolicy

Why does this matter:

  1. It's been discussed that Casbin adapters should support empty strings, therefore there should be a way to Get Filtered Policy for rules with empty string values.
  2. Semantic accuracy.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions