refactor(Code Node): Remove disallowed syntax checks (#5332)

🔥 Remove disallowed syntax checks in Code node
This commit is contained in:
Iván Ovejero 2023-02-02 10:11:36 +01:00 committed by GitHub
parent f9ecc34b10
commit 0f228a60ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -48,30 +48,6 @@ export class Sandbox extends NodeVM {
private async runCodeAllItems() {
const script = `module.exports = async function() {${this.jsCode}\n}()`;
const match = script.match(
/(?<disallowedSyntax>\)\.item(?!Matching)|\$input\.item(?!Matching)|\$json|\$binary|\$itemIndex)/,
); // disallow .item but tolerate .itemMatching
if (match?.groups?.disallowedSyntax) {
const { disallowedSyntax } = match.groups;
const lineNumber =
this.jsCode.split('\n').findIndex((line) => {
return line.includes(disallowedSyntax) && !line.startsWith('//') && !line.startsWith('*');
}) + 1;
const disallowedSyntaxFound = lineNumber !== 0;
if (disallowedSyntaxFound) {
throw new ValidationError({
message: `Can't use ${disallowedSyntax} here`,
description: "This is only available in 'Run Once for Each Item' mode",
itemIndex: this.itemIndex,
lineNumber,
});
}
}
let executionResult;
try {