readJSON in sanboxed DSL withouth approval

1,156 views
Skip to first unread message

Kamil Demecki

unread,
Oct 12, 2018, 8:56:58 AM10/12/18
to job-dsl-plugin
Hi,

I cannot find how to parse json in sandboxed DSL script.

I have used groovy.json.JsonSlurper().parse but I need to port DSL script to Jenkins instance with security enabled for DSL and so can call only whitelisted methods.

I thought about using pipeline-utility-steps plugin. I am able to call readJSON in Jenkins pipeline script running inside sandbox (pipeline script - not DSL script)

Is there a way to call readJSON from pipeline-utility-steps plugin in DSL script or other way to parse JSON in sandbox without need for manual approval?

Regards

Kamil

Chris Williamson

unread,
Oct 12, 2018, 10:54:42 AM10/12/18
to job-dsl...@googlegroups.com
Try using JsonSlurperClassic instead of JsonSlurper

--
You received this message because you are subscribed to the Google Groups "job-dsl-plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to job-dsl-plugi...@googlegroups.com.
To post to this group, send email to job-dsl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/job-dsl-plugin/66daab97-8089-4be4-8161-288c5e0509cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Marasco, Aaron

unread,
Oct 15, 2018, 7:18:49 AM10/15/18
to job-dsl-plugin

I don't see anything on my "script approval" page implying I did anything special to allow this:


import groovy.json.JsonSlurper

def final BUILT_AREA = WORKSPACE + "/testing_support/built_area/"

def final job2_config = new JsonSlurper().parseText(readFileFromWorkspace("${BUILT_AREA}/.jenkins_metadata_job2.json"))





From: job-dsl...@googlegroups.com <job-dsl...@googlegroups.com> on behalf of Kamil Demecki <kods...@gmail.com>
Sent: Friday, October 12, 2018 08:56
To: job-dsl-plugin
Subject: readJSON in sanboxed DSL withouth approval
 

Kamil Demecki

unread,
Oct 17, 2018, 5:33:55 AM10/17/18
to job-dsl-plugin
Right. I was posting question few days after getting failure and by mistake pointed JsonSlurper instead of JsonSlurperClassic because my pipeline used both.

I checked that again on latest Jenkins and indeed JsonSlurper is allowed but JsonSlurperClassic not.

# OK
new groovy.json.JsonSlurper().parseText('{"name": "value"}')

# ERROR: Scripts not permitted to use new groovy.json.JsonSlurperClassic
new groovy.json.JsonSlurperClassic().parseText('{"name": "value"}')

Thanks!

Kamil





On Monday, 15 October 2018 13:18:49 UTC+2, Marasco, Aaron wrote:

I don't see anything on my "script approval" page implying I did anything special to allow this:


import groovy.json.JsonSlurper

def final BUILT_AREA = WORKSPACE + "/testing_support/built_area/"

def final job2_config = new JsonSlurper().parseText(readFileFromWorkspace("${BUILT_AREA}/.jenkins_metadata_job2.json"))





From: job-dsl...@googlegroups.com <job-dsl...@googlegroups.com> on behalf of Kamil Demecki <kods...@gmail.com>
Sent: Friday, October 12, 2018 08:56
To: job-dsl-plugin
Subject: readJSON in sanboxed DSL withouth approval
 
Hi,

I cannot find how to parse json in sandboxed DSL script.

I have used groovy.json.JsonSlurper().parse but I need to port DSL script to Jenkins instance with security enabled for DSL and so can call only whitelisted methods.

I thought about using pipeline-utility-steps plugin. I am able to call readJSON in Jenkins pipeline script running inside sandbox (pipeline script - not DSL script)

Is there a way to call readJSON from pipeline-utility-steps plugin in DSL script or other way to parse JSON in sandbox without need for manual approval?

Regards

Kamil

--
You received this message because you are subscribed to the Google Groups "job-dsl-plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to job-dsl-plug...@googlegroups.com.
To post to this group, send email to job-ds...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages