mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-27 15:37:02 +00:00
fix(policy): compare NotResource in Statement equality (#4454)
Statement equality drives merge/dedup of policy statements. Omitting NotResource let semantically-distinct statements be treated as duplicates and dropped, which can shrink Deny coverage and escalate privileges. Compare not_resources too and add regression tests. Refs rustfs/backlog#1028
This commit is contained in:
@@ -283,11 +283,16 @@ impl Validator for Statement {
|
||||
}
|
||||
|
||||
impl PartialEq for Statement {
|
||||
// This equality drives `Policy::drop_duplicate_statements`/`merge_policies`, so it
|
||||
// must compare every field that affects matching. Any new match-affecting field
|
||||
// added to `Statement` MUST be compared here too, otherwise semantically-distinct
|
||||
// statements can be silently dropped and shrink Deny coverage.
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.effect == other.effect
|
||||
&& self.actions == other.actions
|
||||
&& self.not_actions == other.not_actions
|
||||
&& self.resources == other.resources
|
||||
&& self.not_resources == other.not_resources
|
||||
&& self.conditions == other.conditions
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user