Skip to content
This repository has been archived by the owner on Nov 5, 2022. It is now read-only.

Mixing trusted & untrusted code in one CPS session #36

Merged
merged 4 commits into from Jul 29, 2016
Merged

Conversation

kohsuke
Copy link
Contributor

@kohsuke kohsuke commented Jul 22, 2016

See doc/sandbox.md for the explanation of what this does.

@reviewbybees

See doc/sandbox.md for the explanation of this change.

Previously, whether to sandbox or not was a decision made at the point
of thread creation, which made it impossible to mix trusted code &
untrusted code in single program.

This change fixes that by making this decision at the call site level.
In Jenkins, this enables plugins to package Groovy code that gets
CPS-transformed but runs outside sandbox.

Attention was paid to preserve backward compatibility with the persisted
form of the program, which is translated without any trusted/untrusted
call site tags.
@kohsuke kohsuke changed the title Call site tag Mixing trusted & untrusted code in one CPS session Jul 22, 2016
@jglick
Copy link
Member

jglick commented Jul 25, 2016

Without a downstream PR it is unclear what this is for. Would it allow JENKINS-34650 to be solved, as per jenkinsci/workflow-cps-global-lib-plugin#2?

@kohsuke
Copy link
Contributor Author

kohsuke commented Jul 25, 2016

You are right that this needs some downstream PR before concluding. That said, this change is ready to be looked at.

I was doing this to enable plugins that are written in Groovy that are CPS transformed, in the context of a joint PoC effort with @abayer.

I think JENKINS-34650 is a good user visible feature out of this change. I'll work on it.

@abayer
Copy link
Contributor

abayer commented Jul 28, 2016

🐝

or the invocation should be always allowed to happen (trusted.)

The call site tagging mechanism itself is more general, so it can be used for other purposes,
for example to record where it came from, etc.
Copy link
Member

Choose a reason for hiding this comment

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

So it could at some point be used to record a CodeSource, for example?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right

@jglick
Copy link
Member

jglick commented Jul 29, 2016

🐝

@kohsuke kohsuke merged commit 5539bb7 into master Jul 29, 2016
@kohsuke kohsuke deleted the call-site-tag branch July 29, 2016 19:20
@@ -240,7 +240,7 @@ class CpsTransformer extends CompilationCustomizer implements GroovyCodeVisitor
/**
* {@link Trusted} or {@link Untrusted} tag that gets added to call site.
*
* @see 'doc/sandbox.md'
* @see "doc/sandbox.md"
Copy link
Member

Choose a reason for hiding this comment

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

This is not correct either AFAIK.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants