Run vulnerable operation in isolated environment (#18523)

When driver = LAMBDA:
- run esbuild ts transpilation on dedicated lambda
- run yarn install on app dependencies on a dedicated lambda
This commit is contained in:
martmull
2026-03-11 15:08:47 +01:00
committed by GitHub
parent b346f4fb59
commit d9b3507866
21 changed files with 2036 additions and 154 deletions
@@ -1,5 +1,7 @@
import { Injectable } from '@nestjs/common';
import crypto from 'crypto';
import { v4 } from 'uuid';
import { isDefined } from 'twenty-shared/utils';
import { SEED_LOGIC_FUNCTION_INPUT_SCHEMA } from 'twenty-shared/logic-function';
@@ -302,14 +304,33 @@ export class LogicFunctionFromSourceService {
workspaceId,
});
const { checksum } =
await this.logicFunctionResourceService.buildFromSourceFile({
workspaceId,
applicationUniversalIdentifier:
ownerFlatApplication.universalIdentifier,
sourceHandlerPath: flatLogicFunction.sourceHandlerPath,
builtHandlerPath: flatLogicFunction.builtHandlerPath,
});
const sourceCode = await this.logicFunctionResourceService.getSourceFile({
workspaceId,
applicationUniversalIdentifier: ownerFlatApplication.universalIdentifier,
sourceHandlerPath: flatLogicFunction.sourceHandlerPath,
});
if (!sourceCode) {
throw new LogicFunctionException(
'Source file not found',
LogicFunctionExceptionCode.LOGIC_FUNCTION_NOT_FOUND,
);
}
const { builtCode } = await this.logicFunctionExecutorService.transpile({
sourceCode,
sourceFileName: flatLogicFunction.sourceHandlerPath,
builtFileName: flatLogicFunction.builtHandlerPath,
});
await this.logicFunctionResourceService.uploadBuiltFile({
workspaceId,
applicationUniversalIdentifier: ownerFlatApplication.universalIdentifier,
builtHandlerPath: flatLogicFunction.builtHandlerPath,
builtCode,
});
const checksum = crypto.createHash('md5').update(builtCode).digest('hex');
await this.helperService.updateOneFromMetadata({
flatLogicFunctionToUpdate: {