Skip to content
Snippets Groups Projects
Commit fdfa2e55 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

hotline #67693 : directory traversal is forbidden

parent 5de800d3
Branches
Tags
4 merge requests!2420Hotline master,!2415Master,!2414Hotline master,!2412Hotline#67693 core five filemanager rendre impossible l envoi de fichier htaccess
Pipeline #2944 passed with stage
in 24 minutes and 57 seconds
......@@ -35,6 +35,18 @@ class Class_FileManager {
protected function _isForbidden($part) {
return in_array($part, ['..', '.htaccess']);
return $this->_isHtaccess($part) || $this->_isDotsOnly($part);
}
protected function _isHtaccess($part) {
return '.htaccess' == trim($part);
}
protected function _isDotsOnly($part) {
return $part
? '' == trim(str_replace('.', '', $part))
: false;
}
}
......@@ -46,15 +46,14 @@ class FileManagerAuthTest extends FileManagerTestCase {
'password' => 'admin']);
$this->_admin->beModoBib()->save();
$this->_guest = $this->fixture('Class_Users',
['id' => 3,
'login' => 'guest',
'password' => 'guest']);
$this->_guest->beInvite()->save();
}
/** @test */
public function withoutAuthenticationUserfilesShouldNotBeAuthorized() {
$this->assertFalse($this->_filemanager->isAuthorized(USERFILESURL . 'images/bokeh.png'));
......@@ -105,6 +104,12 @@ class FileManagerAuthAsAdminTest extends FileManagerTestCase {
}
/** @test */
public function megaUpperDirectoryShouldNotBeAuthorized() {
$this->assertFalse($this->_filemanager->isAuthorized(USERFILESURL . '....//'));
}
/**
* @test
* @see http://forge.afi-sa.fr/issues/32417
......@@ -115,7 +120,7 @@ class FileManagerAuthAsAdminTest extends FileManagerTestCase {
/** @test */
public function dotHtaccessShouldNotBeDownloadable() {
public function dotHtaccessShouldNotBeAuthorized() {
$this->assertFalse($this->_filemanager->isAuthorized(USERFILESURL . '/.htaccess'));
}
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment