mirror of
https://gitee.com/BDWare/cp.git
synced 2025-01-10 09:54:07 +00:00
fix arg schema bugs
This commit is contained in:
parent
56d140a2c7
commit
64cdfecd67
@ -6,7 +6,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "org.bdware.sc"
|
group = "org.bdware.sc"
|
||||||
version = "1.6.5"
|
version = "1.6.7"
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
|
@ -92,8 +92,8 @@ public class DebugMain {
|
|||||||
String urlFormat = ("http://%s/SCIDE/SCManager?action=%s&arg=%s");
|
String urlFormat = ("http://%s/SCIDE/SCManager?action=%s&arg=%s");
|
||||||
String url = String.format(urlFormat, config.agentAddress, "getAgentConfig", "");
|
String url = String.format(urlFormat, config.agentAddress, "getAgentConfig", "");
|
||||||
Map<String, Object> resp = HttpUtil.httpGet(url);
|
Map<String, Object> resp = HttpUtil.httpGet(url);
|
||||||
String data = (String
|
String data = (String) resp.get("response");
|
||||||
) resp.get("response");
|
assert (int) resp.get("responseCode") == 200;
|
||||||
JsonObject jsonObject = JsonUtil.parseStringAsJsonObject(data);
|
JsonObject jsonObject = JsonUtil.parseStringAsJsonObject(data);
|
||||||
config.cmi = jsonObject.get("cmi").getAsString();
|
config.cmi = jsonObject.get("cmi").getAsString();
|
||||||
config.dbPath = jsonObject.get("dbPath").getAsString();
|
config.dbPath = jsonObject.get("dbPath").getAsString();
|
||||||
|
@ -5,12 +5,9 @@ import com.google.gson.JsonObject;
|
|||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.bdware.sc.ContractProcess;
|
|
||||||
import org.bdware.sc.JSEngine;
|
import org.bdware.sc.JSEngine;
|
||||||
import org.bdware.sc.bean.ContractRequest;
|
import org.bdware.sc.bean.ContractRequest;
|
||||||
import org.bdware.sc.bean.ProjectConfig;
|
|
||||||
import org.bdware.sc.boundry.ScriptReturnException;
|
import org.bdware.sc.boundry.ScriptReturnException;
|
||||||
import org.bdware.sc.engine.DesktopEngine;
|
|
||||||
import org.bdware.sc.node.AnnotationHook;
|
import org.bdware.sc.node.AnnotationHook;
|
||||||
import org.bdware.sc.node.AnnotationNode;
|
import org.bdware.sc.node.AnnotationNode;
|
||||||
import org.bdware.sc.node.FunctionNode;
|
import org.bdware.sc.node.FunctionNode;
|
||||||
@ -38,13 +35,12 @@ public class ArgSchemaHandler implements AnnotationHook {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object handle(ContractRequest input, JSEngine Engine, Object ret) throws ScriptReturnException {
|
public Object handle(ContractRequest input, JSEngine Engine, Object ret) throws ScriptReturnException {
|
||||||
//input.getArg();
|
|
||||||
JsonElement je = input.getArg();
|
JsonElement je = input.getArg();
|
||||||
ArgSchemaVisitor visitor;
|
ArgSchemaVisitor visitor;
|
||||||
if (je.isJsonObject())
|
if (je.isJsonObject())
|
||||||
visitor = new ArgSchemaVisitor(input.getArg().getAsJsonObject());
|
visitor = new ArgSchemaVisitor(input.getArg().getAsJsonObject());
|
||||||
else
|
else
|
||||||
visitor = new ArgSchemaVisitor(JsonParser.parseString(input.getArg().toString()));
|
visitor = new ArgSchemaVisitor(JsonParser.parseString(input.getArg().getAsString()));
|
||||||
if (je.toString().isEmpty() && !a.getArgs().get(0).equals("")) {
|
if (je.toString().isEmpty() && !a.getArgs().get(0).equals("")) {
|
||||||
JsonObject jo = new JsonObject();
|
JsonObject jo = new JsonObject();
|
||||||
jo.addProperty("msg", "[Empty argument] argument should not be empty");
|
jo.addProperty("msg", "[Empty argument] argument should not be empty");
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
package org.bdware.sc.engine.hook;
|
package org.bdware.sc.engine.hook;
|
||||||
|
|
||||||
import com.alibaba.datax.transport.transformer.maskingMethods.cryptology.AESEncryptionImpl;
|
|
||||||
import com.alibaba.datax.transport.transformer.maskingMethods.cryptology.FormatPreservingEncryptionImpl;
|
|
||||||
import com.alibaba.datax.transport.transformer.maskingMethods.differentialPrivacy.EpsilonDifferentialPrivacyImpl;
|
|
||||||
import com.alibaba.datax.transport.transformer.maskingMethods.irreversibleInterference.MD5EncryptionImpl;
|
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
@ -41,15 +37,12 @@ public class ArgSchemaVisitor extends JsonVisitor {
|
|||||||
message += visitor.message;
|
message += visitor.message;
|
||||||
}
|
}
|
||||||
status &= visitor.status;
|
status &= visitor.status;
|
||||||
|
} else {
|
||||||
}
|
|
||||||
else{
|
|
||||||
message += "[Missing argument] " + key.substring(1) + " should be supplied ";
|
message += "[Missing argument] " + key.substring(1) + " should be supplied ";
|
||||||
status = false;
|
status = false;
|
||||||
errorCode = 1002;
|
errorCode = 1002;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
if (jo.has(key)) {
|
if (jo.has(key)) {
|
||||||
ArgSchemaVisitor visitor = new ArgSchemaVisitor(jo.get(key));
|
ArgSchemaVisitor visitor = new ArgSchemaVisitor(jo.get(key));
|
||||||
visitor.visit(schema.get(key));
|
visitor.visit(schema.get(key));
|
||||||
@ -63,6 +56,10 @@ public class ArgSchemaVisitor extends JsonVisitor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
message += "[Incorrect type] should be object";
|
||||||
|
status = false;
|
||||||
|
errorCode = 1003;
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -72,7 +69,6 @@ public class ArgSchemaVisitor extends JsonVisitor {
|
|||||||
if (root.isJsonArray()) {
|
if (root.isJsonArray()) {
|
||||||
JsonArray array = root.getAsJsonArray();
|
JsonArray array = root.getAsJsonArray();
|
||||||
//message = new JsonArray();
|
//message = new JsonArray();
|
||||||
|
|
||||||
for (int i = 0; i < array.size(); i++) {
|
for (int i = 0; i < array.size(); i++) {
|
||||||
ArgSchemaVisitor visitor = new ArgSchemaVisitor(array.get(i));
|
ArgSchemaVisitor visitor = new ArgSchemaVisitor(array.get(i));
|
||||||
visitor.visit(ele.get(0));
|
visitor.visit(ele.get(0));
|
||||||
@ -116,8 +112,7 @@ public class ArgSchemaVisitor extends JsonVisitor {
|
|||||||
errorCode = 1001;
|
errorCode = 1001;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
} else if (type.equals("boolean")) {
|
||||||
else if (type.equals("boolean")) {
|
|
||||||
if (root.isJsonPrimitive() && root.getAsJsonPrimitive().isBoolean()) {
|
if (root.isJsonPrimitive() && root.getAsJsonPrimitive().isBoolean()) {
|
||||||
return this;
|
return this;
|
||||||
} else {
|
} else {
|
||||||
@ -126,8 +121,7 @@ public class ArgSchemaVisitor extends JsonVisitor {
|
|||||||
errorCode = 1001;
|
errorCode = 1001;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
} else if (type.equals("[]")) {
|
||||||
else if (type.equals("[]")) {
|
|
||||||
if (root.isJsonArray()) {
|
if (root.isJsonArray()) {
|
||||||
return this;
|
return this;
|
||||||
} else {
|
} else {
|
||||||
@ -136,8 +130,7 @@ public class ArgSchemaVisitor extends JsonVisitor {
|
|||||||
errorCode = 1001;
|
errorCode = 1001;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
} else if (type.equals("{}")) {
|
||||||
else if (type.equals("{}")) {
|
|
||||||
if (root.isJsonObject()) {
|
if (root.isJsonObject()) {
|
||||||
return this;
|
return this;
|
||||||
} else {
|
} else {
|
||||||
@ -160,7 +153,12 @@ public class ArgSchemaVisitor extends JsonVisitor {
|
|||||||
//https://github.com/guohf/DataX-Masking
|
//https://github.com/guohf/DataX-Masking
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public boolean getStatus(){return status;}
|
|
||||||
|
|
||||||
public String getException() {return message;}
|
public boolean getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getException() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user