Using ast and whitelists to make python's eval() safe?

后端 未结 2 1688
醉话见心
醉话见心 2021-02-04 18:23

OK. I know the experts have spoken and you should not ever use python\'s eval() on untrusted data, ever. I\'m not smarter than the rest of the world, and s

2条回答
  •  暖寄归人
    2021-02-04 18:56

    Zope has a thing called RestrictedPython, you may want to check it, at least to validate your approach or possibly reuse their code. It is configurable and re-usable.

    Here's my other answer to a similar question.

提交回复
热议问题