From cfb4ef2fc1b7a69c85eca47f50d7c4e94fea1a62 Mon Sep 17 00:00:00 2001 From: rarkenin Date: Sat, 12 Apr 2014 21:10:56 -0400 Subject: [PATCH 1/2] Fix bug in which no bytes of a file would be used in the hash, leading to identical hashes even with bytes being actively read --- src/net/mosstest/servercore/LocalFileManager.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/net/mosstest/servercore/LocalFileManager.java b/src/net/mosstest/servercore/LocalFileManager.java index b7f5e74..f9e1676 100644 --- a/src/net/mosstest/servercore/LocalFileManager.java +++ b/src/net/mosstest/servercore/LocalFileManager.java @@ -104,8 +104,7 @@ public class LocalFileManager implements IFileManager { while ((bytesRead != -1) && (bytesRead != 0)) { bbf.flip(); - byte[] bytes = new byte[bytesRead]; - bbf.get(bytes); + md.update(bbf); From dfe3a218500c8fe6e38a5bf02ee9e9536cc30434 Mon Sep 17 00:00:00 2001 From: rarkenin Date: Sun, 13 Apr 2014 14:51:04 -0400 Subject: [PATCH 2/2] update script env to be able to import --- data | 2 +- src/net/mosstest/scripting/MossScriptEnv.java | 1 + src/net/mosstest/servercore/ScriptEnv.java | 17 ++++++----------- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/data b/data index 34539eb..88ccbe2 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit 34539ebf406a1b1bed747aefc26cf8f17af7cc4b +Subproject commit 88ccbe2bba7da9f6bb366aa2c78f957f3e200cdf diff --git a/src/net/mosstest/scripting/MossScriptEnv.java b/src/net/mosstest/scripting/MossScriptEnv.java index 2c2ac43..cfb19ee 100644 --- a/src/net/mosstest/scripting/MossScriptEnv.java +++ b/src/net/mosstest/scripting/MossScriptEnv.java @@ -4,6 +4,7 @@ import net.mosstest.scripting.events.IMossEvent; import net.mosstest.scripting.handlers.MossEventHandler; import net.mosstest.scripting.handlers.MossNodeChangeHandler; import net.mosstest.servercore.*; +import org.mozilla.javascript.NativeJavaPackage; import java.util.ArrayList; import java.util.HashMap; diff --git a/src/net/mosstest/servercore/ScriptEnv.java b/src/net/mosstest/servercore/ScriptEnv.java index 2ef377a..0c76922 100644 --- a/src/net/mosstest/servercore/ScriptEnv.java +++ b/src/net/mosstest/servercore/ScriptEnv.java @@ -10,7 +10,7 @@ import java.io.IOException; // TODO: Auto-generated Javadoc /** - * Static environment for executing scripts. Call {@link ScriptEnv.runScript()} + * Static environment for executing scripts. Call {@link ScriptEnv#runScript()} * to call a script. * * @author rarkenin @@ -19,7 +19,7 @@ public class ScriptEnv { static Logger logger = Logger.getLogger(MossDebugUtils.class); - ScriptableObject globalScope; + ImporterTopLevel globalScope; /** @@ -52,14 +52,9 @@ public class ScriptEnv { /** * Executes a script with default permissions. This will allow sandboxed * access to the database, and gameplay data, without access to - * authentication data. These scripts have access to - * Hashmap<String, Object>-style maps used for extended - * custom attributes, and may access various API classes via - * {@link net.mosstest.scripting.JavaApi JavaApi}(which internally uses - * reflection to obtain classes). Via an ACL, certain classes may be blocked + * authentication data. Via an ACL, certain classes may be blocked * or replaced with limited versions thereof. At the time of writing, this - * feature is incomplete and will not allow any access to the Java(tm) SE - * API. + * feature uses a security manager to disallow anything that tries to access risky data or sockets. * * @param script A string representing the script to run * @return A {@link ScriptEnv.ScriptResult} constant representing the @@ -101,9 +96,9 @@ public class ScriptEnv { * @param ev the ev */ public ScriptEnv(MossScriptEnv ev) { - this.cx = ContextFactory.getGlobal().enterContext(); - this.globalScope = this.cx.initStandardObjects(); + this.globalScope = new ImporterTopLevel(); + this.globalScope.initStandardObjects(cx, false); cx.setOptimizationLevel(9); this.globalScope.put("moss", this.globalScope, ev); //$NON-NLS-1$