Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
make eval() safe
#5
(Mar-22-2022, 05:29 PM)Skaperen Wrote: i want to protect more than just the system. for example, a web server in Python running some untrusted code with a call to "exit()". preventing this was my first thought.
danthedeckie Wrote:Or if you want to allow simple formulae in a web application, but don't want to give full eval() access,
or don't want to run in javascript on the client side
That's one usage case.

Maybe your doing stuff you should not do in first placešŸ’„
Don't know if you have looked into Template engine as eg Jinja .
Has safe way to render code on server and also call stuff tough macros.
jinja Wrote:
  • Template inheritance and inclusion.
  • Define and import macros within templates.
  • HTML templates can use autoescaping to prevent XSS from untrusted user input.
  • A sandboxed environment can safely render untrusted templates.
    .....
Reply


Messages In This Thread
make eval() safe - by Skaperen - Mar-22-2022, 02:43 AM
RE: make eval() safe - by deanhystad - Mar-22-2022, 03:59 AM
RE: make eval() safe - by snippsat - Mar-22-2022, 03:20 PM
RE: make eval() safe - by Skaperen - Mar-22-2022, 05:29 PM
RE: make eval() safe - by snippsat - Mar-22-2022, 07:15 PM
RE: make eval() safe - by Skaperen - Mar-24-2022, 05:47 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  is this string shell quote safe? Skaperen 2 2,215 Feb-18-2020, 12:56 AM
Last Post: Skaperen
  eval() function security Skaperen 8 3,918 Sep-23-2019, 04:32 AM
Last Post: Skaperen
  after py2 EOL, is it safe to repoint python? Skaperen 6 3,405 Sep-14-2019, 10:37 AM
Last Post: snippsat
  safe text to html Skaperen 10 11,865 Jul-07-2017, 04:23 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020