Skip to content

Commit 40f7e0d

Browse files
authored
Merge pull request #25 from riptano/DSP-19490-dse-2.2
Dsp 19490 dse 2.2
2 parents 0b9d55c + 9989908 commit 40f7e0d

File tree

4 files changed

+47
-6
lines changed

4 files changed

+47
-6
lines changed

bin/server_package.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,16 @@ else
3535
echo "Please specify SCALA_VERSION in ${configFile}"
3636
exit 1
3737
fi
38+
39+
if [ -z "${SBT_BIN}" ]; then
40+
export SBT_BIN="sbt"
41+
fi
3842
set -u
3943

4044
echo "Packaging job-server for environment ${ENV}..."
4145

4246
pushd "${bin}/.." > /dev/null
43-
if ! sbt ++"${SCALA_VERSION}" job-server-extras/assembly; then
47+
if ! "$SBT_BIN" ++"${SCALA_VERSION}" job-server-extras/assembly; then
4448
echo "Assembly failed"
4549
exit 1
4650
fi

job-server/src/main/scala/spark/jobserver/JobServer.scala

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory
1212
import scala.collection.JavaConverters._
1313
import scala.concurrent.{Await, ExecutionContext}
1414
import scala.concurrent.duration._
15+
import scala.util.matching.Regex
1516
import scala.util.Try
1617

1718
/**
@@ -32,6 +33,9 @@ import scala.util.Try
3233
*/
3334
object JobServer {
3435
val logger = LoggerFactory.getLogger(getClass)
36+
final val DEFAULT_CREDENTIAL_PATTERN = "(?i)credentials|secret|password|token"
37+
final val EMPTY_VALUE_PATTERN = "\"\",?".r
38+
final val REDACTION_REPLACEMENT_TEXT = " \"*********(redacted)\""
3539

3640
class InvalidConfiguration(error: String) extends RuntimeException(error)
3741

@@ -49,8 +53,12 @@ object JobServer {
4953
} else {
5054
defaultConfig
5155
}
52-
logger.info("Starting JobServer with config {}", config.getConfig("spark").root.render())
53-
logger.info("Spray config: {}", config.getConfig("spray.can.server").root.render())
56+
57+
val credentialPattern = credentialRegex(config)
58+
val sparkConfig = config.getConfig("spark").root.render()
59+
logger.info("Starting JobServer with config {}", maskCredentials(sparkConfig, credentialPattern))
60+
val sprayConfig = config.getConfig("spray.can.server").root.render()
61+
logger.info("Spray config: {}", maskCredentials(sprayConfig, credentialPattern))
5462

5563
// TODO: Hardcode for now to get going. Make it configurable later.
5664
val system = makeSystem(config)
@@ -122,6 +130,35 @@ object JobServer {
122130
new WebApi(system, config, port, binManager, dataManager, supervisor, jobInfo).start()
123131
}
124132

133+
private def maskCredentials(lines: String, credentialRegex: Regex): String = {
134+
lines
135+
.split("\n")
136+
.toSeq
137+
.map {
138+
line => line.split(":") match {
139+
// if key matches credential keys pattern and value is not empty, mask credentials
140+
case Array(key, value) if (credentialRegex.findFirstIn(key).nonEmpty
141+
&& EMPTY_VALUE_PATTERN.findFirstIn(value.stripMargin).isEmpty) =>
142+
Array(key, REDACTION_REPLACEMENT_TEXT).mkString(":")
143+
case _ => line
144+
}
145+
}.mkString("\n")
146+
}
147+
148+
private def credentialRegex(config: Config): Regex = {
149+
// Use default credential keys if spark.ui.confidentialKeys is not set
150+
val credentialPattern = try {
151+
config.getString("spark.redaction.regex")
152+
} catch {
153+
case _: Exception =>
154+
logger.info(s"spark.redaction.regex is not set, " +
155+
s"use default credential pattern $DEFAULT_CREDENTIAL_PATTERN")
156+
DEFAULT_CREDENTIAL_PATTERN
157+
}
158+
159+
credentialPattern.r
160+
}
161+
125162
private def parseInitialBinaryConfig(key: String, config: Config): Map[String, String] = {
126163
if (config.hasPath(key)) {
127164
val initialJarsConfig = config.getConfig(key).root

project/Dependencies.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ object Dependencies {
8989
lazy val apiDeps = sparkDeps ++ miscDeps :+ typeSafeConfigDeps :+ scalaTestDep
9090

9191
val repos = Seq(
92-
"datastax-release" at "http://datastax.artifactoryonline.com/datastax/datastax-releases-local",
92+
"datastax-release" at "https://repo.sjc.dsinternal.org/artifactory/datastax-releases-local",
9393
"Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/",
9494
"sonatype snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/",
9595
"spray repo" at "http://repo.spray.io"

project/Versions.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import scala.util.Properties.isJavaAtLeast
22

33
object Versions {
4-
lazy val spark = sys.env.getOrElse("SPARK_VERSION", "2.2.0.6")
4+
lazy val spark = sys.env.getOrElse("SPARK_VERSION", "2.2.3.4")
55

66
lazy val akka = "2.4.9"
77
lazy val dseDriver = "1.6.2"
@@ -27,5 +27,5 @@ object Versions {
2727
lazy val spray = "1.3.3"
2828
lazy val sprayJson = "1.3.2"
2929
lazy val typeSafeConfig = if (isJavaAtLeast("1.8")) "1.3.0" else "1.2.1"
30-
lazy val cassandraConnector = "6.0.0-6aa37a9"
30+
lazy val cassandraConnector = "6.0.9"
3131
}

0 commit comments

Comments
 (0)