ExMCP.Server.Tools.ASTValidator (ex_mcp v0.10.0)
View SourceValidates AST nodes to ensure they are safe for evaluation.
This module provides security validation for AST nodes that will be evaluated using Code.eval_quoted, preventing code injection attacks.
Summary
Functions
Validates that an AST node contains only safe constructs.
Functions
Validates that an AST node contains only safe constructs.
Returns {:ok, ast} if the AST is safe, or {:error, reason} if unsafe constructs are detected.
Examples
iex> ASTValidator.validate_schema_ast({:%{}, [], [type: "string"]})
{:ok, {:%{}, [], [type: "string"]}}
iex> ASTValidator.validate_schema_ast({:eval, [], ["dangerous code"]})
{:error, "Unsafe AST node: eval"}