Skip to content

Commit 6c58308

Browse files
authored
fix: middleware dos, storage metadata (#1581)
removed usage of unwraps in middleware to prevent unauthenticated dos bumped the default storage metadata version to v8
1 parent 32735fd commit 6c58308

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

src/handlers/http/middleware.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,21 @@ where
152152
For requests made from other clients, no change.
153153
154154
## Section start */
155-
if let Some(kinesis_common_attributes) =
156-
req.request().headers().get(KINESIS_COMMON_ATTRIBUTES_KEY)
155+
if self.action.eq(&Action::Ingest)
156+
&& let Some(kinesis_common_attributes) =
157+
req.request().headers().get(KINESIS_COMMON_ATTRIBUTES_KEY)
158+
&& let Ok(attribute_value) = kinesis_common_attributes.to_str()
159+
&& let Ok(message) = serde_json::from_str::<Message>(attribute_value)
160+
&& let Ok(auth_value) =
161+
header::HeaderValue::from_str(&message.common_attributes.authorization)
162+
&& let Ok(stream_name_key) =
163+
header::HeaderValue::from_str(&message.common_attributes.x_p_stream)
157164
{
158-
let attribute_value: &str = kinesis_common_attributes.to_str().unwrap();
159-
let message: Message = serde_json::from_str(attribute_value).unwrap();
160-
req.headers_mut().insert(
161-
HeaderName::from_static(AUTHORIZATION_KEY),
162-
header::HeaderValue::from_str(&message.common_attributes.authorization).unwrap(),
163-
);
165+
req.headers_mut()
166+
.insert(HeaderName::from_static(AUTHORIZATION_KEY), auth_value);
164167
req.headers_mut().insert(
165168
HeaderName::from_static(STREAM_NAME_HEADER_KEY),
166-
header::HeaderValue::from_str(&message.common_attributes.x_p_stream).unwrap(),
169+
stream_name_key,
167170
);
168171
req.headers_mut().insert(
169172
HeaderName::from_static(LOG_SOURCE_KEY),

src/storage/store_metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use super::PARSEABLE_METADATA_FILE_NAME;
4343

4444
// Expose some static variables for internal usage
4545
pub static STORAGE_METADATA: OnceCell<StaticStorageMetadata> = OnceCell::new();
46-
pub const CURRENT_STORAGE_METADATA_VERSION: &str = "v6";
46+
pub const CURRENT_STORAGE_METADATA_VERSION: &str = "v8";
4747
// For use in global static
4848
#[derive(Debug, PartialEq, Eq)]
4949
pub struct StaticStorageMetadata {

0 commit comments

Comments
 (0)