bingquanzhao opened a new pull request, #71346: URL: https://github.com/apache/doris/pull/71346
### Background The Logstash Doris output plugin (`extension/logstash`, `logstash-output-doris`, docs: https://doris.apache.org/docs/dev/ecosystem/logstash) loads batched events from Logstash into Apache Doris via HTTP Stream Load `PUT` requests. It constructs request headers from user-configured `headers` plus HTTP Basic credentials derived from the `user` and `password` plugin settings, and logs request metadata during initialization and on each batch load. ### What problem does this PR solve? Issue Number: None Related PR: #3800 (introduced startup header logging), #33135 (introduced per-request header logging), #48040 (refactored per-request header logging for multi-table) PR Type: Bugfix Problem Summary: Even though `password` is declared with `:validate => :password` in Logstash, `logstash-output-doris` logs the full request header hash at `INFO` level during plugin startup and before every Stream Load request (by default), exposing `"Authorization" => "Basic <base64(user:password)>"` in plaintext Logstash logs. This PR avoids mutating `@headers` in place and masks sensitive headers (`Authorization`, `Proxy-Authorization`, `Cookie`, `Set-Cookie`, `token`, `Auth-Token`, case-insensitively) with `***MASKED***` before logging while leaving the actual outbound HTTP headers unchanged. Most of the diff is a new standalone unit test file covering both log sites and verifying that outbound requests still receive real credentials. After upgrading to v1.2.2, sensitive headers appear as `***MASKED***` in Logstash logs without any configuration or authentication behavior change. ### Details - **Change map:** 17 lines of production code (`extension/logstash/lib/logstash/outputs/doris.rb`), 2 lines of gemspec version bump (`extension/logstash/logstash-output-doris.gemspec`), and 447 lines of unit tests (`extension/logstash/spec/outputs/doris_test.rb`). - **Frequency:** Always on plugin startup (`register`) at `INFO` level regardless of `log_request`, and on every Stream Load request (`make_request`) under the default configuration (`log_request => true`) or whenever debug logging is enabled. - **Root cause:** `make_request_headers` inserts `"Authorization" => "Basic " + Base64.strict_encode64("#{@user}:#{@password.value}")` directly into `@request_headers` (and mutated `@headers` in place when `@headers` was non-nil), and both `register` and `make_request` logged `@request_headers` / `table_events.http_headers` verbatim without redacting sensitive headers. - **Why existing tests missed it:** `extension/logstash` previously had no automated unit tests. - **Fix:** Copy `(@headers || {}).dup` in `make_request_headers`; add `sanitize_headers` (matching Doris FE's `LoadAction#isSensitiveHeader` header set and `***MASKED***` placeholder) to return a masked copy for logging; apply `sanitize_headers` at both `@logger.info` call sites (`register` and `make_request`); bump gem version from `1.2.1` to `1.2.2`. - **Other paths and branches:** Audited all `@logger` calls across `extension/logstash/lib/`; `print_plugin_info` and all other log statements do not log `@password`, `@user`, or request headers. `extension/beats/doris/client.go` already masks `Authorization` in its `String()` methods. - **Behavior change:** Sensitive request headers (such as `Authorization` and `token`) are now logged as `***MASKED***` instead of their raw values; actual HTTP headers sent to Doris FE/BE are unchanged. ### Testing Ran locally on macOS (Ruby 2.6.10): - `ruby -c` syntax checks on `doris.rb`, `logstash-output-doris.gemspec`, and `spec/outputs/doris_test.rb` — all `Syntax OK`. - `ruby extension/logstash/spec/outputs/doris_test.rb -v` — 5 runs, 55 assertions, 0 failures, 0 errors: verifies case-insensitive masking of sensitive headers without mutating originals, non-mutation of `@headers` in `make_request_headers`, masked `register` startup log, masked `make_request` logs (both `log_request=true` and `log_request=false` with `debug=true`), and delivery of real unmasked `Authorization` / `token` headers on the outgoing `HttpPut` request. - `Gem::Specification.load("logstash-output-doris.gemspec")` — loads cleanly with `version=1.2.2` and includes `spec/outputs/doris_test.rb` in `test_files`. ### Release note Mask sensitive HTTP headers (such as `Authorization` and `token`) as `***MASKED***` in `logstash-output-doris` logs instead of logging Base64-encoded credentials. ### Check List (For Author) - Behavior changed: Yes (see Details) - Does this need documentation: No - Pre-submission status: Ready ### AI Disclosure - Tool: Antigravity (Gemini) - Generated: Code fix, unit tests, and this PR description. - Human review: Reviewed the issue verification, code diff, and test coverage before pushing and opening the PR. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
