Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Is it possible to validate script syntax before executing it?

0
0
Hi Tomaso,

is it a design choice to prevent syntax checking and script compilation from being called independently from script execution?

Originally ClearScript supported only JScript and VBScript. As far as we know, these script engines don't have syntax checking APIs, nor do they support compilation. V8 supports compilation, so we added V8ScriptEngine.Compile().

But if execution leads to side effects on host objects, I'd prefer to make a syntax check before exec instead of realizing that script was wrong once several host objects have been changed.

A script with syntax errors can't be executed, so it can't have harmful side effects. On the other hand, if a script originates from an untrusted source, checking its syntax won't guarantee that it's bug free and won't abuse your host objects. The best approach is to expose a host API that prevents scripts from doing damage by exposing read-only operations when possible, enforcing limits, etc.

Please send us your further thoughts.

Happy New Year!

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images