mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
fix(apigateway,appsync): sandbox VTL rendering with SecureUberspector and execution limits (#3542)
* fix(apigateway,appsync): sandbox VTL rendering with SecureUberspector and execution limits
VtlTemplateEngine and AppSyncVtlEngine rendered templates with Velocity's
default UberspectImpl introspector, which allows arbitrary reflection
through any context object (e.g. $util.getClass().forName('java.lang.Runtime')),
and had no cap on #foreach iterations, output size, or execution time,
making them vulnerable to both sandbox escapes and denial of service via
runaway loops or #set string doubling.
Add a shared VtlSandbox helper that both engines call to switch to
SecureUberspector and restrict introspection on java.lang.Class,
ClassLoader, Runtime, ProcessBuilder, System, Thread, java.io.File and
related reflection/scripting/process packages, plus three independent
limit layers: a native #foreach loop cap that truncates the loop without
failing the template, a cooperative execution deadline checked from a new
SandboxedForeach directive before each loop iteration, and a BoundedWriter
output-size cap. The latter two throw the new VtlLimitExceededException,
an unchecked RuntimeException that flows through each engine's existing
error handling exactly like any other Velocity evaluation failure, with
no new error shape. Limits are configurable via EmulatorConfig
(vtlMaxLoops, vtlMaxOutputChars, vtlTimeoutMillis; application.yml keys
vtl-max-loops, vtl-max-output-chars, vtl-timeout-millis), mirroring the
project's existing per-service numeric-tunable config pattern, and
documented in api-gateway.md and appsync.md.
The classpath-shadowed velocity.properties resource is kept for any
embedding that resolves it normally, but is not the actual enforcement
point: under this project's test/runtime classloader, Velocity's own
getResourceAsStream lookup for that exact resource path can resolve to
the copy bundled inside the velocity-engine-core jar instead of this
project's shadowed copy, silently leaving the insecure UberspectImpl
active even with a correct properties file on disk. VtlSandbox configures
SecureUberspector and swaps in SandboxedForeach directly via the
VelocityEngine Java API instead, which is unaffected by that ambiguity.
* docs(apigateway): correct foreach registration documentation
This commit is contained in:
1 parent
c63c834c0e
commit
144b90e6fa
19 files changed
+741
-8
No files matched your search
@@ -1177,6 +1177,21 @@ public interface EmulatorConfig {
|
||||
interface ApiGatewayServiceConfig {
|
||||
@WithDefault("true")
|
||||
boolean enabled();
|
||||
|
||||
/** Maximum #foreach loop iterations allowed in a single VTL mapping template render, as a
|
||||
* hard backstop against runaway loops. Env: FLOCI_SERVICES_APIGATEWAY_VTL_MAX_LOOPS */
|
||||
@WithDefault("10000")
|
||||
int vtlMaxLoops();
|
||||
|
||||
/** Maximum rendered output size, in characters, for a single VTL mapping template render.
|
||||
* Env: FLOCI_SERVICES_APIGATEWAY_VTL_MAX_OUTPUT_CHARS */
|
||||
@WithDefault("1048576")
|
||||
int vtlMaxOutputChars();
|
||||
|
||||
/** Wall-clock execution budget, in milliseconds, for a single VTL mapping template render.
|
||||
* Env: FLOCI_SERVICES_APIGATEWAY_VTL_TIMEOUT_MILLIS */
|
||||
@WithDefault("5000")
|
||||
long vtlTimeoutMillis();
|
||||
}
|
||||
|
||||
interface IamServiceConfig {
|
||||
@@ -1968,6 +1983,21 @@ public interface EmulatorConfig {
|
||||
/** Seconds to wait for in-flight schema workers on shutdown. Env: FLOCI_SERVICES_APPSYNC_SCHEMA_WORKER_SHUTDOWN_TIMEOUT_SECONDS */
|
||||
@WithDefault("30")
|
||||
int schemaWorkerShutdownTimeoutSeconds();
|
||||
|
||||
/** Maximum #foreach loop iterations allowed in a single VTL resolver template render, as a
|
||||
* hard backstop against runaway loops. Env: FLOCI_SERVICES_APPSYNC_VTL_MAX_LOOPS */
|
||||
@WithDefault("10000")
|
||||
int vtlMaxLoops();
|
||||
|
||||
/** Maximum rendered output size, in characters, for a single VTL resolver template render.
|
||||
* Env: FLOCI_SERVICES_APPSYNC_VTL_MAX_OUTPUT_CHARS */
|
||||
@WithDefault("1048576")
|
||||
int vtlMaxOutputChars();
|
||||
|
||||
/** Wall-clock execution budget, in milliseconds, for a single VTL resolver template render.
|
||||
* Env: FLOCI_SERVICES_APPSYNC_VTL_TIMEOUT_MILLIS */
|
||||
@WithDefault("5000")
|
||||
long vtlTimeoutMillis();
|
||||
}
|
||||
|
||||
interface OamServiceConfig {
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package io.github.hectorvent.floci.services.apigateway;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
/**
|
||||
* Wraps a delegate {@link Writer} and throws {@link VtlLimitExceededException} once the total
|
||||
* number of characters written would exceed a configured budget.
|
||||
*
|
||||
* <p>This defends against unbounded VTL template output regardless of cause (a huge
|
||||
* {@code #foreach} range, a single oversized reference, or repeated small writes that add up),
|
||||
* complementing the loop-iteration cap and the execution-time deadline, neither of which observe
|
||||
* output size directly.
|
||||
*/
|
||||
public class BoundedWriter extends Writer {
|
||||
|
||||
private final Writer delegate;
|
||||
private final long maxChars;
|
||||
private long written;
|
||||
|
||||
public BoundedWriter(Writer delegate, long maxChars) {
|
||||
this.delegate = delegate;
|
||||
this.maxChars = maxChars;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(char[] cbuf, int off, int len) throws IOException {
|
||||
if (written + len > maxChars) {
|
||||
throw new VtlLimitExceededException(
|
||||
"VTL template output exceeded the configured size limit of " + maxChars + " characters");
|
||||
}
|
||||
delegate.write(cbuf, off, len);
|
||||
written += len;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
delegate.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
delegate.close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package io.github.hectorvent.floci.services.apigateway;
|
||||
|
||||
import org.apache.velocity.context.InternalContextAdapter;
|
||||
import org.apache.velocity.runtime.directive.Foreach;
|
||||
import org.apache.velocity.runtime.parser.node.Node;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
/**
|
||||
* Drop-in replacement for Velocity's built-in {@code #foreach} directive that checks the current
|
||||
* thread's {@link VtlExecutionGuard} deadline before rendering each loop iteration.
|
||||
*
|
||||
* <p>Registered in place of {@code org.apache.velocity.runtime.directive.Foreach} by
|
||||
* {@link VtlSandbox#installSandboxedForeach(org.apache.velocity.app.VelocityEngine)}, so it applies
|
||||
* identically to every {@code #foreach} loop evaluated by either the API Gateway or the AppSync
|
||||
* VTL engine.
|
||||
*/
|
||||
public class SandboxedForeach extends Foreach {
|
||||
|
||||
@Override
|
||||
protected void renderBlock(InternalContextAdapter context, Writer writer, Node node) throws IOException {
|
||||
VtlExecutionGuard.checkDeadline();
|
||||
super.renderBlock(context, writer, node);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package io.github.hectorvent.floci.services.apigateway;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* Tracks a wall-clock execution deadline for the VTL template render currently in progress on
|
||||
* the calling thread.
|
||||
*
|
||||
* <p>Both {@link VtlTemplateEngine} and the AppSync VTL engine call {@link #begin(Duration)}
|
||||
* immediately before delegating to Velocity's {@code VelocityEngine.evaluate(...)}, and
|
||||
* {@link #end()} in a {@code finally} block right after. {@link SandboxedForeach} calls
|
||||
* {@link #checkDeadline()} before rendering each loop iteration's body, which is what actually
|
||||
* stops a runaway {@code #foreach} (whether over a huge range, or one whose body does something
|
||||
* increasingly expensive per iteration, such as {@code #set} string doubling): each iteration's
|
||||
* own cost grows with the doubling, so the next iteration's check reliably trips shortly after
|
||||
* the configured time budget is crossed, well before memory would otherwise be exhausted.
|
||||
*
|
||||
* <p>A {@link ThreadLocal} is used because template evaluation is synchronous and single-threaded
|
||||
* per call, and Velocity does not offer a per-render context slot for deadline plumbing that both
|
||||
* a custom writer and a custom directive can reach without changing Velocity's own APIs.
|
||||
*/
|
||||
public final class VtlExecutionGuard {
|
||||
|
||||
private static final ThreadLocal<Instant> DEADLINE = new ThreadLocal<>();
|
||||
|
||||
private VtlExecutionGuard() {
|
||||
}
|
||||
|
||||
/** Starts a new deadline, {@code timeout} from now, for the current thread. */
|
||||
public static void begin(Duration timeout) {
|
||||
DEADLINE.set(Instant.now().plus(timeout));
|
||||
}
|
||||
|
||||
/** Clears the current thread's deadline. Must be called after every {@link #begin(Duration)}. */
|
||||
public static void end() {
|
||||
DEADLINE.remove();
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws {@link VtlLimitExceededException} if the current thread has an active deadline that
|
||||
* has already passed. Does nothing if no deadline is active.
|
||||
*/
|
||||
public static void checkDeadline() {
|
||||
Instant deadline = DEADLINE.get();
|
||||
if (deadline != null && Instant.now().isAfter(deadline)) {
|
||||
throw new VtlLimitExceededException("VTL template execution exceeded the configured time limit");
|
||||
}
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package io.github.hectorvent.floci.services.apigateway;
|
||||
|
||||
/**
|
||||
* Thrown when a VTL (Velocity Template Language) template render exceeds one of the configured
|
||||
* sandbox limits: loop iteration count, wall-clock execution time, or rendered output size.
|
||||
*
|
||||
* <p>This is a plain unchecked exception, matching Velocity's own {@code VelocityException}
|
||||
* hierarchy (which also extends {@link RuntimeException}), so it propagates through both the
|
||||
* API Gateway and AppSync VTL engines exactly like any other template rendering failure already
|
||||
* does today, without requiring any new catch or error-mapping logic at their call sites.
|
||||
*/
|
||||
public class VtlLimitExceededException extends RuntimeException {
|
||||
|
||||
public VtlLimitExceededException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package io.github.hectorvent.floci.services.apigateway;
|
||||
|
||||
import org.apache.velocity.app.VelocityEngine;
|
||||
import org.apache.velocity.runtime.RuntimeConstants;
|
||||
import org.apache.velocity.util.introspection.SecureUberspector;
|
||||
|
||||
/**
|
||||
* Applies Floci's VTL reflection sandbox to a {@link VelocityEngine}, shared by both the
|
||||
* API Gateway and AppSync VTL engines.
|
||||
*
|
||||
* <p>Velocity normally reads {@code introspector.uberspect.class} and
|
||||
* {@code introspector.restrict.*} from the classpath resource
|
||||
* {@code org/apache/velocity/runtime/defaults/velocity.properties}, which this project shadows
|
||||
* (see {@code src/main/resources/org/apache/velocity/runtime/defaults/velocity.properties}) to
|
||||
* select {@link SecureUberspector} instead of Velocity's insecure default {@code UberspectImpl}.
|
||||
* That shadowed file is kept for any embedding that resolves the resource normally, but it is
|
||||
* <strong>not</strong> the actual enforcement point in this codebase: under Quarkus's custom
|
||||
* test/runtime classloader, {@code ClassLoader#getResourceAsStream} for that exact path can
|
||||
* resolve to the copy bundled inside the {@code velocity-engine-core} jar instead of this
|
||||
* project's shadowed copy, silently leaving the insecure {@code UberspectImpl} active. This was
|
||||
* confirmed empirically: with only the properties file changed, reflection-escape tests
|
||||
* (e.g. {@code $obj.getClass().forName(...)}) still passed against the vulnerable engine.
|
||||
*
|
||||
* <p>Setting these properties directly on the {@link VelocityEngine} via its Java API, before
|
||||
* {@link VelocityEngine#init()}, is unaffected by that classloader ambiguity, so it is the real,
|
||||
* verified enforcement mechanism. Both {@code VtlTemplateEngine} and {@code AppSyncVtlEngine}
|
||||
* call {@link #restrictIntrospection(VelocityEngine)} before {@code init()} and
|
||||
* {@link #installSandboxedForeach(VelocityEngine)} after {@code init()}.
|
||||
*/
|
||||
public final class VtlSandbox {
|
||||
|
||||
/**
|
||||
* Packages blocked outright: any method call on an object from these packages is rejected,
|
||||
* regardless of which method. {@code java.lang.reflect} and {@code java.lang.invoke} close
|
||||
* off reflective/handle-based sandbox escapes; {@code javax.script} closes off the scripting
|
||||
* engine escape; {@code java.nio.file} closes off filesystem access alongside
|
||||
* {@code java.io.File} below.
|
||||
*/
|
||||
private static final String[] RESTRICTED_PACKAGES = {
|
||||
"java.lang.reflect",
|
||||
"java.lang.invoke",
|
||||
"javax.script",
|
||||
"java.nio.file",
|
||||
};
|
||||
|
||||
/**
|
||||
* Individual classes blocked outright. Mirrors Velocity's own recommended secure-introspector
|
||||
* defaults ({@code Class}, {@code ClassLoader}, {@code Runtime}, {@code ProcessBuilder},
|
||||
* {@code System}, {@code Thread}, etc.), plus {@code java.io.File} so templates cannot read or
|
||||
* write arbitrary files on the host.
|
||||
*/
|
||||
private static final String[] RESTRICTED_CLASSES = {
|
||||
"java.lang.Class",
|
||||
"java.lang.ClassLoader",
|
||||
"java.lang.Compiler",
|
||||
"java.lang.InheritableThreadLocal",
|
||||
"java.lang.Package",
|
||||
"java.lang.Process",
|
||||
"java.lang.ProcessBuilder",
|
||||
"java.lang.Runtime",
|
||||
"java.lang.RuntimePermission",
|
||||
"java.lang.SecurityManager",
|
||||
"java.lang.System",
|
||||
"java.lang.Thread",
|
||||
"java.lang.ThreadGroup",
|
||||
"java.lang.ThreadLocal",
|
||||
"java.net.Socket",
|
||||
"javax.management.MBeanServer",
|
||||
"javax.script.ScriptEngine",
|
||||
"java.io.File",
|
||||
};
|
||||
|
||||
private VtlSandbox() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures {@code engine} to use {@link SecureUberspector} with the restricted
|
||||
* packages/classes above. Must be called before {@link VelocityEngine#init()}.
|
||||
*/
|
||||
public static void restrictIntrospection(VelocityEngine engine) {
|
||||
engine.setProperty(RuntimeConstants.UBERSPECT_CLASSNAME, SecureUberspector.class.getName());
|
||||
for (String pkg : RESTRICTED_PACKAGES) {
|
||||
engine.addProperty(RuntimeConstants.INTROSPECTOR_RESTRICT_PACKAGES, pkg);
|
||||
}
|
||||
for (String cls : RESTRICTED_CLASSES) {
|
||||
engine.addProperty(RuntimeConstants.INTROSPECTOR_RESTRICT_CLASSES, cls);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the built-in {@code #foreach} directive with {@link SandboxedForeach}, so every
|
||||
* loop iteration is subject to {@link VtlExecutionGuard}'s execution deadline check. Must be
|
||||
* called after {@link VelocityEngine#init()} (the built-in directive is only registered during
|
||||
* {@code init()}, so calling this beforehand would have nothing to remove/replace).
|
||||
*/
|
||||
public static void installSandboxedForeach(VelocityEngine engine) {
|
||||
engine.removeDirective("foreach");
|
||||
engine.loadDirective(SandboxedForeach.class.getName());
|
||||
}
|
||||
}
|
||||
+20
-4
@@ -3,6 +3,7 @@ package io.github.hectorvent.floci.services.apigateway;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.github.hectorvent.floci.core.common.vtl.VtlUtilFunctions;
|
||||
import io.github.hectorvent.floci.config.EmulatorConfig;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
@@ -24,11 +25,13 @@ import org.apache.velocity.runtime.resource.ResourceManagerImpl;
|
||||
import org.apache.velocity.runtime.resource.loader.FileResourceLoader;
|
||||
import org.apache.velocity.runtime.resource.loader.StringResourceLoader;
|
||||
import org.apache.velocity.runtime.resource.util.StringResourceRepositoryImpl;
|
||||
import org.apache.velocity.util.introspection.SecureUberspector;
|
||||
import org.apache.velocity.util.introspection.TypeConversionHandlerImpl;
|
||||
import org.apache.velocity.util.introspection.UberspectImpl;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.util.AbstractMap;
|
||||
import java.time.Duration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -46,6 +49,7 @@ import java.util.Set;
|
||||
VtlTemplateEngine.UtilVariable.class,
|
||||
VtlTemplateEngine.ResponseOverride.class,
|
||||
UberspectImpl.class,
|
||||
SecureUberspector.class,
|
||||
TypeConversionHandlerImpl.class,
|
||||
ResourceManagerImpl.class,
|
||||
ResourceCacheImpl.class,
|
||||
@@ -54,6 +58,7 @@ import java.util.Set;
|
||||
StringResourceLoader.class,
|
||||
StringResourceRepositoryImpl.class,
|
||||
Foreach.class,
|
||||
SandboxedForeach.class,
|
||||
Include.class,
|
||||
Parse.class,
|
||||
Macro.class,
|
||||
@@ -67,17 +72,22 @@ public class VtlTemplateEngine {
|
||||
|
||||
private final VelocityEngine engine;
|
||||
private final ObjectMapper objectMapper;
|
||||
private final EmulatorConfig config;
|
||||
|
||||
@Inject
|
||||
public VtlTemplateEngine(ObjectMapper objectMapper) {
|
||||
public VtlTemplateEngine(ObjectMapper objectMapper, EmulatorConfig config) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.config = config;
|
||||
this.engine = new VelocityEngine();
|
||||
engine.setProperty(RuntimeConstants.INPUT_ENCODING, "UTF-8");
|
||||
engine.setProperty(RuntimeConstants.RUNTIME_LOG_NAME, "io.github.hectorvent.floci.vtl");
|
||||
engine.setProperty(RuntimeConstants.RESOURCE_LOADERS, "string");
|
||||
engine.setProperty("resource.loader.string.class",
|
||||
"org.apache.velocity.runtime.resource.loader.StringResourceLoader");
|
||||
engine.setProperty(RuntimeConstants.MAX_NUMBER_LOOPS, config.services().apigateway().vtlMaxLoops());
|
||||
VtlSandbox.restrictIntrospection(engine);
|
||||
engine.init();
|
||||
VtlSandbox.installSandboxedForeach(engine);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,10 +120,16 @@ public class VtlTemplateEngine {
|
||||
vc.put("context", buildContextMap(ctx, override));
|
||||
vc.put("stageVariables", ctx.stageVariables() != null ? ctx.stageVariables() : Map.of());
|
||||
|
||||
StringWriter writer = new StringWriter();
|
||||
engine.evaluate(vc, writer, "apigw-template", template);
|
||||
StringWriter rawWriter = new StringWriter();
|
||||
BoundedWriter writer = new BoundedWriter(rawWriter, config.services().apigateway().vtlMaxOutputChars());
|
||||
VtlExecutionGuard.begin(Duration.ofMillis(config.services().apigateway().vtlTimeoutMillis()));
|
||||
try {
|
||||
engine.evaluate(vc, writer, "apigw-template", template);
|
||||
} finally {
|
||||
VtlExecutionGuard.end();
|
||||
}
|
||||
return new EvaluateResult(
|
||||
writer.toString(),
|
||||
rawWriter.toString(),
|
||||
override.getStatus(),
|
||||
override.getHeader().isEmpty() ? Map.of() : Map.copyOf(override.getHeader()));
|
||||
}
|
||||
|
||||
+17
-3
@@ -1,5 +1,9 @@
|
||||
package io.github.hectorvent.floci.services.appsync.graphql;
|
||||
|
||||
import io.github.hectorvent.floci.config.EmulatorConfig;
|
||||
import io.github.hectorvent.floci.services.apigateway.BoundedWriter;
|
||||
import io.github.hectorvent.floci.services.apigateway.VtlExecutionGuard;
|
||||
import io.github.hectorvent.floci.services.apigateway.VtlSandbox;
|
||||
import io.github.hectorvent.floci.services.appsync.graphql.util.AppSyncUtil;
|
||||
import io.github.hectorvent.floci.services.appsync.graphql.util.VtlErrorSignal;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
@@ -9,6 +13,7 @@ import org.apache.velocity.app.VelocityEngine;
|
||||
import org.apache.velocity.runtime.RuntimeConstants;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -16,9 +21,11 @@ import java.util.Map;
|
||||
public class AppSyncVtlEngine {
|
||||
|
||||
private final VelocityEngine engine;
|
||||
private final EmulatorConfig config;
|
||||
|
||||
@Inject
|
||||
public AppSyncVtlEngine() {
|
||||
public AppSyncVtlEngine(EmulatorConfig config) {
|
||||
this.config = config;
|
||||
this.engine = new VelocityEngine();
|
||||
engine.setProperty(RuntimeConstants.INPUT_ENCODING, "UTF-8");
|
||||
engine.setProperty(RuntimeConstants.RUNTIME_LOG_NAME,
|
||||
@@ -29,7 +36,10 @@ public class AppSyncVtlEngine {
|
||||
engine.setProperty(RuntimeConstants.RUNTIME_REFERENCES_STRICT, false);
|
||||
engine.setProperty("userdirective",
|
||||
"io.github.hectorvent.floci.services.appsync.graphql.ReturnDirective");
|
||||
engine.setProperty(RuntimeConstants.MAX_NUMBER_LOOPS, config.services().appsync().vtlMaxLoops());
|
||||
VtlSandbox.restrictIntrospection(engine);
|
||||
engine.init();
|
||||
VtlSandbox.installSandboxedForeach(engine);
|
||||
}
|
||||
|
||||
public AppSyncVtlResult evaluate(String template, AppSyncVtlContext ctx) {
|
||||
@@ -51,7 +61,9 @@ public class AppSyncVtlEngine {
|
||||
vc.put("util", util);
|
||||
vc.put("utils", util);
|
||||
|
||||
StringWriter writer = new StringWriter();
|
||||
StringWriter rawWriter = new StringWriter();
|
||||
BoundedWriter writer = new BoundedWriter(rawWriter, config.services().appsync().vtlMaxOutputChars());
|
||||
VtlExecutionGuard.begin(Duration.ofMillis(config.services().appsync().vtlTimeoutMillis()));
|
||||
try {
|
||||
engine.evaluate(vc, writer, "appsync-template", template);
|
||||
} catch (ReturnSignal signal) {
|
||||
@@ -65,9 +77,11 @@ public class AppSyncVtlEngine {
|
||||
cause = cause.getCause();
|
||||
}
|
||||
throw new RuntimeException("VTL evaluation failed", e);
|
||||
} finally {
|
||||
VtlExecutionGuard.end();
|
||||
}
|
||||
|
||||
return new AppSyncVtlResult(writer.toString(), null, ctx.getAppendedErrors());
|
||||
return new AppSyncVtlResult(rawWriter.toString(), null, ctx.getAppendedErrors());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user