This extension lets you write your own JavaScript code that runs when AI characters say certain things. The code on this line is how it runs your code. That's exactly what the extension is supposed to do, and you choose what code to run. It's like giving the AI a remote control that only presses buttons you set up beforehand.
Technical evidence
Scanner reason: OpenGrep matched static-analysis rule tavernkeeper.dynamic-execution.javascript-eval in this repository.
Contextual assessment: The `Function(javascript)()` call on line 103 executes user-authored JavaScript stored in the extension's settings. This is the core, transparently documented purpose of the Sorcery extension: enabling users to bind arbitrary JavaScript code to chat events. The execution path is entirely controlled by the user through the settings UI. The streaming hook (onProgressStreaming) only parses script IDs from AI-generated markers and selects pre-existing user-written scripts; it never injects code from the model output. No concealed execution, obfuscation, or unintended data exfiltration is present. The risk of self-harm from running user's own code is inherent and expected.
This extension is designed to run code that you write yourself. The AI can't make up its own code, it can only trigger one of the scripts you've already set up. So using Function() here is exactly the intended way to run those scripts.
Technical evidence
Scanner reason: JavaScript analysis matched static JavaScript security signal javascript.xray.unsafe-stmt in this repository.
Contextual assessment: The Function() constructor on line 103 executes JavaScript code stored in the user's script configuration. The variable `javascript` originates from `script.javascript`, which is user-defined through the extension's settings UI and persisted locally. The extension's stated purpose is to execute user-configured scripts triggered by AI-generated markers in streaming responses. The model cannot inject arbitrary code; it can only select among pre-configured scripts by ID. There is no evidence that `javascript` is derived from untrusted input, network sources, or AI output. The code is plainly visible and directly implements the intended functionality described in the project's README.