@ -118,6 +118,7 @@ public class RpcV2Controller extends AbstractRpcController {
@ApiResponse(responseCode="200",description="Persistent RPC request was saved to the database or lightweight RPC request was sent to the device."),
@ApiResponse(responseCode="400",description="Invalid structure of the request."),
@ApiResponse(responseCode="401",description="User is not authorized to send the RPC request. Most likely, User belongs to different Customer or Tenant."),
@ApiResponse(responseCode="413",description="Request payload is too large"),
@ApiResponse(responseCode="504",description="Timeout to process the RPC call. Most likely, device is offline."),
@ -136,6 +137,7 @@ public class RpcV2Controller extends AbstractRpcController {
@ApiResponse(responseCode="200",description="Persistent RPC request was saved to the database or lightweight RPC response received."),
@ApiResponse(responseCode="400",description="Invalid structure of the request."),
@ApiResponse(responseCode="401",description="User is not authorized to send the RPC request. Most likely, User belongs to different Customer or Tenant."),
@ApiResponse(responseCode="413",description="Request payload is too large"),
@ApiResponse(responseCode="504",description="Timeout to process the RPC call. Most likely, device is offline."),
@ -125,7 +126,7 @@ class NashornJsInvokeServiceTest extends AbstractControllerTest {
@Test
voidgivenTooBigScriptForEval_thenReturnError(){
StringhugeScript="var a = 'qwertyqwertywertyqwabababer'; return {a: a};";
StringhugeScript="var a = '"+"a".repeat(10000)+"'; return {a: a};";
assertThatThrownBy(()->{
evalScript(hugeScript);
@ -159,6 +160,46 @@ class NashornJsInvokeServiceTest extends AbstractControllerTest {
assertThatScriptIsBlocked(scriptId);
}
@Test
voidgivenComplexScript_testCompile(){
Stringscript="""
function(data){
if(data.get("propertyA")=="a special value 1"||data.get("propertyA")=="a special value 2"){
return"a special value 1";
}elseif(data.get("propertyB")=="a special value 3"&&(data.get("propertyC")=="a special value 1"||data.get("propertyJ")=="a special value 1"||data.get("propertyV")=="a special value 1")){
return"a special value 1";
}elseif(data.get("propertyB")=="4"&&(data.get("propertyD")=="a special value 1"||data.get("propertyV")=="a special value 1"||data.get("propertyW")=="a special value 1")){
return"a special value 1";
}elseif(data.get("propertyB")=="a special value 2"&&(data.get("propertyE")=="a special value 1"||data.get("propertyF")=="a special value 1"||data.get("propertyL")=="a special value 1")){
return"a special value 1";
}elseif(data.get("propertyB")=="a special value 3"&&(data.get("propertyE")=="a special value 1"||data.get("propertyF")=="a special value 1"||data.get("propertyL")=="a special value 1")){
return"a special value 1";
}elseif(data.get("propertyB")=="a special value 3"&&(data.get("propertyM")=="a special value 1"||data.get("propertyY")=="a special value 1"||data.get("propertyH")=="a special value 1")){
return"a special value 1";
}elseif(data.get("propertyB")=="a special value 3"&&(data.get("propertyM")=="a special value 1"||data.get("propertyY")=="a special value 1"||data.get("propertyH")=="a special value 1")){
return"a special value 1";
}elseif(data.get("propertyB")=="a special value 3"&&(data.get("propertyM")=="a special value 1"||data.get("propertyY")=="a special value 1"||data.get("propertyH")=="a special value 1")){
return"a special value 1";
}elseif(data.get("propertyB")=="a special value 3"&&(data.get("propertyM")=="a special value 1"||data.get("propertyY")=="a special value 1"||data.get("propertyH")=="a special value 1")){
return"a special value 1";
}elseif(data.get("propertyB")=="a special value 3"&&(data.get("propertyM")=="a special value 1"||data.get("propertyY")=="a special value 1"||data.get("propertyH")=="a special value 1")){
return"a special value 1";
}elseif(data.get("propertyB")=="a special value 3"&&(data.get("propertyM")=="a special value 1"||data.get("propertyY")=="a special value 1"||data.get("propertyH")=="a special value 1")){
return"a special value 1";
}elseif(data.get("propertyB")=="a special value 3"&&(data.get("propertyM")=="a special value 1"||data.get("propertyY")=="a special value 1"||data.get("propertyH")=="a special value 1")){
return"a special value 1";
}else{
return"0"
};
}
""";
// with delight-nashorn-sandbox 0.4.2, this would throw delight.nashornsandbox.exceptions.ScriptCPUAbuseException: Regular expression running for too many iterations. The operation could NOT be gracefully interrupted.
thrownewIllegalArgumentException("Offset: "+offset+" is out of bounds for array with length: "+data.length+"!");
}
if((offset+length)>data.length){
thrownewIllegalArgumentException("Default length is always "+length+" bytes. Offset: "+offset+" and Length: "+length+" is out of bounds for array with length: "+data.length+"!");
@ -272,7 +288,8 @@ public class DeviceApiController implements TbTransportService {
@Parameter(description="RPC request id from the incoming RPC request",required=true,schema=@Schema(defaultValue="123"))
@PathVariable("requestId")IntegerrequestId,
@io.swagger.v3.oas.annotations.parameters.RequestBody(description="Reply to the RPC request, JSON. For example: {\"status\":\"success\"}",required=true)
thrownewDataValidationException("Can't delete rule chain that is root for edge ["+edge.getName()+"]. Please assign another root rule chain first to the edge!");
}
if(ruleChain.isRoot()){
thrownewDataValidationException("Deletion of Root Tenant Rule Chain is prohibited!");
thrownewDataValidationException("Can't delete rule chain that is root for edge ["+edge.getName()+"]. Please assign another root rule chain first to the edge!");
}
}
}
@ -457,6 +458,9 @@ public class BaseRuleChainService extends AbstractEntityService implements RuleC
<!-- IMPORTANT: If you change the version of the kafka client, make sure to synchronize our overwritten implementation of the
org.apache.kafka.common.network.NetworkReceive class in the application module. It addresses the issue https://issues.apache.org/jira/browse/KAFKA-4090.
max_payload_size:"${HTTP_MAX_PAYLOAD_SIZE:65536}"# max payload size in bytes
sessions:
# Session inactivity timeout is a global configuration parameter that defines how long the device transport session will be opened after the last message arrives from the device.