|
NAMEText::MicroMason::Safe - Compile all Templates in a Safe CompartmentSYNOPSISInstead of using this class directly, pass its name to be mixed in:use Text::MicroMason; my $mason = Text::MicroMason->new( -Safe ); Use the standard compile and execute methods to parse and evaluate templates: print $mason->compile( text=>$template )->( @%args ); print $mason->execute( text=>$template, @args ); Safe usage restricts templates from accessing your files or data: print $mason->execute( text=>"<% qx! cat /etc/passwd ! %>" ); # dies print $mason->execute( text=>"The time is <% time() %>." ); # dies DESCRIPTIONThis package adds support for Safe compartments to MicroMason, allowing you to restrict the operations that a template can perform.By default, these safe calls prevent the code in a template from performing any system activity or accessing any of your other Perl code. Violations may result in either compile-time or run-time errors, so make sure you are using an eval block or the CatchErrors trait to catch exceptions. use Text::MicroMason; my $mason = Text::MicroMason->new( -Safe ); $result = eval { $mason->execute( text => $template ) }; Caution: Although this appears to provide a significant amount of security for untrusted templates, please take this with a grain of salt. A bug in either this module or in the core Safe module could allow a clever attacker to defeat the protection. At least one bug in the Safe module has been found and fixed in years past, and there could be others. Supported Attributes
Private Methods
Private Safe::Facade classCode compiled in a Safe compartment only has access to a limited version of the template compiler in the $m variable, and can not make changes to the attributes of the real MicroMason object. This limited object is an instance of the Text::MicroMason::Safe::Facade class and can only perform certain pre-defined methods.
SEE ALSOFor an overview of this templating framework, see Text::MicroMason.This is a mixin class intended for use with Text::MicroMason::Base. For distribution, installation, support, copyright and license information, see Text::MicroMason::Docs::ReadMe.
Visit the GSP FreeBSD Man Page Interface. |