Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions collector/src/framework/analyzers/http_decompressor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ impl HTTPDecompressor {
}

/// Keep the compressed data in the event (adds a compressed_body field)
#[allow(dead_code)]
pub fn keep_compressed(mut self) -> Self {
self.keep_compressed = true;
self
Expand Down
11 changes: 6 additions & 5 deletions collector/src/framework/analyzers/ssl_merger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,12 @@ impl SSLMerger {
// For non-chunked, check Content-Length
if let Some(cl_start) = headers.to_lowercase().find("content-length:") {
let cl_line = &headers[cl_start..];
if let Some(cl_end) = cl_line.find("\r\n") {
let cl_value = &cl_line[15..cl_end].trim();
if let Ok(content_length) = cl_value.parse::<usize>() {
return body.len() >= content_length;
}
// Find the end of the Content-Length header line
// It could be followed by \r\n (if there are more headers) or end of headers
let cl_end = cl_line.find("\r\n").unwrap_or(cl_line.len());
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Content-Length detection uses headers.to_lowercase().find("content-length:"), which can match inside other header names (e.g., X-Content-Length) or within a header value, and then slices from that byte offset. This can cause incorrect Content-Length parsing and premature message completion. Consider parsing headers line-by-line (split on \r\n) and matching Content-Length only at the start of a header line (case-insensitive), or at least ensuring the match is at start-of-string or preceded by \r\n.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 573cc1c. Changed implementation to parse headers line-by-line using split("\r\n") and match Content-Length only at the start of header lines with starts_with(), preventing false matches in other header names or values.

let cl_value = cl_line[15..cl_end].trim();
if let Ok(content_length) = cl_value.parse::<usize>() {
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The slice offset 15 is a magic number for the length of "Content-Length:". Using "content-length:".len() (or deriving the offset from the matched prefix) would be safer and easier to maintain if the header name string changes.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 573cc1c. Replaced magic number 15 with "content-length:".len() for better maintainability.

return body.len() >= content_length;
}
}

Expand Down
Loading