You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I just remembered that any valid assignment target can be used in a list comprehension! i.e. something like [... for foo[0] in ...] is valid syntax.
Expected behavior
>>> [xforxin ([None],) forx[0] in (15,)]
[[15]]
Actual behavior
>>>EvalWithCompoundTypes('[x for x in ([None],) for x[0] in (15,)]')
Traceback (mostrecentcalllast):
File"<stdin>", line1, in<module>File"LIBPATH/simpleeval.py", line539, inevalreturnsuper(EvalWithCompoundTypes, self).eval(expr)
File"LIBPATH/simpleeval.py", line332, inevalreturnself._eval(ast.parse(expr.strip()).body[0].value)
File"LIBPATH/simpleeval.py", line343, in_evalreturnhandler(node)
File"LIBPATH/simpleeval.py", line597, in_eval_comprehensiondo_generator()
File"LIBPATH/simpleeval.py", line592, indo_generatordo_generator(gi+1)
File"LIBPATH/simpleeval.py", line589, indo_generatorrecurse_targets(g.target, i)
File"LIBPATH/simpleeval.py", line579, inrecurse_targetsfort, vinzip(target.elts, value):
AttributeError: 'Subscript'objecthasnoattribute'elts'
The text was updated successfully, but these errors were encountered:
That's... fun - definitely something to handle better than that!
I'm not tooooo worried about it, it's a bug, in that it throws a non-SimpleEval exception, but I don't believe there are any security implications.
Although, it would be good to add to the documentation that users should probably wrap any public facing usage of SimpleEval in a try:catch and log errors themselves...?
Hah, wow, that's an old one! I haven't done Python in a couple years so thanks for the reminder, this was a fun hack. I'm not sure if exploitability is a big worry here... i guess this circularity construction could maaaaaaybe be used as a DoS vector somehow. But i don't currently have ideas for how that'd work.
simpleeval 0.9.10
So I just remembered that any valid assignment target can be used in a list comprehension! i.e. something like
[... for foo[0] in ...]
is valid syntax.Expected behavior
Actual behavior
The text was updated successfully, but these errors were encountered: