-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-19720][CORE] Redact sensitive information from SparkSubmit console #17047
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,7 @@ import scala.io.Source | |
| import scala.reflect.ClassTag | ||
| import scala.util.Try | ||
| import scala.util.control.{ControlThrowable, NonFatal} | ||
| import scala.util.matching.Regex | ||
|
|
||
| import _root_.io.netty.channel.unix.Errors.NativeIoException | ||
| import com.google.common.cache.{CacheBuilder, CacheLoader, LoadingCache} | ||
|
|
@@ -2574,13 +2575,28 @@ private[spark] object Utils extends Logging { | |
|
|
||
| def redact(conf: SparkConf, kvs: Seq[(String, String)]): Seq[(String, String)] = { | ||
| val redactionPattern = conf.get(SECRET_REDACTION_PATTERN).r | ||
| redact(redactionPattern, kvs) | ||
| } | ||
|
|
||
| private def redact(redactionPattern: Regex, kvs: Seq[(String, String)]): Seq[(String, String)] = { | ||
| kvs.map { kv => | ||
| redactionPattern.findFirstIn(kv._1) | ||
| .map { ignore => (kv._1, REDACTION_REPLACEMENT_TEXT) } | ||
|
||
| .getOrElse(kv) | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Looks up the redaction regex from within the key value pairs and uses it to redact the rest | ||
| * of the key value pairs. No care is taken to make sure the redaction property itself is not | ||
| * redacted. So theoretically, the property itself could be configured to redact its own value | ||
| * when printing. | ||
| */ | ||
| def redact(kvs: Map[String, String]): Seq[(String, String)] = { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Nit: I'd omit param and return if they're not filled in.)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct, that's exactly the use case - where there isn't a conf object available yet. I will update the Javadoc. Thanks for reviewing! |
||
| val redactionPattern = kvs.getOrElse(SECRET_REDACTION_PROPERTY, SECRET_REDACTION_DEFAULT).r | ||
| redact(redactionPattern, kvs.toArray) | ||
| } | ||
|
|
||
| } | ||
|
|
||
| private[util] object CallerContext extends Logging { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, instead of this you could use
SECRET_REDACTION_PATTERN.keyandSECRET_REDACTION_PATTERN.defaultValueinUtils.scala.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @vanzin Updated.