How dangerous is it to let users specify RazorEngine templates?

前端 未结 3 1639
无人及你
无人及你 2021-01-12 08:06

I have mail-merge like functionality, which takes a template, some business object, and produces html which is then made into PDF.

I\'m using RazorEngine to do the t

3条回答
  •  隐瞒了意图╮
    2021-01-12 08:40

    In version 3 I've introduced an IsolatedTemplateService which supports the parsing/compiling of templates in another AppDomain. You'll be able to control the creation of the application domain that templates will be compiled in, which means you can introduce whatever security requirements you want by applying security policies to the child application domain itself.

    In future pushes, I am hoping to introduce a generic way for adding extensions to the pipeline, so you can do things like code generation inspection. I would imagine this will enable scenarios for type checking of the generated code before it is compiled.

    I pushed an early version of RazorEngine (v3) onto GitHub a few days ago. Feel free to check it out. https://github.com/Antaris/RazorEngine

提交回复
热议问题