Skip to content

Conversation

@tooptoop4
Copy link
Contributor

@tooptoop4 tooptoop4 commented Jun 8, 2018

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
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
Contributor Author

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
Copy link
Contributor Author

tooptoop4 commented Jun 9, 2018

@cloud-fan can u commit?

@jiangxb1987
Copy link
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
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
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
Contributor Author

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
Member

maropu commented Jun 18, 2018

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

@tooptoop4 tooptoop4 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 enabled Jun 30, 2018
Copy link
Contributor

@mgaido91 mgaido91 left a comment

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
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
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
Contributor Author

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
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
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
Contributor Author

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
Member

ok to test

@SparkQA
Copy link

SparkQA commented Jul 16, 2018

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
Contributor Author

ok to test

@tooptoop4
Copy link
Contributor Author

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

Copy link
Contributor

@mgaido91 mgaido91 left a comment

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
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

SparkQA commented Jul 16, 2018

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
Contributor Author

ok to test

@SparkQA
Copy link

SparkQA commented Jul 16, 2018

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
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
Contributor Author

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
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
Contributor Author

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
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
Contributor Author

Choose a reason for hiding this comment

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

done

@tooptoop4
Copy link
Contributor Author

@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
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
Contributor Author

ok to test

@SparkQA
Copy link

SparkQA commented Jul 17, 2018

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
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
Contributor Author

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
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
Contributor Author

Choose a reason for hiding this comment

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

done

@tooptoop4
Copy link
Contributor Author

ok to test

@SparkQA
Copy link

SparkQA commented Jul 17, 2018

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
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.

Copy link
Contributor

@mgaido91 mgaido91 left a comment

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
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
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
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
Member

ping @tooptoop4

@HyukjinKwon
Copy link
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.

@asfgit asfgit closed this in a3ba3a8 Nov 11, 2018
zifeif2 pushed a commit to zifeif2/spark that referenced this pull request Nov 22, 2025
Closes apache#21766
Closes apache#21679
Closes apache#21161
Closes apache#20846
Closes apache#19434
Closes apache#18080
Closes apache#17648
Closes apache#17169

Add:
Closes apache#22813
Closes apache#21994
Closes apache#22005
Closes apache#22463

Add:
Closes apache#15899

Add:
Closes apache#22539
Closes apache#21868
Closes apache#21514
Closes apache#21402
Closes apache#21322
Closes apache#21257
Closes apache#20163
Closes apache#19691
Closes apache#18697
Closes apache#18636
Closes apache#17176

Closes apache#23001 from wangyum/CloseStalePRs.

Authored-by: Yuming Wang <yumwang@ebay.com>
Signed-off-by: hyukjinkwon <gurwls223@apache.org>
Sign up for free to 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