Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
fix: reject unhyphenated channelIDs from register
Browse files Browse the repository at this point in the history
Closes #1225
  • Loading branch information
pjenvey committed May 11, 2018
1 parent 976c4c3 commit 2579197
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions autopush_rs/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,6 @@ where
);
transition!(AwaitMigrateUser { response, data });
} else if all_acked && webpush.flags.reset_uaid {

let response = data.srv.ddb.drop_uaid(&data.srv.opts.router_table_name, &webpush.uaid);
transition!(AwaitDropUser { response, data });
}
Expand Down Expand Up @@ -733,9 +732,18 @@ where
transition!(AwaitInput { data });
}
}
Either::A(ClientMessage::Register { channel_id, key }) => {
Either::A(ClientMessage::Register {
channel_id: channel_id_str,
key,
}) => {
debug!("Got a register command";
"channel_id" => channel_id.hyphenated().to_string());
"channel_id" => &channel_id_str);
let channel_id =
Uuid::parse_str(&channel_id_str).chain_err(|| "Invalid channelID")?;
if channel_id.hyphenated().to_string() != channel_id_str {
return Err("Bad UUID format, use lower case, dashed format".into());
}

let uaid = webpush.uaid.clone();
let message_month = webpush.message_month.clone();
let srv = data.srv.clone();
Expand All @@ -750,6 +758,8 @@ where
}
Either::A(ClientMessage::Unregister { channel_id, code }) => {
debug!("Got a unregister command");
// XXX: unregister should check the format of channel_id like
// register does
let uaid = webpush.uaid.clone();
let message_month = webpush.message_month.clone();
let fut = data.srv.ddb.unregister(
Expand Down
2 changes: 1 addition & 1 deletion autopush_rs/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub enum ClientMessage {

Register {
#[serde(rename = "channelID")]
channel_id: Uuid,
channel_id: String,
key: Option<String>,
},

Expand Down

0 comments on commit 2579197

Please sign in to comment.