import {
JSAstValidator,
DisallowedIdentifierRule,
ForbiddenLoopRule,
RequiredFunctionCallRule,
UnknownGlobalRule,
} from '@enclave-vm/ast';
const customValidator = new JSAstValidator([
new DisallowedIdentifierRule({
disallowed: ['eval', 'Function', 'process', 'require'],
}),
new ForbiddenLoopRule({
allowFor: true,
allowWhile: false,
}),
new RequiredFunctionCallRule({
required: ['callTool'],
minCalls: 1,
}),
new UnknownGlobalRule({
allowedGlobals: ['callTool', 'Math', 'JSON', 'Array', 'Object'],
allowStandardGlobals: true,
}),
]);
const result = await customValidator.validate(code);