-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-18535][UI][YARN] Redact sensitive information from Spark logs and UI #15971
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 7 commits
5dd3630
b0ad319
78e4398
eed33db
84a7ef3
549881b
61a961c
49015ac
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 |
|---|---|---|
|
|
@@ -55,7 +55,7 @@ import org.slf4j.Logger | |
| import org.apache.spark._ | ||
| import org.apache.spark.deploy.SparkHadoopUtil | ||
| import org.apache.spark.internal.Logging | ||
| import org.apache.spark.internal.config.{DYN_ALLOCATION_INITIAL_EXECUTORS, DYN_ALLOCATION_MIN_EXECUTORS, EXECUTOR_INSTANCES} | ||
| import org.apache.spark.internal.config._ | ||
| import org.apache.spark.network.util.JavaUtils | ||
| import org.apache.spark.serializer.{DeserializationStream, SerializationStream, SerializerInstance} | ||
| import org.apache.spark.util.logging.RollingFileAppender | ||
|
|
@@ -2555,6 +2555,18 @@ private[spark] object Utils extends Logging { | |
| sparkJars.map(_.split(",")).map(_.filter(_.nonEmpty)).toSeq.flatten | ||
| } | ||
| } | ||
|
|
||
| private[util] val REDACTION_REPLACEMENT_TEXT = "*********(redacted)" | ||
|
|
||
| def redact(conf: SparkConf, kvs: Seq[(String, String)]): Seq[(String, String)] = { | ||
| val redactionPattern = conf.get(SECRET_REDACTION_PATTERN).r | ||
|
Contributor
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. This is very expensive. How about a version that takes a list of tuples and redacts them?
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. What part do you think is expensive? Going through all the configuration properties and matching them with the regex?
Contributor
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. Compiling the regex once for every item in the list being redacted, instead of doing it once for the whole list.
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. Ah, good point. Let me fix this. |
||
| kvs.map { kv => | ||
| redactionPattern.findFirstIn(kv._1) | ||
| .map { ignore => (kv._1, REDACTION_REPLACEMENT_TEXT) } | ||
| .getOrElse(kv) | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
| private[util] object CallerContext extends Logging { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,6 +95,18 @@ class EventLoggingListenerSuite extends SparkFunSuite with LocalSparkContext wit | |
| } | ||
| } | ||
|
|
||
| test("Event logging with password redaction") { | ||
| val key = "spark.executorEnv.HADOOP_CREDSTORE_PASSWORD" | ||
| val secretPassword = "secret_password" | ||
| val conf = getLoggingConf(testDirPath, None) | ||
| .set(key, secretPassword) | ||
| val eventLogger = new EventLoggingListener("test", None, testDirPath.toUri(), conf) | ||
| val envDetails = SparkEnv.environmentDetails(conf, "FIFO", Seq.empty, Seq.empty) | ||
| val event = SparkListenerEnvironmentUpdate(envDetails) | ||
| val redactedProps = eventLogger.redactEvent(event).environmentDetails("Spark Properties").toMap | ||
|
Contributor
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. "Spark Properties" is begging to be turned into a constant somewhere... |
||
| assert(redactedProps(key) == "*********(redacted)") | ||
| } | ||
|
|
||
| test("Log overwriting") { | ||
| val logUri = EventLoggingListener.getLogPath(testDir.toURI, "test", None) | ||
| val logPath = new URI(logUri).getPath | ||
|
|
||
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.
nit: this needs to be indented one more level...
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, I'll go through Spark style guide so I don't cause as much trouble next time.
Thanks for reviewing.