Skip to content

Conversation

@t-yuki
Copy link

@t-yuki t-yuki commented Dec 16, 2024

In this PR, we add new syscall rules to allow use of fetch async function in Nodejs runtime.

Also, Code template in dify api should be replaced by:

        runner_script = dedent(
            f"""
            // declare main function
            {cls._code_placeholder}
            
            // decode and prepare input object
            var inputs_obj = JSON.parse(Buffer.from('{cls._inputs_placeholder}', 'base64').toString('utf-8'))
            
            // execute main function
            async function wrap() {"{"}
            var output_obj = await main(inputs_obj)
            
            // convert output to json and print
            var output_json = JSON.stringify(output_obj)
            var result = `<<RESULT>>${{output_json}}<<RESULT>>`
            console.log(result)
            {"}"}
            wrap()
            """
        )

see: https://github.com/langgenius/dify/blob/7f095bdc42bc9482304c4e4f937d9b72b3aa9759/api/core/helper/code_executor/javascript/javascript_transformer.py#L9

Note that, arm64 arch support is not tested yet.

@t-yuki
Copy link
Author

t-yuki commented Dec 16, 2024

Well, the test for malicious commands is failing. We must distinglish nodejs internal fork and child_process spawn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant