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:
Zhengchao An
2026-07-08 17:02:20 +08:00
committed by GitHub
parent 04bf2e7b99
commit d5687e1693
2 changed files with 137 additions and 0 deletions
+5
View File
@@ -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
}
}