Skip to content

Commit

Permalink
Remove SecurityManager
Browse files Browse the repository at this point in the history
  • Loading branch information
keeganwitt committed May 23, 2023
1 parent 473d93e commit 0f801bc
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,6 @@ public abstract class AbstractToolsMojo extends AbstractGroovyMojo {
@Parameter
protected Properties properties = new Properties();

/**
* Whether to allow System.exit() to be used. Should not be set to <code>false</code> when using parallel
* execution, as it isn't thread-safe.
*
* @since 1.2
*/
@Parameter(defaultValue = "true")
protected boolean allowSystemExits;

/**
* Whether to bind each property to a separate variable (otherwise binds properties to a single 'properties' variable).
*
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/org/codehaus/gmavenplus/mojo/ConsoleMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.codehaus.gmavenplus.util.NoExitSecurityManager;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
Expand Down Expand Up @@ -86,12 +85,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
}

if (groovyVersionSupportsAction()) {
final SecurityManager sm = System.getSecurityManager();
try {
if (!allowSystemExits) {
System.setSecurityManager(new NoExitSecurityManager());
}

// get classes we need with reflection
Class<?> consoleClass;
try {
Expand Down Expand Up @@ -127,10 +121,6 @@ public void execute() throws MojoExecutionException, MojoFailureException {
throw new MojoExecutionException("Unable to access a method on a Groovy class from classpath.", e);
} catch (InstantiationException e) {
throw new MojoExecutionException("Error occurred while instantiating a Groovy class from classpath.", e);
} finally {
if (!allowSystemExits) {
System.setSecurityManager(sm);
}
}
} else {
getLog().error("Your Groovy version (" + classWrangler.getGroovyVersionString() + ") doesn't support running a console. The minimum version of Groovy required is " + minGroovyVersion + ". Skipping console startup.");
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/org/codehaus/gmavenplus/mojo/ExecuteMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.codehaus.gmavenplus.model.internal.Version;
import org.codehaus.gmavenplus.util.FileUtils;
import org.codehaus.gmavenplus.util.NoExitSecurityManager;

import java.io.BufferedReader;
import java.io.File;
Expand Down Expand Up @@ -137,12 +136,7 @@ protected synchronized void doExecute() throws MojoExecutionException {
}

if (groovyVersionSupportsAction()) {
final SecurityManager sm = System.getSecurityManager();
try {
if (!allowSystemExits) {
System.setSecurityManager(new NoExitSecurityManager());
}

// get classes we need with reflection
Class<?> groovyShellClass = classWrangler.getClass("groovy.lang.GroovyShell");

Expand All @@ -159,10 +153,6 @@ protected synchronized void doExecute() throws MojoExecutionException {
throw new MojoExecutionException("Error occurred while instantiating a Groovy class from classpath.", e);
} catch (IllegalAccessException e) {
throw new MojoExecutionException("Unable to access a method on a Groovy class from classpath.", e);
} finally {
if (!allowSystemExits) {
System.setSecurityManager(sm);
}
}
} else {
getLog().error("Your Groovy version (" + classWrangler.getGroovyVersionString() + ") doesn't support script execution. The minimum version of Groovy required is " + minGroovyVersion + ". Skipping script execution.");
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/org/codehaus/gmavenplus/mojo/ShellMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.codehaus.gmavenplus.model.internal.Version;
import org.codehaus.gmavenplus.util.NoExitSecurityManager;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
Expand Down Expand Up @@ -91,12 +90,7 @@ public void execute() throws MojoExecutionException {
}

if (groovyVersionSupportsAction()) {
final SecurityManager sm = System.getSecurityManager();
try {
if (!allowSystemExits) {
System.setSecurityManager(new NoExitSecurityManager());
}

// get classes we need with reflection
Class<?> shellClass = classWrangler.getClass(groovyAtLeast(GROOVY_4_0_0_ALPHA1) ? "org.apache.groovy.groovysh.Groovysh" : "org.codehaus.groovy.tools.shell.Groovysh");
Class<?> bindingClass = classWrangler.getClass("groovy.lang.Binding");
Expand All @@ -121,10 +115,6 @@ public void execute() throws MojoExecutionException {
throw new MojoExecutionException("Unable to access a method on a Groovy class from classpath.", e);
} catch (InstantiationException e) {
throw new MojoExecutionException("Error occurred while instantiating a Groovy class from classpath.", e);
} finally {
if (!allowSystemExits) {
System.setSecurityManager(sm);
}
}
} else {
getLog().error("Your Groovy version (" + classWrangler.getGroovyVersionString() + ") doesn't support running a shell. The minimum version of Groovy required is " + minGroovyVersion + ". Skipping shell startup.");
Expand Down

This file was deleted.

0 comments on commit 0f801bc

Please sign in to comment.