fix(security): replace string interpolation with static match in gear SQL filter

GearCategory is a Rust enum so this was not exploitable, but the
format!() pattern is a code smell. Use a match returning &'static str
literals instead for consistency with the rest of the parameterised
query codebase.
This commit is contained in:
Jon Seager 2026-02-06 17:52:08 +00:00
parent 533a0a067f
commit 1f2ec0fc14
No known key found for this signature in database

View file

@ -51,11 +51,12 @@ impl SqlGearRepository {
}) })
} }
fn build_where_clause(filter: &GearFilter) -> Option<String> { fn build_where_clause(filter: &GearFilter) -> Option<&'static str> {
filter filter.category.as_ref().map(|category| match category {
.category GearCategory::Grinder => "category = 'grinder'",
.as_ref() GearCategory::Brewer => "category = 'brewer'",
.map(|category| format!("category = '{}'", category.as_str())) GearCategory::FilterPaper => "category = 'filter_paper'",
})
} }
} }