I m working on a webapp to teach programming concepts. Webpages have some text about a programming concept, then let the user type in javascript code into a text editor window to try to answer a programming problem. When the user clicks "submit", I analyse the text they ve typed to see if they have solved the problem. For example, I ask them to "write a function named f
that adds three to its argument".
这里,我做的是分析用户案文:
- Run JSLint on the text with strict settings, in particular without assuming browser or console functions.
- If there are any errors, show the errors and stop.
eval(usertext);
- Loop through conditions for passing the assignment,
eval(condition)
. An example condition is"f(1)===4"
. Conditions come from trusted source. - Show passing/failing conditions.
我的问题:这是否足以防止安全问题? 我可以做些什么? 是否有更好的办法去做我想要的东西?
如果是相关的,我的申请是在谷歌应用引擎上,使用JQuery,有个人用户账户。