AOS-GUI / AOS-GUI

AOS-GUI: A cross-platform shell for modern computers
https://aos-gui.github.io/
MIT License
8 stars 2 forks source link

Calculator Enhancement: Math Functions #3

Open JhonySousa opened 1 year ago

JhonySousa commented 1 year ago

Enable support for math functions, such as cos, acos etc..

This could be achieved by using exec instead of eval, enabling the user to type alpha numeric characters in to the input text. The problem will be that this will allow the user to type any valid python code, witch dangerous... To avoid this code execution it is possible to first parse the input code into an AST using the ast builtin python module (ref https://docs.python.org/3/library/ast.html). Then, scan each Call Node, allowing only those present on the math module...

Expanding this idea, maybe it's possible to allow the use store variables inside an controlled scope and add suport to lambdas!

Nanobot567 commented 1 year ago

This sounds like something that could be done easily enough! I think that it's possible to change the scope of exec() so users could write python code, but disallow them access to system functions