fix(core): Allow $evaluateExpression to resolve in task runners (#14641)

This commit is contained in:
Iván Ovejero
2025-04-15 20:27:26 +02:00
committed by GitHub
parent 57444d3a16
commit 7c1be05845
3 changed files with 11 additions and 31 deletions

View File

@@ -49,17 +49,6 @@ setErrorHandler((error: Error) => {
if (isExpressionError(error)) throw error;
});
const AsyncFunction = (async () => {}).constructor as FunctionConstructor;
const fnConstructors = {
sync: Function.prototype.constructor,
async: AsyncFunction.prototype.constructor,
mock: () => {
throw new ExpressionError('Arbitrary code execution detected');
},
};
export class Expression {
constructor(private readonly workflow: Workflow) {}
@@ -217,8 +206,6 @@ export class Expression {
data.Reflect = {};
data.Proxy = {};
data.constructor = {};
// Deprecated
data.escape = {};
data.unescape = {};
@@ -345,10 +332,6 @@ export class Expression {
data: IWorkflowDataProxyData,
): tmpl.ReturnValue | undefined {
try {
[Function, AsyncFunction].forEach(({ prototype }) =>
Object.defineProperty(prototype, 'constructor', { value: fnConstructors.mock }),
);
return evaluateExpression(expression, data);
} catch (error) {
if (isExpressionError(error)) throw error;
@@ -362,11 +345,6 @@ export class Expression {
throw new ApplicationError(match.groups.msg);
}
} finally {
Object.defineProperty(Function.prototype, 'constructor', { value: fnConstructors.sync });
Object.defineProperty(AsyncFunction.prototype, 'constructor', {
value: fnConstructors.async,
});
}
return null;