mirror of https://github.com/abpframework/abp.git
Browse Source
ITemplateRenderingEngine exposes a new IsSandboxed property so callers can decide whether editing a template requires elevated trust. - TemplateRenderingEngineBase provides a virtual default of false (secure-by-default) - RazorTemplateRenderingEngine declares IsSandboxed=false (compiles to .NET assembly via Roslyn) - ScribanTemplateRenderingEngine declares IsSandboxed=true (DSL without .NET interop) - Razor integration docs and TextTemplateManagement docs document the implications - Migration guide for ABP 10.4 documents the new abstraction memberpull/25399/head
9 changed files with 197 additions and 0 deletions
@ -0,0 +1,29 @@ |
|||
using Shouldly; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Abp.TextTemplating.Razor; |
|||
|
|||
public class RazorTemplateRenderingEngine_IsSandboxed_Tests : AbpTextTemplatingTestBase<RazorTextTemplatingTestModule> |
|||
{ |
|||
private readonly RazorTemplateRenderingEngine _engine; |
|||
|
|||
public RazorTemplateRenderingEngine_IsSandboxed_Tests() |
|||
{ |
|||
_engine = GetRequiredService<RazorTemplateRenderingEngine>(); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Razor_Engine_Should_Not_Be_Sandboxed() |
|||
{ |
|||
// Razor templates compile into fully-trusted .NET code; editing them is
|
|||
// equivalent to granting server-side code execution.
|
|||
_engine.IsSandboxed.ShouldBeFalse(); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Razor_Engine_Should_Expose_IsSandboxed_Through_Interface() |
|||
{ |
|||
ITemplateRenderingEngine asInterface = _engine; |
|||
asInterface.IsSandboxed.ShouldBeFalse(); |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
using Shouldly; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Abp.TextTemplating.Scriban; |
|||
|
|||
public class ScribanTemplateRenderingEngine_IsSandboxed_Tests : AbpTextTemplatingTestBase<ScribanTextTemplatingTestModule> |
|||
{ |
|||
private readonly ScribanTemplateRenderingEngine _engine; |
|||
|
|||
public ScribanTemplateRenderingEngine_IsSandboxed_Tests() |
|||
{ |
|||
_engine = GetRequiredService<ScribanTemplateRenderingEngine>(); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Scriban_Engine_Should_Be_Sandboxed() |
|||
{ |
|||
// Scriban interprets templates as a restricted DSL without .NET interop;
|
|||
// editing template content is safe for non-developer users.
|
|||
_engine.IsSandboxed.ShouldBeTrue(); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Scriban_Engine_Should_Expose_IsSandboxed_Through_Interface() |
|||
{ |
|||
ITemplateRenderingEngine asInterface = _engine; |
|||
asInterface.IsSandboxed.ShouldBeTrue(); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue