Add script invocation result size check to remote JS executor
This commit is contained in:
parent
a2c830ce8a
commit
8d735f4886
@ -43,6 +43,7 @@ const useSandbox = config.get('script.use_sandbox') === 'true';
|
|||||||
const maxActiveScripts = Number(config.get('script.max_active_scripts'));
|
const maxActiveScripts = Number(config.get('script.max_active_scripts'));
|
||||||
const slowQueryLogMs = Number(config.get('script.slow_query_log_ms'));
|
const slowQueryLogMs = Number(config.get('script.slow_query_log_ms'));
|
||||||
const slowQueryLogBody = config.get('script.slow_query_log_body') === 'true';
|
const slowQueryLogBody = config.get('script.slow_query_log_body') === 'true';
|
||||||
|
const maxResultSize = Number(config.get('js.max_result_size'));
|
||||||
|
|
||||||
export class JsInvokeMessageProcessor {
|
export class JsInvokeMessageProcessor {
|
||||||
|
|
||||||
@ -164,9 +165,19 @@ export class JsInvokeMessageProcessor {
|
|||||||
(script) => {
|
(script) => {
|
||||||
this.executor.executeScript(script, invokeRequest.args, invokeRequest.timeout).then(
|
this.executor.executeScript(script, invokeRequest.args, invokeRequest.timeout).then(
|
||||||
(result) => {
|
(result) => {
|
||||||
const invokeResponse = JsInvokeMessageProcessor.createInvokeResponse(result, true);
|
if (result.length <= maxResultSize) {
|
||||||
this.logger.debug('[%s] Sending success invoke response, scriptId: [%s]', requestId, scriptId);
|
const invokeResponse = JsInvokeMessageProcessor.createInvokeResponse(result, true);
|
||||||
this.sendResponse(requestId, responseTopic, headers, scriptId, undefined, invokeResponse);
|
this.logger.debug('[%s] Sending success invoke response, scriptId: [%s]', requestId, scriptId);
|
||||||
|
this.sendResponse(requestId, responseTopic, headers, scriptId, undefined, invokeResponse);
|
||||||
|
} else {
|
||||||
|
let err = {
|
||||||
|
name: 'Error',
|
||||||
|
message: 'script invocation result exceeds maximum allowed size of ' + maxResultSize + ' symbols'
|
||||||
|
}
|
||||||
|
const invokeResponse = JsInvokeMessageProcessor.createInvokeResponse("", false, RUNTIME_ERROR, err);
|
||||||
|
this.logger.debug('[%s] Script invocation result exceeds maximum allowed size of %s symbols, scriptId: [%s]', requestId, maxResultSize, scriptId);
|
||||||
|
this.sendResponse(requestId, responseTopic, headers, scriptId, undefined, invokeResponse);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
(err: any) => {
|
(err: any) => {
|
||||||
let errorCode;
|
let errorCode;
|
||||||
|
|||||||
@ -20,6 +20,7 @@ http_port: "HTTP_PORT" # /livenessProbe
|
|||||||
|
|
||||||
js:
|
js:
|
||||||
response_poll_interval: "REMOTE_JS_RESPONSE_POLL_INTERVAL_MS"
|
response_poll_interval: "REMOTE_JS_RESPONSE_POLL_INTERVAL_MS"
|
||||||
|
max_result_size: "JS_MAX_RESULT_SIZE"
|
||||||
|
|
||||||
kafka:
|
kafka:
|
||||||
bootstrap:
|
bootstrap:
|
||||||
|
|||||||
@ -20,6 +20,7 @@ http_port: "8888" # /livenessProbe
|
|||||||
|
|
||||||
js:
|
js:
|
||||||
response_poll_interval: "25"
|
response_poll_interval: "25"
|
||||||
|
max_result_size: "300000"
|
||||||
|
|
||||||
kafka:
|
kafka:
|
||||||
bootstrap:
|
bootstrap:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user