mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 10:24:26 +02:00
added security test case
This commit is contained in:
@@ -54,7 +54,7 @@ class PluginFunctionFetchTest extends PHPUnit_Smarty
|
|||||||
* test {fetch file=...} access to file from path not aloo/wed by security settings
|
* test {fetch file=...} access to file from path not aloo/wed by security settings
|
||||||
*
|
*
|
||||||
* @expectedException SmartyException
|
* @expectedException SmartyException
|
||||||
* @expectedExceptionMessage not trusted file pat
|
* @expectedExceptionMessage not trusted file path
|
||||||
* @run InSeparateProcess
|
* @run InSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
*/
|
*/
|
||||||
@@ -65,4 +65,21 @@ class PluginFunctionFetchTest extends PHPUnit_Smarty
|
|||||||
$this->smarty->enableSecurity();
|
$this->smarty->enableSecurity();
|
||||||
$result = $this->smarty->fetch('string:{fetch file=\''. $dir[0]. '../../../../../etc/passwd\'}');
|
$result = $this->smarty->fetch('string:{fetch file=\''. $dir[0]. '../../../../../etc/passwd\'}');
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* test {fetch file=...} access to file from path not aloo/wed by security settings
|
||||||
|
*
|
||||||
|
* @expectedException SmartyException
|
||||||
|
* @expectedExceptionMessage not trusted file path
|
||||||
|
* @run InSeparateProcess
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
*/
|
||||||
|
public function testFetchSecurity2()
|
||||||
|
{
|
||||||
|
$this->cleanDirs();
|
||||||
|
$dir=$this->smarty->getTemplateDir();
|
||||||
|
$this->smarty->enableSecurity();
|
||||||
|
$this->smarty->setTemplateDir('/templates');
|
||||||
|
$result = $this->smarty->fetch('string:{fetch file="/templates/../etc/passwd"}');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user