LuciferYang opened a new pull request, #7728:
URL: https://github.com/apache/kyuubi/pull/7728

   ### Why are the changes needed?
   
   Closes #7727.
   
   `genKeyValuePair` trimmed only the concatenated string 
(`s"$key=$value".trim`), so whitespace between the key and value survived: 
`genKeyValuePair("abc ", "123")` returned `"abc =123"`. `redactConfValues` 
splits an assembled argument on the first `=` and matches the key against an 
exact key set, so a spaced key (`"<key> ="`) misses the set and the value is 
not redacted.
   
   This matters for the Data Agent engine's API key. 
`kyuubi.engine.data.agent.openai.api.key` is not matched by the default 
pattern-based redaction, so exact-key redaction is its only guard, and session 
conf keys are not trimmed on the way to the engine command. A key carrying a 
trailing space slipped both stages and logged the API key value. Trimming each 
side (`s"${key.trim}=${value.trim}"`) makes the assembled pair carry no inner 
whitespace, so the exact-key stage sees the clean key. 
`Utils.redactCommandLineArgs` also assembles through `genKeyValuePair`, so the 
same fix closes the hole at both assembly points.
   
   ### How was this patch tested?
   
   Added `CommandUtilsSuite` cases: symmetric-trim assertions 
(`genKeyValuePair("abc ", " 123")` -> `"abc=123"`, including a tab) and a 
redaction round-trip that assembles a spaced Data Agent api-key argument and 
asserts `redactConfValues` masks it. Both fail on the old `.trim`.
   
   ```
   build/mvn test -pl kyuubi-util-scala -am
   build/mvn scalastyle:check spotless:check -pl kyuubi-util-scala -am
   build/mvn test -pl kyuubi-common -am 
-DwildcardSuites=org.apache.kyuubi.UtilsSuite
   ```
   
   `kyuubi-util-scala` green on Zulu 17.0.18 (22/22), scalastyle 0 errors, 
spotless clean; `kyuubi-common` `UtilsSuite` (which exercises 
`redactCommandLineArgs`) 14/14.
   
   ### Was this patch assisted by generative AI tooling?
   
   Assisted-by: Claude Opus 4.8
   


-- 
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]

Reply via email to