Run timeout for Engine.Razor.Run[Compile]
I didn't found Timeout option for RunCompile/Run methods. Not present in configurator either. So Im a little bit in a pinch when it comes to running untrusted code, for example:
while(true){};
It will run forever.
Where exactly are you seeing this?
I see this when executing compiled (by razor) dll. For now Im just running it in separated thread and Abort() it to prevent further execution if it times out after one minute.
Do you have an example?
Create file example.cshtml with this content:
@
{
while(true){};
}
And RunCompile it.
Yeh that'll break.
I'm not sure if the MS razor engine offers a timeout option.
But, surely all the code should be "trusted" you wouldn't be putting in random views into your code would you?
I stated, that this code will be untrusted - it means I give users rights to modify it. It is used for report generation, and I try not to protect code against hacker or malicious behaviors but from accidents when user made a bug and template will be stuck/overflowed/execute something bad, etc.
With a lack of anything here (or in the MS version).
You could write your own, using cancellation tokens? Or set your own timeout