A full-scale PHP 5.3.2+ sandbox class that utilizes PHPParser lớn prevent sandboxed code from running unsafe code.


Launching Visual Studio Code Your codespace will open once ready.

Bạn đang xem: Github

There was a problem preparing your codespace, please try again.


*

##DEPRECATED: The PHPSandbox project has transfered lớn Corveda/PHPSandbox và will be actively maintained there. This branch is no longer being actively maintained. Update your dependencies as follows:


##A full-scale PHP 5.3.2+ sandbox class that utilizes PHP-Parser to lớn prsự kiện sandboxed code from running unsafe code.

It also utilizes FunctionParser lớn disassemble callables passed khổng lồ the sandbox, so that PHP.. callables can also be run in sandboxes without first converting them inkhổng lồ strings.

Xem thêm: Top 20+ Vay Tiền Online Uy Tín Nhanh Chóng, Vay Tiền Nhanh Online

Manual: http://manual.phpsandbox.org

Online API Documentation: http://docs.phpsandbox.org

*
*
*
*
*
*

##Features:

Finegrained whitelisting và blacklisting, with sensible defaults configured.Includes dynamic demonstration system that allows for local testing of custom sandbox configurationsCan redefine internal PHP & other functions lớn make them more secure for sandbox usage.Can redefine superglobals và magic constants to expose your own values khổng lồ sandboxed code.Can overwrite the get_defined_* và get_declared_* functions to show only allowed functions, classes, etc. khổng lồ the sandboxed code.Can selectively allow and disallow function creation, class declarations, constant definitions, từ khoá, & much more.Can prepkết thúc and appkết thúc trusted code to lớn thiết lập and tear down the sandbox, và automatically whitecác mục the classes, functions, variables, etc. they define for the sandbox.Can retrieve the generated sandbox code for later usage.Can pass arguments directly to lớn the sandboxed code through the exexinh đẹp method to lớn reveal chosen outside variables to the sandbox.Can access the parsed, prepared và generated code ASTs for further analysis or for serialization.Can define custom validation functions for fine-grained control of every element of the sandbox.Can specify a custom error handler to lớn intercept PHP errors & handle them with custom súc tích.Can specify a custom exception handler to lớn intercept thrown exceptions và handle them with custom xúc tích.Can specify a validation error handler lớn intercept thrown validation errors and handle them with custom ngắn gọn xúc tích.Can intercept callbacks & validate them against function whitelists và blacklists, even if they are called as strings

##Example usage:


whitelist_func("test");$result = $sandbox->execute(function() return test("world"););var_dump($result); //Hello world">

function test($string) return "Hello " . $string;$sandbox = new PHPSandboxPHPSandbox;$sandbox->whitelist_func("test");$result = $sandbox->execute(function() return test("world"););var_dump($result); //Hello world
##Custom validation example:


set_func_validator(function($function_name, PHPSandboxPHPSandbox $sandbox) return (substr($function_name, 0, 7) == "custom_"); //return true if function is valid, false otherwise);$sandbox->execute(function() custom_func(););//echoes "I am valid!"">

function custom_func() emang đến "I am valid!";$sandbox = new PHPSandboxPHPSandbox;//this will mark any function valid that begins with "custom_"$sandbox->set_func_validator(function($function_name, PHPSandboxPHPSandbox $sandbox) return (substr($function_name, 0, 7) == "custom_"); //return true if function is valid, false otherwise);$sandbox->execute(function() custom_func(););//echoes "I am valid!"
##Custom validation error handler example:


set_validation_error_handler(function(PHPSandboxError $error, PHPSandboxPHPSandbox $sandbox) if($error->getCode() == PHPSandboxError::PARSER_ERROR) //PARSER_ERROR == 1 exit; throw $error;);$sandbox->execute("");//does nothing">

$sandbox = new PHPSandboxPHPSandbox;//this will intercept parser validation errors và quietly exit, otherwise it will throw the validation error$sandbox->set_validation_error_handler(function(PHPSandboxError $error, PHPSandboxPHPSandbox $sandbox) if($error->getCode() == PHPSandboxError::PARSER_ERROR) //PARSER_ERROR == 1 exit; throw $error;);$sandbox->execute("");//does nothing
##Disable validation example:


set_option("validate_functions", false); // or $sandbox->validate_functions = false;$sandbox->execute("");//Pinging google.com. . .">

$sandbox = new PHPSandboxPHPSandbox;//this will disable function validation$sandbox->set_option("validate_functions", false); // or $sandbox->validate_functions = false;$sandbox->execute("");//Pinging google.com. . .

Xem thêm: Download Phần Mềm Photoshop Cs6 Full Crack 64Bit & Hướng Dẫn Cài Đặt


##Requirements

PHPhường 5.3.2+PHPhường should be compiled with --enable-tokenizer option (it typically is)

##Installation

To install using composer, simply add the following to your composer.json tệp tin in the root of your project:


"minimum-stability": "dev", "require": "fieryprophet/php-sandbox": "1.3.*"
Then run composer install --dry-run khổng lồ kiểm tra for any potential problems, and composer install to install.

##LICENSE



Chuyên mục: Điện máy