Repository navigation
[fix](fe) Preserve SQL formatting when masking FE logs - #69467
Conversation
### What problem does this PR solve? Issue Number: N/A Problem Summary: Rebuilding SQL property lists for FE log masking loses line breaks, indentation and comments. Some execution-log paths still use the original SQL, and parser diagnostics can repeat credentials even when the primary log message is masked. Share the audit masking parser and sensitive-property policy while adding a mode that replaces only value ranges in the original SQL. Use that mode consistently before and after parsing, independently of the audit gate. Translate code-point offsets to UTF-16 offsets to handle supplementary characters correctly. Keep the audit log's existing formatting and gate. Use fixed placeholders when masking fails, omit input-bearing parser and masking exception diagnostics, and avoid applying execution hints while preparing log text. ### Release note Preserve SQL formatting in FE execution logs while masking recognized credentials. Do not repeat the original SQL in syntax-error diagnostics. ### Check List (For Author) - Test: FE Core compilation, 35 focused unit tests, and Checkstyle. - Behavior changed: Yes; FE logs preserve layout and mask credential values. Audit log formatting and dispatch remain unchanged. - Does this need documentation: No; no SQL or configuration interfaces change.
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
run buildall |
|
/review |
There was a problem hiding this comment.
No new actionable findings in the seven-file diff at 6939795. The review converged after two rounds, with two reviewers covering the full change and a separate reviewer examining the identified risks. No existing inline findings require a blocking disposition. No additional user focus was supplied.
Critical checkpoint conclusions:
- Goal and evidence: value-only masking preserves source layout, converts code-point ranges for FE logging, and omits input-bearing parser diagnostics at the changed StmtExecutor boundaries. Added tests assert representative positive and negative behavior; they were inspected, not executed.
- Scope and reuse: changes remain focused and reuse existing sensitivity rules, property-key parsing, audit parser, and SQL rewriting.
- Concurrency and locks: no new threads, shared-state concurrency, lock acquisitions, or lock-order changes were introduced.
- Lifecycle: parser/maps are temporary; no new retained resources or static initialization dependencies. Inherited parsing can update statement IDs/aliases/hints, but no concrete new execution regression was established.
- Configuration: no configuration additions or dynamic-update requirements.
- Compatibility: the existing parser overload and audit gate/rendering mode remain available; no wire/storage format change.
- Thrift/protobuf: no definitions or field IDs changed.
- Parallel paths: reviewed preparse/parsed logging, retry, internal-query and HTTP planning paths, plus the separate audit dispatch.
- Conditions and errors: null/empty skips have concrete callers; sensitivity and layout checks match their purposes. Masking exceptions yield a fixed placeholder without exception text or Throwable.
- Test coverage: new JUnit cases cover exact layout, Unicode, hidden keys, password masking, CTAS/EXPLAIN, SET_VAR non-application, empty SQL, syntax errors and masking failures. Real retry/HTTP flows were not exercised end to end.
- Expected results: new assertions match the inspected grammar, policy and replacement spans; no generated regression result files changed.
- Observability: query identifiers and exception types remain available on the changed parser-error boundaries; no new operation needs metrics.
- Transactions/persistence: no transaction, EditLog, replay or failover logic changed.
- Writes/atomicity: no data-write or commit behavior changed; visibility and delete-bitmap invariants are unaffected.
- FE-BE state: no new cross-process variables or sending paths.
- Performance: UTF-16 conversion walks disjoint source spans linearly. Some logging paths add a masking parse, including retry/error arguments evaluated with DEBUG disabled; no substantiated material regression was found.
- Additional risks: normalized/escaped keys, duplicate-key failure behavior, disjoint password/property spans, supplementary characters, prepared placeholders, distribution hints and exception chains were rechecked. No unresolved new candidate remains.
Static review only: no builds or tests were run, as required. The new failure tests cover their exercised StmtExecutor logger boundaries. Pre-existing raw exception diagnostics in upstream/HTTP error paths remain; this result does not establish universal FE log sanitization. Audit behavior, including its existing limitations, is retained.
Review converged after 2 round(s).
FE UT Coverage ReportIncrement line coverage |
TPC-H: Total hot run time: 28728 ms |
TPC-DS: Total hot run time: 150639 ms |
ClickBench: Total hot run time: 24.17 s |
FE Regression Coverage ReportIncrement line coverage |
### What problem does this PR solve? Issue Number: N/A Related PR: apache#69467 Problem Summary: The audit entry point uses the compact formatting mode, but code-point-to-UTF-16 conversion only ran in the formatting-preserving mode. Supplementary characters before or inside a credential could shift the replacement range and leave part or all of its value unmasked. Normalize replacement ranges at the NereidsParser.parseForEncryption output boundary for both modes and for direct streaming callers. Collect the original code-point ranges in sorted order and advance through them once. Remove the mode-specific conversion from NeedAuditEncryption to avoid converting the same range twice. Keep the existing audit rendering, hidden-property policy and dispatch gate. Add regressions for the default audit API, ASCII and BMP prefixes, supplementary characters before and inside passwords, distinct output policies, and multiple direct-parser replacement ranges. ### Release note Correct credential masking for SQL containing supplementary Unicode characters in audit and execution logs. ### Check List (For Author) - Test: 58 focused FE unit tests and Checkstyle passed; FE Core compiled. - Behavior changed: Yes; both formatting modes use correct UTF-16 ranges. Audit formatting and dispatch remain unchanged. - Does this need documentation: No; no SQL or configuration interfaces change.
|
run buildall |
TPC-H: Total hot run time: 28732 ms |
TPC-H: Total hot run time: 29583 ms |
TPC-DS: Total hot run time: 151245 ms |
ClickBench: Total hot run time: 24.14 s |
### Background The pending always-on query audit change protects startup and runtime settings and records prepared execution on the receiving FE. ### What problem does this PR solve? Issue Number: None Related PR: apache#70123 (local review follow-up), apache#69467 and apache#70366 (masking offset contracts) PR Type: Bugfix Problem Summary: Close the review findings on early prepared redaction, invalid dispatcher intervals, and audit records for rejected prepared handles. Keep audit metadata separate from execution state, retain the audit file in always-on mode, and use parser-provided UTF-16 ranges for audit text rewriting. ### Details - Frequency: Applies to the affected prepared execution or logger paths, nonpositive dispatcher settings, and SQL masking with supplementary characters. - Root cause: The earlier audit path lacked a saved redaction plan and skipped handle lookup failures. It used a one-sided interval bound and wrote the preparation hash into the live execution context. File logging used a shared switch. The shared masker converted offsets already normalized by the parser. - Why existing tests missed it: Prepared audit tests exercised known handles and ordinary statements. The earlier focused run omitted the separate supplementary-character masking suite. - Fix: Pass the saved plan and original template for sensitive execution, emit an event for an unknown handle, require a positive dispatcher interval, pass the hash into the audit event, keep the audit file appender, and give UTF-16 audit replacements an explicit rewrite entry point. - Other paths and branches: Migrate streaming-insert masking consumers of the same parser offsets. Preserve lexer code-point handling for view rewrites. This commit targets the pending local PR branch. ### Testing 169 targeted FE tests passed in the expanded run. All 23 tests in the prepared-statement class passed after correcting its synthetic query ID fixture. Checkstyle passed on all 29 Java files in the full diff. ### Release note Sensitive prepared audit records use masked SQL templates. Always-on query audit records unknown prepared handles, keeps its file appender, and rejects invalid dispatcher intervals. Audit SQL masking preserves supplementary characters correctly. ### Check List (For Author) - Behavior changed: Yes (see Details). - Does this need documentation: No separate update. The FE config description covers the audit file behavior. - Pre-submission status: Partially verified: Docker and mixed-version cluster scenarios were not exercised. ### AI Disclosure - Tool: Codex. - Generated: Local bug fixes, unit coverage, and follow-up review. - Human review: Pending.
What problem does this PR solve?
Issue Number: N/A
Problem Summary:
SQL masking in FE execution logs rebuilds entire property lists, losing their line breaks, indentation, comments and original key formatting. Some retry, internal query and HTTP stream planning logs also print the original SQL. Parser exceptions can repeat the original SQL in their diagnostic text even when the main log message uses a masked statement.
Reuse the audit masking parser and the existing sensitive/hidden property key policies, with a formatting-preserving mode that replaces only sensitive values. Use this shared path for StmtExecutor SQL logs before and after parsing, including statements whose audit-encryption flag is false. Normalize parser replacement ranges to inclusive UTF-16 offsets for both formatting modes and direct streaming callers, so supplementary Unicode characters cannot shift the masked ranges. Keep audit logging's existing formatting and dispatch behavior.
Masking failures return a fixed placeholder. Logs for masking and syntax failures record the exception type without input-bearing exception messages or stack traces. Logging pre-processing does not apply execution hints.
Release note
FE execution logs preserve SQL line breaks and formatting while masking recognized credential values. Syntax-error diagnostics no longer repeat the original SQL. Supplementary Unicode characters no longer leave recognized credentials unmasked in audit SQL.
Check List (For Author)
Check List (For Reviewer who merge this PR)