Skip to content

Commit

Permalink
Merge branch 'master' into fix-shell-autocompletion
Browse files Browse the repository at this point in the history
  • Loading branch information
botic authored Jan 12, 2022
2 parents aab3568 + 823797c commit 59e4f24
Show file tree
Hide file tree
Showing 15 changed files with 53 additions and 369 deletions.
28 changes: 14 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ sourceSets {
}

dependencies {
implementation 'org.mozilla:rhino:1.7.13'
implementation 'org.eclipse.jetty:jetty-server:9.4.43.v20210629'
implementation 'org.eclipse.jetty:jetty-servlet:9.4.43.v20210629'
implementation 'org.eclipse.jetty.websocket:websocket-server:9.4.43.v20210629'
implementation 'org.eclipse.jetty.websocket:websocket-client:9.4.43.v20210629'
implementation 'org.eclipse.jetty:jetty-servlets:9.4.43.v20210629'
implementation 'org.eclipse.jetty:jetty-xml:9.4.43.v20210629'
implementation 'org.apache.logging.log4j:log4j-core:2.14.0'
implementation 'org.apache.logging.log4j:log4j-api:2.14.0'
implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.14.0'
implementation 'org.jline:jline:3.20.0'
implementation 'junit:junit:4.13.1'
implementation 'org.mozilla:rhino:1.7.14'
implementation 'org.eclipse.jetty:jetty-server:9.4.44.v20210927'
implementation 'org.eclipse.jetty:jetty-servlet:9.4.44.v20210927'
implementation 'org.eclipse.jetty.websocket:websocket-server:9.4.44.v20210927'
implementation 'org.eclipse.jetty.websocket:websocket-client:9.4.44.v20210927'
implementation 'org.eclipse.jetty:jetty-servlets:9.4.44.v20210927'
implementation 'org.eclipse.jetty:jetty-xml:9.4.44.v20210927'
implementation 'org.apache.logging.log4j:log4j-core:2.17.1'
implementation 'org.apache.logging.log4j:log4j-api:2.17.1'
implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.17.1'
implementation 'org.jline:jline:3.21.0'
implementation 'junit:junit:4.13.2'
}

tasks.withType(JavaCompile) {
Expand Down Expand Up @@ -250,12 +250,12 @@ class DatesTestTask extends JavaExec {
})
.distinct()
.sorted()
.forEach({offset ->
.forEach({offset ->
String timeZone = "GMT${offset}"
logger.quiet("Testing ringo/utils/dates in timezone {} …", timeZone)
systemProperty("user.timezone", timeZone);
super.exec()
})
}

}
}
41 changes: 0 additions & 41 deletions lib/ringo.policy

This file was deleted.

49 changes: 0 additions & 49 deletions modules/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
const io = require('io');
const binary = require('binary');

const security = java.lang.System.getSecurityManager();

const arrays = require('ringo/utils/arrays');
const {PosixPermissions} = require('ringo/utils/files');

Expand Down Expand Up @@ -769,10 +767,6 @@ const lastModified = exports.lastModified = function(path) {
* @param {Number|String|java.util.Set<PosixFilePermission>} permissions optional the POSIX permissions
*/
const makeDirectory = exports.makeDirectory = function(path, permissions) {
if (security) {
security.checkWrite(path);
}

// single-argument Files.createDirectory() respects the current umask
if (permissions == null) {
Files.createDirectory(getPath(path));
Expand Down Expand Up @@ -824,9 +818,6 @@ const isDirectory = exports.isDirectory = function(path) {
* @returns {Boolean} true if the given file exists and is a symbolic link
*/
const isLink = exports.isLink = function(path) {
if (security) {
security.checkRead(path);
}
return Files.isSymbolicLink(resolvePath(path));
}

Expand All @@ -840,10 +831,6 @@ const isLink = exports.isLink = function(path) {
* @returns {Boolean} true iff the two paths locate the same file
*/
const same = exports.same = function(pathA, pathB) {
if (security) {
security.checkRead(pathA);
security.checkRead(pathB);
}
// make canonical to resolve symbolic links
const nioPathA = getPath(canonical(pathA));
const nioPathB = getPath(canonical(pathB));
Expand All @@ -859,10 +846,6 @@ const same = exports.same = function(pathA, pathB) {
* @returns {Boolean} true if same file system, otherwise false
*/
const sameFilesystem = exports.sameFilesystem = function(pathA, pathB) {
if (security) {
security.checkRead(pathA);
security.checkRead(pathB);
}
// make canonical to resolve symbolic links
const nioPathA = getPath(canonical(pathA));
const nioPathB = getPath(canonical(pathB));
Expand Down Expand Up @@ -908,11 +891,6 @@ const touch = exports.touch = function(path, mtime) {
* @returns {String} the path to the symbolic link
*/
const symbolicLink = exports.symbolicLink = function(existing, link) {
if (security) {
security.checkRead(existing);
security.checkWrite(link);
}

return String(Files.createSymbolicLink(getPath(link), getPath(existing)));
}

Expand All @@ -925,11 +903,6 @@ const symbolicLink = exports.symbolicLink = function(existing, link) {
* @returns {String} the path to the link
*/
const hardLink = exports.hardLink = function(existing, link) {
if (security) {
security.checkRead(existing);
security.checkWrite(link);
}

return String(Files.createLink(getPath(link), getPath(existing)));
}

Expand All @@ -939,8 +912,6 @@ const hardLink = exports.hardLink = function(existing, link) {
* @param {String} path a file path
*/
const readLink = exports.readLink = function(path) {
if (security) security.checkRead(path);

// Throws an exception if there is no symbolic link at the given path or the link cannot be read.
if (!Files.isReadable(getPath(path))) {
throw new Error("Path " + path + " is not readable!");
Expand Down Expand Up @@ -974,9 +945,6 @@ const iterate = exports.iterate = function(path) {
* @returns PosixFilePermission the POSIX permissions for the given path
*/
const permissions = exports.permissions = function(path) {
if (security) {
security.checkRead(path);
}
return new PosixPermissions(Files.getPosixFilePermissions(getPath(path)));
}

Expand All @@ -986,9 +954,6 @@ const permissions = exports.permissions = function(path) {
* @returns {String} the username of the owner, or null if not possible to determine
*/
const owner = exports.owner = function(path) {
if (security) {
security.checkRead(path);
}
try {
return Files.getOwner(getPath(path)).getName();
} catch (error) {
Expand All @@ -1004,9 +969,6 @@ const owner = exports.owner = function(path) {
* @returns {String} the group's name, or null if not possible to determine
*/
const group = exports.group = function(path) {
if (security) {
security.checkRead(path);
}
try {
const attributes = Files.getFileAttributeView(getPath(path), PosixFileAttributeView);
return attributes.readAttributes().group().getName();
Expand All @@ -1023,9 +985,6 @@ const group = exports.group = function(path) {
* @param {Number|String|java.util.Set<PosixFilePermission>} permissions the POSIX permissions
*/
const changePermissions = exports.changePermissions = function(path, permissions) {
if (security) {
security.checkWrite(path);
}
permissions = new PosixPermissions(permissions);
return Files.setPosixFilePermissions(getPath(path), permissions.toJavaPosixFilePermissionSet());
}
Expand All @@ -1037,10 +996,6 @@ const changePermissions = exports.changePermissions = function(path, permissions
* @param {String} owner the user name string
*/
const changeOwner = exports.changeOwner = function(path, user) {
if (security) {
security.checkWrite(path);
}

const lookupService = FS.getUserPrincipalLookupService();
const userPrincipal = lookupService.lookupPrincipalByName(user);

Expand All @@ -1054,10 +1009,6 @@ const changeOwner = exports.changeOwner = function(path, user) {
* @param {String} group group name string
*/
const changeGroup = exports.changeGroup = function(path, group) {
if (security) {
security.checkWrite(path);
}

const lookupService = FS.getUserPrincipalLookupService();
const groupPrincipal = lookupService.lookupPrincipalByGroupName(group);

Expand Down
4 changes: 2 additions & 2 deletions modules/ringo/utils/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const {Buffer} = require('ringo/buffer');
const binary = require('binary');
const io = require('io');

const {open} = require('fs').open;
const fs = require('fs');
const {createTempFile} = require('ringo/utils/files');

const PATH_CTL = java.util.regex.Pattern.compile("[\x00-\x1F\x7F\x3B]");
Expand Down Expand Up @@ -894,5 +894,5 @@ exports.TempFileFactory = function(data, encoding) {
return BufferFactory(data, encoding)
}
data.tempfile = createTempFile("ringo-upload-");
return open(data.tempfile, {write: true, binary: true});
return fs.open(data.tempfile, {write: true, binary: true});
};
4 changes: 1 addition & 3 deletions src/org/ringojs/engine/ReloadableScript.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,7 @@ protected synchronized Object compileScript(Context cx)
Object script = null;
String charset = engine.getCharset();
try {
CodeSource securityDomain = engine.isPolicyEnabled() ?
new CodeSource(resource.getUrl(), (CodeSigner[]) null) : null;
script = loader.load(cx, engine, securityDomain, moduleName,
script = loader.load(cx, engine, null, moduleName,
charset, resource);
} catch (Exception x) {
exception = x;
Expand Down
7 changes: 0 additions & 7 deletions src/org/ringojs/engine/RhinoEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -700,16 +700,9 @@ public static RhinoEngine getEngine(Scriptable scope) {
*/
public RhinoEngine createSandbox(RingoConfig config, Map<String,Object> globals)
throws Exception {
config.setPolicyEnabled(this.config.isPolicyEnabled());
return new RhinoEngine(config, globals);
}

protected boolean isPolicyEnabled() {
// only use security when ringo runs standalone with default security manager,
// not with google app engine
return config.isPolicyEnabled();
}

/**
* Wait until all daemon threads running in this engine have terminated.
* @throws InterruptedException if the current thread has been interrupted
Expand Down
9 changes: 0 additions & 9 deletions src/org/ringojs/engine/RingoConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public class RingoConfig {
private WrapFactory wrapFactory = null;
private List<String> bootstrapScripts;
private boolean sealed = false;
private boolean policyEnabled = false;
private boolean reloading = true;
private String charset = "UTF-8";

Expand Down Expand Up @@ -537,14 +536,6 @@ public void setReloading(boolean reloading) {
this.reloading = reloading;
}

public boolean isPolicyEnabled() {
return policyEnabled;
}

public void setPolicyEnabled(boolean hasPolicy) {
this.policyEnabled = hasPolicy;
}

public List<String> getBootstrapScripts() {
return bootstrapScripts;
}
Expand Down
4 changes: 0 additions & 4 deletions src/org/ringojs/engine/RingoContextFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ public Void run() {
if (classShutter != null) {
cx.setClassShutter(classShutter);
}
if (engine.isPolicyEnabled()) {
cx.setInstructionObserverThreshold(instructionLimit);
cx.setSecurityController(new PolicySecurityController());
}
cx.setErrorReporter(new ToolErrorReporter(true));
cx.setGeneratingDebug(generatingDebug);
}
Expand Down
8 changes: 0 additions & 8 deletions src/org/ringojs/engine/RingoGlobal.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.mozilla.javascript.tools.shell.QuitAction;
import org.ringojs.repository.Repository;
import org.ringojs.repository.Trackable;
import org.ringojs.security.RingoSecurityManager;
import org.ringojs.util.ScriptUtils;
import org.mozilla.javascript.tools.shell.Global;
import org.ringojs.repository.Resource;
Expand All @@ -48,7 +47,6 @@
public class RingoGlobal extends Global {

private final RhinoEngine engine;
private final static SecurityManager securityManager = System.getSecurityManager();
private static ExecutorService threadPool;
private static final AtomicInteger ids = new AtomicInteger();

Expand Down Expand Up @@ -147,9 +145,6 @@ public static Object getRepository(final Context cx, Scriptable thisObj,

public static Object addToClasspath(final Context cx, Scriptable thisObj,
Object[] args, Function funObj) {
if (securityManager != null) {
securityManager.checkPermission(RingoSecurityManager.GET_CLASSLOADER);
}
if (args.length != 1) {
throw Context.reportRuntimeError(
"addToClasspath() requires one argument");
Expand Down Expand Up @@ -206,9 +201,6 @@ public PrivilegedAction run() {

public static Object spawn(Context cx, Scriptable thisObj,
Object[] args, Function funObj) {
if (securityManager != null) {
securityManager.checkPermission(RingoSecurityManager.SPAWN_THREAD);
}
if (args.length < 1 || !(args[0] instanceof Function)) {
throw Context.reportRuntimeError("spawn() requires a function argument");
}
Expand Down
29 changes: 0 additions & 29 deletions src/org/ringojs/security/RingoRuntimePermission.java

This file was deleted.

Loading

0 comments on commit 59e4f24

Please sign in to comment.