Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bowenliang123 committed Nov 29, 2023
1 parent 83f0ca1 commit a445016
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
31 changes: 17 additions & 14 deletions kyuubi-common/src/main/scala/org/apache/kyuubi/Utils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -338,20 +338,23 @@ object Utils extends Logging {
}

def redactCommandLineArgs(conf: KyuubiConf, commands: Iterable[String]): Iterable[String] = {
val redactionPattern = conf.get(SERVER_SECRET_REDACTION_PATTERN)
var nextKV = false
commands.map {
case PATTERN_FOR_KEY_VALUE_ARG(key, value) if nextKV =>
val (_, newValue) = redact(redactionPattern, Seq((key, value))).head
nextKV = false
genKeyValuePair(key, newValue)

case cmd if cmd == CONF =>
nextKV = true
cmd

case cmd =>
cmd
conf.get(SERVER_SECRET_REDACTION_PATTERN) match {
case Some(redactionPattern) =>
var nextKV = false
commands.map {
case PATTERN_FOR_KEY_VALUE_ARG(key, value) if nextKV =>
val (_, newValue) = redact(redactionPattern, Seq((key, value))).head
nextKV = false
genKeyValuePair(key, newValue)

case cmd if cmd == CONF =>
nextKV = true
cmd

case cmd =>
cmd
}
case _ => commands
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ object CommandLineUtils {
* and redact the value with the replacement text if keys are contained in given config keys
*/
def redactConfValues(
configs: Iterable[String],
commands: Iterable[String],
redactKeys: Iterable[String]): Iterable[String] = {
redactKeys.toSet match {
case redactKeySet if redactKeySet.isEmpty => configs
case redactKeySet => configs.map {
case redactKeySet if redactKeySet.isEmpty => commands
case redactKeySet => commands.map {
case PATTERN_FOR_KEY_VALUE_ARG(key, _) if redactKeySet.contains(key) =>
genKeyValuePair(key, REDACTION_REPLACEMENT_TEXT)
case arg => arg
case part => part
}
}
}
Expand Down

0 comments on commit a445016

Please sign in to comment.