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:
parent
533a0a067f
commit
1f2ec0fc14
1 changed files with 6 additions and 5 deletions
|
|
@ -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'",
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue