Skip to content

Commit efaa62c

Browse files
committed
Merge branch 'master' into post-SECURITY-359
2 parents faa94c1 + 3a59e40 commit efaa62c

File tree

121 files changed

+2397
-1112
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+2397
-1112
lines changed

.github/dependabot.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ updates:
99
directory: "/"
1010
schedule:
1111
interval: "weekly"
12+
ignore:
13+
- dependency-name: org.codehaus.groovy:groovy
1214
- package-ecosystem: "github-actions"
1315
directory: "/"
1416
schedule:
1517
interval: "weekly"
1618
- package-ecosystem: "npm"
17-
directory: "/"
19+
directory: "/plugin"
1820
schedule:
1921
interval: "weekly"

.mvn/extensions.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
<extension>
33
<groupId>io.jenkins.tools.incrementals</groupId>
44
<artifactId>git-changelist-maven-extension</artifactId>
5-
<version>1.4</version>
5+
<version>1.7</version>
66
</extension>
77
</extensions>

Jenkinsfile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
buildPlugin(useContainerAgent: true, configurations: [
2-
[ platform: "windows", jdk: "11" ],
3-
[ platform: "linux", jdk: "11" ]
1+
/*
2+
See the documentation for more options:
3+
4+
https://github.com/jenkins-infra/pipeline-library/
5+
6+
*/
7+
buildPlugin(
8+
useContainerAgent: true, // Set to `false` if you need to use Docker for containerized tests
9+
configurations: [
10+
[platform: 'linux', jdk: 21],
11+
[platform: 'windows', jdk: 17],
412
])

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,8 @@ The executor widget only displays an entry for the “flyweight” executor on t
7878
* [Continuation, Next, and Env](doc/cps-model.md) and how we interpret Groovy program
7979
* [How interpreted program is represented](doc/block-tree.md)
8080
* [CPS + Sandbox](doc/sandbox.md)
81+
82+
## Development
83+
84+
When developing the editor, edit `plugin/package.json` to set `mvnbuild` to `yarn dev` instead of `yarn prod`.
85+
This will allow you to do in situ debugging of JavaScript in your browser.

dgm-builder/pom.xml

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@
2121
</license>
2222
</licenses>
2323

24-
<properties>
25-
<maven.compiler.release>11</maven.compiler.release>
26-
<maven.compiler.testRelease>11</maven.compiler.testRelease>
27-
<maven.deploy.skip>true</maven.deploy.skip>
28-
</properties>
29-
3024
<build>
3125
<plugins>
3226
<plugin>
@@ -55,12 +49,6 @@
5549
</build>
5650

5751
<dependencies>
58-
<dependency>
59-
<!-- TODO: Once we are ok limiting workflow-cps (and groovy-cps) to compile _and_ run only on Java 9+, we should delete this dependency and switch to javax.annotation.processing.Generated. -->
60-
<groupId>javax.annotation</groupId>
61-
<artifactId>javax.annotation-api</artifactId>
62-
<version>1.3.2</version>
63-
</dependency>
6452
<dependency>
6553
<groupId>org.kohsuke.codemodel</groupId>
6654
<artifactId>codemodel</artifactId>
@@ -69,7 +57,6 @@
6957
<dependency>
7058
<groupId>org.jenkins-ci.main</groupId>
7159
<artifactId>remoting</artifactId>
72-
<version>4.13.3</version>
7360
</dependency>
7461
<dependency>
7562
<groupId>org.codehaus.groovy</groupId>
@@ -83,19 +70,4 @@
8370
<version>${groovy.version}</version>
8471
</dependency>
8572
</dependencies>
86-
87-
<profiles>
88-
<profile>
89-
<id>skip-installation</id>
90-
<activation>
91-
<property>
92-
<name>set.changelist</name>
93-
<value>true</value>
94-
</property>
95-
</activation>
96-
<properties>
97-
<maven.install.skip>true</maven.install.skip>
98-
</properties>
99-
</profile>
100-
</profiles>
10173
</project>

dgm-builder/src/main/java/com/cloudbees/groovy/cps/tool/Driver.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@
1313
import java.io.File;
1414
import java.nio.charset.Charset;
1515
import java.nio.file.Files;
16-
import java.nio.file.Paths;
1716
import java.util.ArrayList;
18-
import java.util.Collections;
1917
import java.util.List;
2018
import java.util.Locale;
21-
22-
import static java.util.Arrays.*;
19+
import java.util.Set;
2320

2421
public class Driver {
2522
public static void main(String[] args) throws Exception {
@@ -32,18 +29,18 @@ public void run(File dir) throws Exception {
3229

3330
try (StandardJavaFileManager fileManager = javac.getStandardFileManager(errorListener, Locale.getDefault(), Charset.defaultCharset())) {
3431
fileManager.setLocation(StandardLocation.CLASS_PATH,
35-
Collections.singleton(Which.jarFile(GroovyShell.class)));
32+
Set.of(Which.jarFile(GroovyShell.class)));
3633

3734
File groovySrcJar = Which.jarFile(Driver.class.getClassLoader().getResource("groovy/lang/GroovyShell.java"));
3835

3936
// classes to translate
4037
// TODO include other classes mentioned in DefaultGroovyMethods.DGM_LIKE_CLASSES if they have any applicable methods
41-
List<String> fileNames = asList("DefaultGroovyMethods",
38+
List<String> fileNames = List.of("DefaultGroovyMethods",
4239
"DefaultGroovyStaticMethods",
4340
"StringGroovyMethods");
4441

4542
List<JavaFileObject> src = new ArrayList<>();
46-
for (JavaFileObject jfo : fileManager.list(StandardLocation.CLASS_PATH, "org.codehaus.groovy.runtime", Collections.singleton(JavaFileObject.Kind.SOURCE), true)) {
43+
for (JavaFileObject jfo : fileManager.list(StandardLocation.CLASS_PATH, "org.codehaus.groovy.runtime", Set.of(JavaFileObject.Kind.SOURCE), true)) {
4744
for (String name : fileNames) {
4845
if (jfo.toUri().toString().endsWith("/org/codehaus/groovy/runtime/" + name + ".java")) {
4946
src.add(jfo);
@@ -57,7 +54,7 @@ public void run(File dir) throws Exception {
5754
// Tree symbols created by the original JavacTask.parse() call to be thrown away,
5855
// which breaks later processing.
5956
// So for now, don't perform annotation processing
60-
List<String> options = asList("-proc:none");
57+
List<String> options = List.of("-proc:none");
6158

6259
Translator t = new Translator(javac.getTask(null, fileManager, errorListener, options, null, src));
6360

dgm-builder/src/main/java/com/cloudbees/groovy/cps/tool/Translator.java

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
import javax.lang.model.type.WildcardType;
7272
import javax.lang.model.util.ElementScanner7;
7373
import javax.lang.model.util.Elements;
74-
import javax.lang.model.util.SimpleTypeVisitor6;
74+
import javax.lang.model.util.SimpleTypeVisitor8;
7575
import javax.lang.model.util.Types;
7676
import javax.tools.JavaCompiler.CompilationTask;
7777
import java.io.BufferedReader;
@@ -90,7 +90,7 @@
9090
import java.util.Set;
9191
import java.util.TreeMap;
9292
import java.util.stream.Collectors;
93-
import javax.annotation.Generated;
93+
import javax.annotation.processing.Generated;
9494
import javax.lang.model.element.ElementKind;
9595
import javax.lang.model.element.Modifier;
9696

@@ -160,9 +160,7 @@ public Translator(CompilationTask task) throws IOException {
160160

161161
private String mangledName(ExecutableElement e) {
162162
StringBuilder overloadResolved = new StringBuilder("$").append(n(e));
163-
e.getParameters().forEach(ve -> {
164-
overloadResolved.append("__").append(types.erasure(ve.asType()).toString().replace("[]", "_array").replaceAll("[^\\p{javaJavaIdentifierPart}]+", "_"));
165-
});
163+
e.getParameters().forEach(ve -> overloadResolved.append("__").append(types.erasure(ve.asType()).toString().replace("[]", "_array").replaceAll("[^\\p{javaJavaIdentifierPart}]+", "_")));
166164
return overloadResolved.toString();
167165
}
168166

@@ -291,16 +289,14 @@ private void translateMethod(final CompilationUnitTree cut, ExecutableElement e,
291289
} else {
292290
delegating.body()._return(delegateCall);
293291
}
294-
delegatingParams.forEach(p -> delegateCall.arg(p));
292+
delegatingParams.forEach(delegateCall::arg);
295293

296294
JVar $b = m.body().decl($Builder, "b", JExpr._new($Builder).arg(JExpr.invoke("loc").arg(methodName)).
297295
invoke("contextualize").arg(codeModel.ref("com.cloudbees.groovy.cps.sandbox.Trusted").staticRef("INSTANCE")));
298296
JInvocation f = JExpr._new($CpsFunction);
299297

300298
// parameter names
301-
f.arg(codeModel.ref(Arrays.class).staticInvoke("asList").tap( inv -> {
302-
e.getParameters().forEach( p -> inv.arg(n(p)) );
303-
}));
299+
f.arg(codeModel.ref(Arrays.class).staticInvoke("asList").tap(inv -> e.getParameters().forEach(p -> inv.arg(n(p)) )));
304300

305301
// translate the method body into an expression that invokes Builder
306302
f.arg(trees.getTree(e).getBody().accept(new SimpleTreeVisitor<JExpression,Void>() {
@@ -380,7 +376,7 @@ public JExpression visitMethodInvocation(MethodInvocationTree mt, Void __) {
380376
).findAny();
381377
if (callSite.isPresent()) {
382378
ExecutableElement e = (ExecutableElement) callSite.get();
383-
if (e.getModifiers().contains(Modifier.PUBLIC) && !e.isVarArgs() && !e.getParameters().stream().anyMatch(p -> types.isAssignable(p.asType(), closureType))) {
379+
if (e.getModifiers().contains(Modifier.PUBLIC) && !e.isVarArgs() && e.getParameters().stream().noneMatch(p -> types.isAssignable(p.asType(), closureType))) {
384380
// Delegate to the standard version.
385381
inv = $b.invoke("staticCall")
386382
.arg(loc(mt))
@@ -577,9 +573,7 @@ public JExpression visitArrayType(ArrayTypeTree at, Void __) {
577573
@Override
578574
public JExpression visitNewArray(NewArrayTree nt, Void __) {
579575
if (nt.getInitializers()!=null) {
580-
return $b.invoke("newArrayFromInitializers").tap(inv -> {
581-
nt.getInitializers().forEach(d -> inv.arg(visit(d)));
582-
});
576+
return $b.invoke("newArrayFromInitializers").tap(inv -> nt.getInitializers().forEach(d -> inv.arg(visit(d))));
583577
} else {
584578
return $b.invoke("newArray").tap(inv -> {
585579
inv.arg(loc(nt));
@@ -767,7 +761,7 @@ private JType t(TypeMirror m, Map<String, JTypeVar> typeVars) {
767761
if (m.getKind().isPrimitive())
768762
return JType.parse(codeModel,m.toString());
769763

770-
return m.accept(new SimpleTypeVisitor6<JType, Void>() {
764+
return m.accept(new SimpleTypeVisitor8<JType, Void>() {
771765
@Override
772766
public JType visitPrimitive(PrimitiveType t, Void __) {
773767
return primitive(t, t.getKind());

doc/classloader.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ which is not trusted.
2323
Scripts loaded in TCL, OTOH, does not live in the security sandbox. This
2424
classloader is meant to be used to load Groovy code packaged inside
2525
plugins and global libraries. Write access to these sources should be
26-
restricted to `RUN_SCRIPTS` permission.
26+
restricted to `ADMINISTER` permission.
2727

2828
## Persisting code & surviving restarts
2929
When a Groovy script is loaded via one of `GroovyShell.parse*()` and

doc/persistence.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ Running pipelines persist in 3 pieces:
1515
- If null, probably the build dates back to before this field was added - we check to see if this is running in a highly persistent DurabilityMode (Max_survivability generally)
1616
* done - if true, this execution completed, if false or un-set, the pipeline is a candidate to resume unless its only head is a FlowEndNode
1717
- The handling of false is for legacy reasons, since it was only recently made persistent.
18-
*
1918
* various other boolean flags & settings for the execution (durability setting, user that started the build, is it sandboxed, etc)
2019
3. The Program -- this is the current execution state of the Pipeline
2120
* This holds the Groovy state - the `CpsThreadGroup` - with runtime calls transformed by CPS so they can persist
@@ -29,12 +28,11 @@ Running pipelines persist in 3 pieces:
2928

3029
Some basic rules:
3130

32-
1. If the FlowNodeStorage is corrupt, incomplete, or un-persisted, all manner of heck will break loose
33-
- In terms of Pipeline execution, the impact is like the Resonance Cascade from the Half-Life games
31+
1. If the FlowNodeStorage is corrupt, incomplete, or un-persisted, various things will break
3432
- The pipeline can never be resumed (the key piece is missing)
3533
- Usually we fake up some placeholder FlowNodes to cover this situation and save them
3634
2. Whenever persisting data, the Pipeline *must* have the FlowNodes persisted on disk (via `storage.flush()` generally)
3735
in order to be able to load the heads and restore the program.
3836
3. Once we've set persistedClean as false and saved the FlowExecution, then it doesn't matter what we do -- the Pipeline will assume
3937
it already has incomplete persistence data (as with 1) when trying to resume. This is how we handle the low-durability modes, to
40-
avoid resuming a stale state of the Pipeline simply because we have old data persisted and are not updating it.
38+
avoid resuming a stale state of the Pipeline simply because we have old data persisted and are not updating it.

lib/pom.xml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,28 @@
2929
<executions>
3030
<execution>
3131
<goals>
32-
<goal>properties</goal>
32+
<goal>copy</goal>
3333
</goals>
34+
<phase>generate-sources</phase>
35+
<configuration>
36+
<artifactItems>
37+
<artifactItem>
38+
<groupId>com.cloudbees</groupId>
39+
<artifactId>groovy-cps-dgm-builder</artifactId>
40+
<version>${project.version}</version>
41+
<classifier>jar-with-dependencies</classifier>
42+
</artifactItem>
43+
</artifactItems>
44+
<outputDirectory>${project.build.directory}</outputDirectory>
45+
<overWriteIfNewer>true</overWriteIfNewer>
46+
</configuration>
3447
</execution>
3548
</executions>
3649
</plugin>
3750
<plugin>
3851
<groupId>org.codehaus.mojo</groupId>
3952
<artifactId>exec-maven-plugin</artifactId>
40-
<version>1.6.0</version>
53+
<version>3.1.1</version>
4154
<executions>
4255
<execution>
4356
<phase>generate-sources</phase>
@@ -49,7 +62,7 @@
4962
<executable>java</executable>
5063
<arguments>
5164
<argument>-jar</argument>
52-
<argument>${com.cloudbees:groovy-cps-dgm-builder:jar:jar-with-dependencies}</argument>
65+
<argument>${project.build.directory}/groovy-cps-dgm-builder-${project.version}-jar-with-dependencies.jar</argument>
5366
<argument>${project.build.directory}/generated-sources/dgm</argument>
5467
</arguments>
5568
</configuration>
@@ -60,7 +73,7 @@
6073
</build>
6174

6275
<properties>
63-
<groovy-sandbox.version>1.30</groovy-sandbox.version>
76+
<groovy-sandbox.version>1.33</groovy-sandbox.version>
6477
<no-test-jar>false</no-test-jar>
6578
</properties>
6679
<dependencies>

0 commit comments

Comments
 (0)