Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eval is used, which is unsafe #40

Open
eric-wieser opened this issue Feb 25, 2016 · 5 comments
Open

eval is used, which is unsafe #40

eric-wieser opened this issue Feb 25, 2016 · 5 comments

Comments

@eric-wieser
Copy link

In the following places:

What type of input is this trying to parse?

@eric-wieser
Copy link
Author

All the cases seem to be eval(str(x)). Is this:

  • Trying to be copy.copy?
  • Trying to be float?
  • Deliberately trying to support expression input in text form(ie, 1+2*3?

Whichever this it, it's a bad idea for two reasons:

  • Pushing floats through string form is inefficient and precision losing
  • You probably don't want to execute arbitrary python code passed in from a config file

@vrabaud
Copy link
Contributor

vrabaud commented Feb 25, 2016

Well, I don't know that Python style. That's a question to ask @mikeferguson :) Thx

@mikeferguson
Copy link
Member

This actually predates me -- I just moved things around and tried to parameterize and clean up -- in particular I think this is for lines like: https://github.com/PR2/pr2_calibration/blob/hydro-devel/pr2_calibration_launch/estimate_params/config_pr2_beta/system.yaml#L109 where it has to evaluate "pi/2"

@vrabaud
Copy link
Contributor

vrabaud commented Feb 25, 2016

good catch ! That .yaml is a custom format right ? Maybe we can just parse pi properly and that''s it.
eval can be a security issue like ros-perception/vision_opencv#112

@eric-wieser
Copy link
Author

Is pi the only global that should be accessible in the expression? Or should we expose all of math.*? Right now, there are way more constants accesible than makes sense. Something like this would work:

https://stackoverflow.com/questions/2371436/evaluating-a-mathematical-expression-in-a-string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants