diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d504b8f..fb934b8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,12 @@ Versioning](https://semver.org/spec/v2.0.0.html). now properly respected and retained. - User expecting `status_id` change when `qualifier_id` is changed will need to specify desired `qualifier_id` while updating cluster. +- When inserting a new filter using `filters.insert(new.name.clone(), new)`, the + function now checks for conflicts in the filter collection. + - If the `new.name` already exists, the function returns an error, preventing + unintentional or malicious deletion of any filter. + - This fix adds an extra layer of security, ensuring the integrity of the + filter collection. ## [0.17.0] - 2024-01-19 diff --git a/src/graphql/filter.rs b/src/graphql/filter.rs index 72475fed..88056c62 100644 --- a/src/graphql/filter.rs +++ b/src/graphql/filter.rs @@ -210,7 +210,9 @@ impl FilterMutation { } filters.remove(&old.name); - filters.insert(new.name.clone(), new); + if let Some(v) = filters.insert(new.name.clone(), new) { + return Err(format!("filter named {} already exists", v.name).into()); + } let new_value = codec.serialize(&filters)?; map.update( (username.as_bytes(), old_value.as_ref()),