An open API service indexing awesome lists of open source software.

https://github.com/mkende/perl-eval-safe

Simplified safe evaluation of Perl code
https://github.com/mkende/perl-eval-safe

Last synced: 3 months ago
JSON representation

Simplified safe evaluation of Perl code

Awesome Lists containing this project

README

          

=head1 Eval::Safe - Simplified safe evaluation of Perl code

=head2 DESCRIPTION

B is a Perl module to allow executing Perl code like with the
B function, but in isolation from the main program. This is similar to the
L module, but faster, as we don't try to be safe.

=head2 DOCUMENTATION

The standard L module does 4 things when running user-provided code:
compiling and running the string as Perl code; running the code in a specific
package so that variables in the calling code are not modified by mistake;
hiding all the existing packages so that the executed code cannot modify them;
and limiting the set of operations that can be executed by the code to further
try to make it safe (prevents it from modifying the system, etc.).

By comparison, the B module here only does the first two of these
things (compiling the code and changing the namespace in which it is executed)
to make it conveniant to run user-provided code, as long as you can trust that
code. The benefit is that this is around three times faster than using L
(especially for small pieces of code).

The documentation for the module can be found on L.
After the module is installed, you can also get its documentation by running
B (this usually comes in a B package on most
systems).

=head2 INSTALLATION

=head3 Requirements

Building and installing this module only requires Perl modules from the
standard library. So as long as you have Perl installed (which should be the
case by default on almost all system), you should be able to install it using
one of the method below. This module requires Perl version 5.22 or above. You
can check which Perl you have installed with the following command:

perl -v

=head3 Installing from the Git sources

To install this module manually from Git, you can run the following commands
(you do need to have the B and B program installed):

git clone https://github.com/mkende/perl-eval-safe.git
cd perl-eval-safe
perl Makefile.PL
make
make test
sudo make install

=head3 Installing from CPAN

This module is available on CPAN (the Perl package manager). The CPAN command
should be installed on any system that has Perl (which, again, should mostly be
any system at all). So, to install the module automatically using CPAN, you can
just run the following command:

cpan Eval::Safe

Note: if this is the first time that you run the B command, you will be
asked to configure it. The default answer to most questions is usually fine.

=head2 DISTRIBUTION

The main development of this software is done on
L. However, it is also
available on CPAN.

The following can be used only by the module maintainer on CPAN. To update the
CPAN module, remember to increment the version number and then run the following
commands:

perl Makefile.PL
make distcheck
# Optionally, to add files not in the manifest:
# make manifest
make dist

Finally, upload the F.tar.gz> file that has been created
through L, ideally putting it under an
F directory.