當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。