Safe reader for Elixir-syntax data files (.vulncheck.exs, .vulncheck.ignore,
mix.lock, mix.exs, config/*.exs).
Files are parsed with Code.string_to_quoted/2 and a static atom encoder, so
no atoms are created and no code is ever evaluated. Literal values are
converted into a neutral term representation:
- atoms become
{:atom, "name"}(exceptnil,trueandfalse) - module aliases become
{:alias, "Elixir.Mod.Name"} - tuples become
{:tuple, [elements]} - maps become
{:map, [{key, value}]}(insertion order preserved) - strings, numbers and lists are kept as they are
Any other expression (function calls, variables, operators, ...) is rejected
with {:error, {:unsafe_expression, line, code}} by to_term/1.
Summary
Functions
Converts an __aliases__ AST node into its canonical module string, or nil.
Returns true if the encoded AST node is the given atom literal.
Returns the name of an encoded atom AST node, or nil.
Converts a literal keyword list into [{key_string, value}], or :error.
Looks up a key in a keyword-like literal list ([{{:atom, key}, value}]).
Parses a source string and converts it into a literal term.
Reads and parses a file into a literal term.
Parses source into an encoded AST without creating atoms.
Converts an encoded AST into a literal term, rejecting any executable code.
Types
Functions
Converts an __aliases__ AST node into its canonical module string, or nil.
Returns true if the encoded AST node is the given atom literal.
Returns the name of an encoded atom AST node, or nil.
Converts a literal keyword list into [{key_string, value}], or :error.
Looks up a key in a keyword-like literal list ([{{:atom, key}, value}]).
Parses a source string and converts it into a literal term.
Reads and parses a file into a literal term.
Parses source into an encoded AST without creating atoms.
Converts an encoded AST into a literal term, rejecting any executable code.