本文整理汇总了PHP中ESAPI::getValidator方法的典型用法代码示例。如果您正苦于以下问题:PHP ESAPI::getValidator方法的具体用法?PHP ESAPI::getValidator怎么用?PHP ESAPI::getValidator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ESAPI
的用法示例。
在下文中一共展示了ESAPI::getValidator方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct()
{
//The xml file is in its insecure default location.
//We would normally have all referenced libraries outside of the webroot.
$this->esapi = new ESAPI('../owasp-esapi-php-read-only/test/testresources/ESAPI.xml');
ESAPI::setEncoder(new DefaultEncoder());
ESAPI::setValidator(new DefaultValidator());
$this->encoder = ESAPI::getEncoder();
$this->validator = ESAPI::getValidator();
}
示例2: __construct
/**
* The constructor stores an instance of Auditor for the purpose of logging.
*/
public function __construct()
{
$this->_auditor = ESAPI::getAuditor('DefaultHTTPUtilities');
$this->_validator = ESAPI::getValidator();
}
示例3: testIsValidDirectoryPath
/**
* Test of isValidDirectoryPath method, of class org.owasp.esapi.Validator.
*/
public function testIsValidDirectoryPath()
{
$list = array();
array_push($list, new HTMLEntityCodec());
$encoder = new DefaultEncoder($list);
$instance = ESAPI::getValidator();
switch ($this->_os) {
case self::PLATFORM_WINDOWS:
// Windows paths that should pass
$this->assertTrue($instance->isValidDirectoryPath('test', 'C:\\', false));
// Windows root directory
$this->assertTrue($instance->isValidDirectoryPath('test', 'C:\\Windows', false));
// Windows always exist directory
// Windows paths that don't exist and thus should fail
$this->assertFalse($instance->isValidDirectoryPath('test', 'c:\\ridiculous', false));
$this->assertFalse($instance->isValidDirectoryPath('test', 'c:\\temp\\..\\etc', false));
// Windows path that exists but is not a directory
$this->assertFalse($instance->isValidDirectoryPath('test', 'C:\\Windows\\System32\\cmd.exe', false));
// Windows command shell
// Windows path that exists but is not canonical
$this->assertFalse($instance->isValidDirectoryPath('test', 'C:\\Windows\\System32\\..', false));
// Unix specific paths should not pass
$this->assertFalse($instance->isValidDirectoryPath('test', '/tmp', false));
// Unix Temporary directory
$this->assertFalse($instance->isValidDirectoryPath('test', '/bin/sh', false));
// Unix Standard shell
$this->assertFalse($instance->isValidDirectoryPath('test', '/etc/config', false));
// Unix specific paths that should not exist or work
$this->assertFalse($instance->isValidDirectoryPath('test', '/etc/ridiculous', false));
$this->assertFalse($instance->isValidDirectoryPath('test', '/tmp/../etc', false));
break;
case self::PLATFORM_UNIX:
// Unix specific paths should pass
$this->assertTrue($instance->isValidDirectoryPath('test', '/', false));
// Root directory
$this->assertTrue($instance->isValidDirectoryPath('test', '/bin', false));
// Always exist directory
// Unix specific path that exists but is not a directory
$this->assertFalse($instance->isValidDirectoryPath('test', '/bin/sh', false));
// Standard shell
// Unix specific path that exists but is not canonical
$this->assertFalse($instance->isValidDirectoryPath('test', '/bin/../', false));
// Unix specific paths that should not exist or work
$this->assertFalse($instance->isValidDirectoryPath('test', '/etc/ridiculous', false));
$this->assertFalse($instance->isValidDirectoryPath('test', '/tmp/../etc', false));
// Windows paths should fail
$this->assertFalse($instance->isValidDirectoryPath('test', 'c:\\ridiculous', false));
$this->assertFalse($instance->isValidDirectoryPath('test', 'c:\\temp\\..\\etc', false));
// Standard Windows locations should fail
$this->assertFalse($instance->isValidDirectoryPath('test', 'c:\\', false));
// Windows root directory
$this->assertFalse($instance->isValidDirectoryPath('test', 'c:\\Windows\\temp', false));
// Windows temporary directory
$this->assertFalse($instance->isValidDirectoryPath('test', 'c:\\Windows\\System32\\cmd.exe', false));
// Windows command shell
break;
}
}
示例4: __construct
/**
* SafeRequest can be forced to use the supplied cookies, headers and server
* globals by passing an array containing the following keys: 'cookies',
* 'headers', 'env'. The values for each of the keys should be an associative
* array e.g. 'headers' => array('REQUEST_METHOD' => 'GET').
* If any of the three options keys are not supplied then those elements will be
* extracted from the actual request.
* TODO accept a string like: 'GET / HTTP/1.1\r\nHost:example.com\r\n\r\n'
* TODO accept GET and REQUEST parameters.
*
* @param NULL|array $options Array (optional) of HTTP Request elements.
*/
public function __construct($options = null)
{
$codecs = array(new HTMLEntityCodec(), new PercentCodec());
$this->_encoder = new DefaultEncoder($codecs);
$this->_auditor = ESAPI::getAuditor('SafeRequest');
$this->_validator = ESAPI::getValidator();
if ($options !== null && is_array($options)) {
if (array_key_exists('cookies', $options)) {
$this->_cookies = $this->_validateCookies($options['cookies']);
}
if (array_key_exists('headers', $options)) {
$this->_headers = $this->_validateHeaders($options['headers']);
}
if (array_key_exists('env', $options)) {
$this->_serverGlobals = $this->_canonicalizeServerGlobals($options['env']);
}
}
}