当前位置: 首页>>代码示例>>PHP>>正文


PHP ESAPI::getValidator方法代码示例

本文整理汇总了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();
 }
开发者ID:bradchesney79,项目名称:PHP-OWASP-ESAPI-Canonicalization-Demo,代码行数:10,代码来源:user.php

示例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();
 }
开发者ID:najamelan,项目名称:PHP-ESAPI,代码行数:8,代码来源:DefaultHTTPUtilities.php

示例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;
     }
 }
开发者ID:najamelan,项目名称:PHP-ESAPI,代码行数:61,代码来源:ValidatorTest.php

示例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']);
         }
     }
 }
开发者ID:najamelan,项目名称:PHP-ESAPI,代码行数:30,代码来源:SafeRequest.php


注:本文中的ESAPI::getValidator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。