You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "cmackenzie1 (via GitHub)" <gi...@apache.org> on 2026/02/09 21:37:43 UTC
[PR] fix(rest): Filter sensitive headers from error logs (#2117) [iceberg-rust]
cmackenzie1 opened a new pull request, #2130:
URL: https://github.com/apache/iceberg-rust/pull/2130
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
- Closes #2117
## What changes are included in this PR?
<!--
Provide a summary of the modifications in this PR. List the main changes such as new features, bug fixes, refactoring, or any other updates.
-->
Sensitive headers like Set-Cookie, Authorization, and Cookie were being included in error messages, potentially exposing authentication tokens and session information in logs.
This change filters out sensitive headers entirely from error context rather than logging their values, preventing credential leakage.
## Are these changes tested?
<!--
Specify what test covers (unit test, integration test, etc.).
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
Covered by unit tests.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] fix(rest): Filter sensitive headers from error logs (#2117) [iceberg-rust]
Posted by "blackmwk (via GitHub)" <gi...@apache.org>.
blackmwk commented on code in PR #2130:
URL: https://github.com/apache/iceberg-rust/pull/2130#discussion_r2796535410
##########
crates/catalog/rest/src/client.rs:
##########
@@ -278,14 +278,40 @@ pub(crate) async fn deserialize_catalog_response<R: DeserializeOwned>(
})
}
+/// Headers that contain sensitive information and should be excluded from logs.
+const SENSITIVE_HEADERS: &[&str] = &[
+ "authorization",
+ "proxy-authorization",
+ "set-cookie",
+ "cookie",
+ "x-api-key",
+ "x-auth-token",
+];
+
+/// Returns true if the header name is considered sensitive.
+fn is_sensitive_header(name: &str) -> bool {
+ let name_lower = name.to_lowercase();
+ SENSITIVE_HEADERS.iter().any(|h| name_lower == *h)
+}
+
+/// Filters out sensitive headers and returns a debug-formatted string.
+fn format_headers_redacted(headers: &HeaderMap) -> String {
+ let filtered: HashMap<&str, &str> = headers
+ .iter()
+ .filter(|(name, _)| !is_sensitive_header(name.as_str()))
+ .filter_map(|(name, value)| value.to_str().ok().map(|v| (name.as_str(), v)))
+ .collect();
+ format!("{filtered:?}")
Review Comment:
When we say redacting sensitive header, I think we replace actually content with things like `xxxx` rather than removing them?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] fix(rest): Filter sensitive headers from error logs (#2117) [iceberg-rust]
Posted by "cmackenzie1 (via GitHub)" <gi...@apache.org>.
cmackenzie1 commented on code in PR #2130:
URL: https://github.com/apache/iceberg-rust/pull/2130#discussion_r2800463262
##########
crates/catalog/rest/src/client.rs:
##########
@@ -278,14 +278,40 @@ pub(crate) async fn deserialize_catalog_response<R: DeserializeOwned>(
})
}
+/// Headers that contain sensitive information and should be excluded from logs.
+const SENSITIVE_HEADERS: &[&str] = &[
+ "authorization",
+ "proxy-authorization",
+ "set-cookie",
+ "cookie",
+ "x-api-key",
+ "x-auth-token",
+];
+
+/// Returns true if the header name is considered sensitive.
+fn is_sensitive_header(name: &str) -> bool {
+ let name_lower = name.to_lowercase();
+ SENSITIVE_HEADERS.iter().any(|h| name_lower == *h)
+}
+
+/// Filters out sensitive headers and returns a debug-formatted string.
+fn format_headers_redacted(headers: &HeaderMap) -> String {
+ let filtered: HashMap<&str, &str> = headers
+ .iter()
+ .filter(|(name, _)| !is_sensitive_header(name.as_str()))
+ .filter_map(|(name, value)| value.to_str().ok().map(|v| (name.as_str(), v)))
+ .collect();
+ format!("{filtered:?}")
Review Comment:
Thanks for the feedback @blackmwk! Updated to redact instead of filter using `[REDACTED]` as a value and made it configurable.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] fix(rest): Filter sensitive headers from error logs (#2117) [iceberg-rust]
Posted by "blackmwk (via GitHub)" <gi...@apache.org>.
blackmwk merged PR #2130:
URL: https://github.com/apache/iceberg-rust/pull/2130
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] fix(rest): Filter sensitive headers from error logs (#2117) [iceberg-rust]
Posted by "blackmwk (via GitHub)" <gi...@apache.org>.
blackmwk commented on code in PR #2130:
URL: https://github.com/apache/iceberg-rust/pull/2130#discussion_r2801838980
##########
crates/catalog/rest/src/client.rs:
##########
@@ -278,14 +287,64 @@ pub(crate) async fn deserialize_catalog_response<R: DeserializeOwned>(
})
}
+/// Headers that contain sensitive information and should be excluded from logs.
+const SENSITIVE_HEADERS: &[&str] = &[
+ "authorization",
+ "proxy-authorization",
+ "set-cookie",
+ "cookie",
+ "x-api-key",
+ "x-auth-token",
+];
+
+/// Returns true if the header name is considered sensitive.
+fn is_sensitive_header(name: &str) -> bool {
+ let name_lower = name.to_lowercase();
+ SENSITIVE_HEADERS.iter().any(|h| name_lower == *h)
+}
+
+/// Redacts sensitive headers and returns a debug-formatted string.
+///
+/// If `disable_redaction` is true, returns all headers without redaction.
+/// Otherwise, replaces sensitive header values with "[REDACTED]".
+fn format_headers_redacted(headers: &HeaderMap, disable_redaction: bool) -> String {
Review Comment:
```suggestion
fn format_headers(headers: &HeaderMap, disable_redaction: bool) -> String {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] fix(rest): Filter sensitive headers from error logs (#2117) [iceberg-rust]
Posted by "blackmwk (via GitHub)" <gi...@apache.org>.
blackmwk commented on code in PR #2130:
URL: https://github.com/apache/iceberg-rust/pull/2130#discussion_r2796540370
##########
crates/catalog/rest/src/client.rs:
##########
@@ -278,14 +278,40 @@ pub(crate) async fn deserialize_catalog_response<R: DeserializeOwned>(
})
}
+/// Headers that contain sensitive information and should be excluded from logs.
+const SENSITIVE_HEADERS: &[&str] = &[
+ "authorization",
+ "proxy-authorization",
+ "set-cookie",
+ "cookie",
+ "x-api-key",
+ "x-auth-token",
+];
+
+/// Returns true if the header name is considered sensitive.
+fn is_sensitive_header(name: &str) -> bool {
+ let name_lower = name.to_lowercase();
+ SENSITIVE_HEADERS.iter().any(|h| name_lower == *h)
+}
+
+/// Filters out sensitive headers and returns a debug-formatted string.
+fn format_headers_redacted(headers: &HeaderMap) -> String {
+ let filtered: HashMap<&str, &str> = headers
+ .iter()
+ .filter(|(name, _)| !is_sensitive_header(name.as_str()))
+ .filter_map(|(name, value)| value.to_str().ok().map(|v| (name.as_str(), v)))
+ .collect();
+ format!("{filtered:?}")
Review Comment:
The reason we want to keep them rather than removing them directly is that if maybe confusing when missing these headers when debugging. Also, I would prefer to add a config to disable the redaction. We could redact these header by default, but we should allow user to disable it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org