Skip to content

[SPARK-22860] [SPARK-24621] [Core] [WebUI] - hide key password from linux ps listing and masterwebui point to https if ssl enabled - #21514

Closed
tooptoop4 wants to merge 7 commits into
apache:masterfrom
tooptoop4:spark22860
Closed

[SPARK-22860] [SPARK-24621] [Core] [WebUI] - hide key password from linux ps listing and masterwebui point to https if ssl enabled#21514
tooptoop4 wants to merge 7 commits into
apache:masterfrom
tooptoop4:spark22860

Conversation

@tooptoop4

@tooptoop4tooptoop4 commented Jun 8, 2018

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

hide password from 'ps' linux command
AND
masterwebui point to https if ssl enabled

How was this patch tested?

Existing tests

Please review http://spark.apache.org/contributing.html before opening a pull request.
The contribution is my own original work and I license the work to the project under the project’s open source license.

@pjfanning

Copy link
Copy Markdown
Member

Instead of filtering out the passwords, would it be more useful to blank the passwords or replace them with ****** in the output?

@tooptoop4

Copy link
Copy Markdown
ContributorAuthor

I just went through the process of getting 'security approval' in my organisation to use Spark in Production. They ran a Qualsys Vulnerability Assessment scanner that among other things picked up a vulnerability called 'presence of string keyStorePassword in process list' so the scan would still fail if the string keyStorePassword appeared at all.

@tooptoop4

tooptoop4 commented Jun 9, 2018

Copy link
Copy Markdown
ContributorAuthor

@cloud-fan can u commit?

@jiangxb1987

Copy link
Copy Markdown
Contributor

Have you tried the config "spark.redaction.regex" ?

val javaOpts = sparkJavaOpts ++ extraJavaOpts
val command = Command("org.apache.spark.executor.CoarseGrainedExecutorBackend",
args, sc.executorEnvs, classPathEntries ++ testingClassPath, libraryPathEntries, javaOpts)
args, sc.executorEnvs, classPathEntries ++ testingClassPath, libraryPathEntries, javaOpts.filterNot(_.startsWith("-Dspark.ssl.keyStorePassword")).filterNot(_.startsWith("-Dspark.ssl.keyPassword")))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you really have to do this, I'd have:

javaOpts.filterNot { opt =>
opt.startsWith("-Dspark.ssl.keyStorePassword") || opt.startsWith("-Dspark.ssl.keyPassword")
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about *storePassword?

Actually I'm thinking of using Hadoop credential provider to store password (https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-common/CredentialProviderAPI.html) to avoid plaintext password. I have a local PR for this.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does your PR still end up having the literal 'storePassword' in ps output?

@maropu

Copy link
Copy Markdown
Member

Is this only the place where we need to hide the password? e.g., how about logging about properties in SparkSubmitArguments

@tooptoop4tooptoop4 changed the title [SPARK-22860] [Core] - hide key password from linux ps listing[SPARK-22860] [SPARK-24621] [Core] [WebUI] - hide key password from linux ps listing and masterwebui point to https if ssl enabledJun 30, 2018

@mgaido91mgaido91 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add UTs for your changes? Or at least post some pictures with your tests of the changes?

val SSL_ENABLED = conf.getBoolean("spark.ssl.enabled", false)
val uriScheme = "http://"
if (SSL_ENABLED) {
uriScheme = "https://"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you tested this? This is a val, I doubt this can even compile...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you try this? It's a bit closer to the usual scala style.

 val uriScheme = if (conf.getBoolean("spark.ssl.enabled", false)) "https://" else "http://"

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woops, i just updated val to var

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but still please add tests for this, in order to enforce the correctness of your solution. PS I agree with @pjfanning's suggestion..

uriScheme = "https://"
}
masterWebUiUrl = uriScheme + masterPublicAddress + ":" + webUi.boundPort
//masterWebUiUrl = "http://" + masterPublicAddress + ":" + webUi.boundPort

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove this comment

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update in latest commit

@HyukjinKwon

Copy link
Copy Markdown
Member

ok to test

@SparkQA

Copy link
Copy Markdown

Test build #93065 has finished for PR 21514 at commit 825380a.

  • This patch fails Scala style tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@tooptoop4

Copy link
Copy Markdown
ContributorAuthor

ok to test

@tooptoop4

Copy link
Copy Markdown
ContributorAuthor

@HyukjinKwon can u commit this? i fixed the Scala style

@mgaido91mgaido91 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please if you cannot add UT, at least provide some pictures showing the behavior before and after your PR.

webUi.bind()
masterWebUiUrl = "http://" + masterPublicAddress + ":" + webUi.boundPort
val SSL_ENABLED = conf.getBoolean("spark.ssl.enabled", false)
var uriScheme = "http://"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be:

val uriScheme = if (SSL_ENABLED) { "https://" } else { "http://" }

@SparkQA

Copy link
Copy Markdown

Test build #93104 has finished for PR 21514 at commit 050b226.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@tooptoop4

Copy link
Copy Markdown
ContributorAuthor

ok to test

@SparkQA

Copy link
Copy Markdown

Test build #93142 has finished for PR 21514 at commit bc8a833.

  • This patch fails Scala style tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

val javaOpts = sparkJavaOpts ++ extraJavaOpts
val command = Command("org.apache.spark.executor.CoarseGrainedExecutorBackend",
args, sc.executorEnvs, classPathEntries ++ testingClassPath, libraryPathEntries, javaOpts)
args, sc.executorEnvs, classPathEntries ++ testingClassPath, libraryPathEntries

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please put the comma at the end of this line instead of the beginning of the next one.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

val command = Command("org.apache.spark.executor.CoarseGrainedExecutorBackend",
args, sc.executorEnvs, classPathEntries ++ testingClassPath, libraryPathEntries, javaOpts)
args, sc.executorEnvs, classPathEntries ++ testingClassPath, libraryPathEntries
, javaOpts.filterNot { opt =>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't put long code inline to function argument usually. Please move this before and store it to a local val used here.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
}

test("SPARK-24621 https urls when ssl enabled") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we usually put a : after the JIRA number, eg. SPARK-24621:

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@tooptoop4

Copy link
Copy Markdown
ContributorAuthor

@mgaido91 - do you know what caused this?
Scalastyle checks failed at following occurrences:
[error] /home/jenkins/workspace/SparkPullRequestBuilder@2/core/src/test/scala/org/apache/spark/deploy/master/MasterSuite.scala: Expected token RPAREN but got Token(RBRACE,},10480,})

@mgaido91

Copy link
Copy Markdown
Contributor

@tooptoop4 the only thing I can see is that you are suing ' instead of " for string. Anyway you can run the scala linter on your local machine too and you can check which part of the code you added to the MasterSuite file causes the failure

@tooptoop4

Copy link
Copy Markdown
ContributorAuthor

ok to test

@SparkQA

Copy link
Copy Markdown

Test build #93166 has finished for PR 21514 at commit 39bb2a0.

  • This patch fails Scala style tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

val command = Command("org.apache.spark.executor.CoarseGrainedExecutorBackend",
args, sc.executorEnvs, classPathEntries ++ testingClassPath, libraryPathEntries, javaOpts)
val javaOptsFiltered = javaOpts.filterNot { opt =>
opt.startsWith("-Dspark.ssl.keyStorePassword") || opt.startsWith("-Dspark.ssl.keyPassword")}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong indentation. This should look like:

val javaOptsFiltered = javaOpts.filterNot { opt =>
opt.startsWith("-Dspark.ssl.keyStorePassword") || opt.startsWith("-Dspark.ssl.keyPassword")
}

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

webUi = new MasterWebUI(this, webUiPort)
webUi.bind()
masterWebUiUrl = "http://" + masterPublicAddress + ":" + webUi.boundPort
val SSL_ENABLED = conf.getBoolean("spark.ssl.enabled", false)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: rename to sslEnabled

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@tooptoop4

Copy link
Copy Markdown
ContributorAuthor

ok to test

@SparkQA

Copy link
Copy Markdown

Test build #93172 has finished for PR 21514 at commit d4de123.

  • This patch fails Scala style tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

val command = Command("org.apache.spark.executor.CoarseGrainedExecutorBackend",
args, sc.executorEnvs, classPathEntries ++ testingClassPath, libraryPathEntries, javaOpts)
val javaOptsFiltered = javaOpts.filterNot { opt =>
opt.startsWith("-Dspark.ssl.keyStorePassword") || opt.startsWith("-Dspark.ssl.keyPassword")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong indentation: missing 2 spaces.

@mgaido91mgaido91 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some other comments. Please verify locally and fix the scala style error. You can run the linter also locally. Thanks.

opt.startsWith("-Dspark.ssl.keyStorePassword") || opt.startsWith("-Dspark.ssl.keyPassword")
}
val command = Command("org.apache.spark.executor.CoarseGrainedExecutorBackend", args,
sc.executorEnvs, classPathEntries ++ testingClassPath, libraryPathEntries, javaOptsFiltered)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong indentation here too, missing 2 spaces. Moreover, in such cases, we usually put one argument per line, so:

val command = Command("org.apache.spark.executor.CoarseGrainedExecutorBackend",
args,
sc.executorEnvs,
...)

eventually(timeout(5 seconds), interval(100 milliseconds)) {
val json = Source.fromURL(s"https://localhost:${localCluster.masterWebUIPort}/json")
.getLines().mkString("\n")
assert(json.contains('<a href="https://'))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

" instead of '

eventually(timeout(5 seconds), interval(100 milliseconds)) {
val json = Source.fromURL(s"http://localhost:${localCluster.masterWebUIPort}/json")
.getLines().mkString("\n")
assert(!json.contains('<a href="https://'))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@HyukjinKwon

Copy link
Copy Markdown
Member

ping @tooptoop4

@HyukjinKwon

Copy link
Copy Markdown
Member

I'm going to suggest to close this. The review comments were not addressed more then few months and there's not quite a great point to keep inactive PRs.

Feel free to take over this if any of you here is interested in this. Or @tooptoop4, please recreate a PR after addressing review commnets here.

Thanks.

@HyukjinKwonHyukjinKwon mentioned this pull request Nov 11, 2018
zifeif2 pushed a commit to zifeif2/spark that referenced this pull request Nov 22, 2025
Closesapache#21766Closesapache#21679Closesapache#21161Closesapache#20846Closesapache#19434Closesapache#18080Closesapache#17648Closesapache#17169
Add:
Closesapache#22813Closesapache#21994Closesapache#22005Closesapache#22463
Add:
Closesapache#15899
Add:
Closesapache#22539Closesapache#21868Closesapache#21514Closesapache#21402Closesapache#21322Closesapache#21257Closesapache#20163Closesapache#19691Closesapache#18697Closesapache#18636Closesapache#17176Closesapache#23001 from wangyum/CloseStalePRs.
Authored-by: Yuming Wang <yumwang@ebay.com>
Signed-off-by: hyukjinkwon <gurwls223@apache.org>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@tooptoop4@pjfanning@jiangxb1987@maropu@HyukjinKwon@SparkQA@mgaido91@jerryshao