Development

Changeset 8925

You must first sign up to be able to contribute.

Changeset 8925

Show
Ignore:
Timestamp:
05/13/08 11:03:01 (5 years ago)
Author:
fabien
Message:

fixed yml validator file can be overriden by a remote attacker (closes #1617 - based on a patch from Carl.Vondrick)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/lib/plugins/sfCompat10Plugin/lib/filter/sfValidationExecutionFilter.class.php

    r7792 r8925  
    108108    $validated = true; 
    109109 
     110    // the case of the first letter of the action is insignificant 
    110111    // get the current action validation configuration 
    111     $validationConfig = $moduleName.'/validate/'.$actionName.'.yml'; 
     112    $validationConfigWithFirstLetterLower = strtolower(substr($actionName, 0, 1)).substr($actionName, 1).'.yml'; 
     113    $validationConfigWithFirstLetterUpper = ucfirst($actionName).'.yml'; 
     114 
     115    // determine $validateFile by testing both the uppercase and lowercase 
     116    // types of validation configurations. 
     117    $validateFile = null; 
     118    if (!is_null($testValidateFile = $this->context->getConfigCache()->checkConfig('modules/'.$moduleName.'/validate/'.$validationConfigWithFirstLetterLower, true))) 
     119    { 
     120      $validateFile = $testValidateFile; 
     121    } 
     122    else if (!is_null($testValidateFile = $this->context->getConfigCache()->checkConfig('modules/'.$moduleName.'/validate/'.$validationConfigWithFirstLetterUpper, true))) 
     123    { 
     124      $validateFile = $testValidateFile; 
     125    } 
    112126 
    113127    // load validation configuration 
    114128    // do NOT use require_once 
    115     if (null !== $validateFile = $this->context->getConfigCache()->checkConfig('modules/'.$validationConfig, true)) 
     129    if (!is_null($validateFile)) 
    116130    { 
    117131      // create validator manager 
  • branches/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/apps/frontend/modules/validation/actions/actions.class.php

    r3168 r8925  
    1313  public function executeIndex() 
    1414  { 
     15    if (sfWebRequest::POST == $this->getRequest()->getMethod()) 
     16    { 
     17      $this->getResponse()->setHttpHeader('X-Validated', 'ok'); 
     18    } 
    1519  } 
    1620 
    1721  public function handleErrorIndex() 
    1822  { 
     23    $this->getResponse()->setHttpHeader('X-Validated', 'ko'); 
     24 
     25    return sfView::SUCCESS; 
     26  } 
     27 
     28  public function executeIndex2() 
     29  { 
     30    if (sfWebRequest::POST == $this->getRequest()->getMethod()) 
     31    { 
     32      $this->getResponse()->setHttpHeader('X-Validated', 'ok'); 
     33    } 
     34  } 
     35 
     36  public function handleErrorIndex2() 
     37  { 
     38    $this->getResponse()->setHttpHeader('X-Validated', 'ko'); 
     39 
    1940    return sfView::SUCCESS; 
    2041  } 
  • branches/1.1/lib/plugins/sfCompat10Plugin/test/functional/validationTest.php

    r6482 r8925  
    137137  checkResponseElement('body ul[class="errors"] li[class="input4"]', 'Required') 
    138138; 
     139 
     140// check that /validation/index and /validation/Index both uses the index.yml validation file (see #1617) 
     141// those tests are only relevant on machines where filesystems are case sensitive. 
     142$b-> 
     143  post('/validation/index')-> 
     144  isStatusCode(200)-> 
     145  isRequestParameter('module', 'validation')-> 
     146  isRequestParameter('action', 'index')-> 
     147  isResponseHeader('X-Validated', 'ko') 
     148; 
     149 
     150$b-> 
     151  post('/validation/Index')-> 
     152  isStatusCode(200)-> 
     153  isRequestParameter('module', 'validation')-> 
     154  isRequestParameter('action', 'Index')-> 
     155  isResponseHeader('X-Validated', 'ko') 
     156; 
     157 
     158// needed to pass tests on case and non case sensitive machines 
     159if (!file_exists(dirname(__FILE__).'/fixtures/apps/frontend/modules/validation/templates/IndexSuccess.php')) 
     160{ 
     161  $b->throwsException('sfRenderException'); 
     162} 
     163 
     164$b-> 
     165  post('/validation/INdex')-> 
     166  isStatusCode(404) 
     167; 
     168 
     169$b-> 
     170  post('/validation/index2')-> 
     171  isStatusCode(200)-> 
     172  isRequestParameter('module', 'validation')-> 
     173  isRequestParameter('action', 'index2')-> 
     174  isResponseHeader('X-Validated', 'ko') 
     175; 
     176 
     177if (!is_readable(dirname(__FILE__).'/fixtures/apps/frontend/modules/validation/templates/index2Success.php')) 
     178{ 
     179  $b->throwsException('sfRenderException'); 
     180} 
     181 
     182$b-> 
     183  post('/validation/Index2')-> 
     184  isStatusCode(200)-> 
     185  isRequestParameter('module', 'validation')-> 
     186  isRequestParameter('action', 'Index2')-> 
     187  isResponseHeader('X-Validated', 'ko') 
     188;