https://kotlinlang.org logo
#feed
Title
a

apatrida

11/21/2017, 12:52 AM
cross-post from #scripting I just put out BETA of a bunch of libs around, I'll start to do docs and samples now but worked out all the kinks. * Elasticsearch-lang-kotlin: Kotlin text scripting in Elasticsearch, and also the ability to send Kotlin Lambdas as scripts as well. Why give up syntax highlighting and help from our IDE's! -- https://github.com/kohesive/elasticsearch-lang-kotlin * Cuarentena: secure scripting (validate script or binary lambda against a whitelist of allowed accesses down to method level, matching Painless scripting rules from Elasticsearch but can apply elsewhere) -- https://github.com/kohesive/cuarentena * Chillambda: convert a lambda into a script (base64 encoded version that you can send somewhere to run using Cuarentena to validate the security rules are not violated, also handles safe ser/deser of the lambda to prevent attacks there as well) -- https://github.com/kohesive/chillambda * Keplin: shrunk down just to be less things, some slightly easier way of using Kotlin REPLs and scripting, but I would like to deprecate more here and just end up flat on the core from Kotlin. So expect this to shrink, and only be secure scripting hooks into Kotlin scripting with Cuarentena -- https://github.com/kohesive/keplin These are finally working and distributable, but need time to bake, samples written, docs, ... so be gentle to them. From here, I would like to get Kotlin scripting into other engines that make sense. But I'll let the details work out with this set first to find the kinks, close any holes, etc. I also have to update to other versions of Elasticsearch, including big changes in 6.x series.
👍 13
d

dave08

11/21/2017, 3:30 AM
Now if someone would only replace Groovy scripting w/ Kotlin scripting in Jenkins Pipeline... ! 😄
m

marcinmoskala

11/21/2017, 6:47 AM
@aparkitny I am really interested in chillambda. Do you have any usage example?
a

apatrida

11/25/2017, 9:58 PM
@dave08 that's a thought!
@marcinmoskala you sent that to the wrong person, but yes there is an example of it being used in the elasticsearch plugin, serializing a lambda to base64: https://github.com/kohesive/elasticsearch-lang-kotlin/blob/master/elasticsearch-lang-kotlin-client/src/main/kotlin/uy/kohesive/elasticsearch/kotlinscript/client/ScriptExtensions.kt#L12
You create your own script template for whatever receiver you want to use. This one uses one specific to elasticsearch but you can just change it to any abstract base class. The configuration for Cuarentena used in this case, as well as Chillambda is: https://github.com/kohesive/elasticsearch-lang-kotlin/blob/master/elasticsearch-lang-kotlin-common/src/main/kotlin/uy/kohesive/elasticsearch/kotlinscript/common/ConfiguredChillambda.kt
I'll add a full example to Chillambda soon. but you have all the parts there, it isn't much code to use it.
d

dave08

11/26/2017, 12:38 PM
Interesting... I guess there might be some hope, but to get a plugin like this to might be quite a bit of work! 🙂
4 Views