Skip to content

Commit 61017e2

Browse files
committed
chore: validate keys before persisting for Azure CosmosDB key-value stores
Signed-off-by: Thorsten Hans <[email protected]>
1 parent bd5457e commit 61017e2

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

crates/key-value-azure/src/store.rs

+9
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,15 @@ impl Store for AzureCosmosStore {
154154
}
155155

156156
async fn set(&self, key: &str, value: &[u8]) -> Result<(), Error> {
157+
let illegal_chars = ['/', '\\', '?', '#'];
158+
159+
if key.contains(|c| illegal_chars.contains(&c)) {
160+
return Err(Error::Other(format!(
161+
"Key contains an illegal character. Allowed characters do not include: {}",
162+
illegal_chars.iter().collect::<String>()
163+
)));
164+
}
165+
157166
let pair = Pair {
158167
id: key.to_string(),
159168
value: value.to_vec(),

0 commit comments

Comments
 (0)