From 677fb3542700e5ad71ca3d8a1259cef9deb5bb18 Mon Sep 17 00:00:00 2001 From: Faraphel Date: Wed, 27 Jul 2022 20:31:19 +0200 Subject: [PATCH] added dict to safe_eval --- source/safe_eval.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/safe_eval.py b/source/safe_eval.py index 0ebb912..5985ed0 100644 --- a/source/safe_eval.py +++ b/source/safe_eval.py @@ -5,14 +5,14 @@ common_token_map = { # these operators and function are considered safe to use operator: operator for operator in [">=", "<=", "<<", ">>", "+", "-", "*", "/", "%", "**", ",", "(", ")", "[", "]", "==", "!=", "in", ">", "<", - "and", "or", "&", "|", "^", "~", ":", "isinstance", "issubclass", "not", "is", "if", "else", "abs", "int", + "and", "or", "&", "|", "^", "~", ":", "{", "}", "isinstance", "issubclass", "not", "is", "if", "else", "abs", "int", "bin", "hex", "oct", "chr", "ord", "len", "str", "bool", "float", "round", "min", "max", "sum", "zip", "any", "all", "reversed", "enumerate", "list", "sorted", "hasattr", "for", "range", "type", "repr", "None", - "True", "False", "getattr" + "True", "False", "getattr", "dict" ] } | { # these methods are considered safe, except for the magic methods f".{method}": f".{method}" - for method in dir(str) + dir(list) + dir(int) + dir(float) + for method in dir(str) + dir(list) + dir(int) + dir(float) + dir(dict) if not method.startswith("__") }