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:
+29
-8
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user