1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @copyright Copyright (c) 2016 Joas Schilling <[email protected]> |
4
|
|
|
* |
5
|
|
|
* @license GNU AGPL version 3 or any later version |
6
|
|
|
* |
7
|
|
|
* This program is free software: you can redistribute it and/or modify |
8
|
|
|
* it under the terms of the GNU Affero General Public License as |
9
|
|
|
* published by the Free Software Foundation, either version 3 of the |
10
|
|
|
* License, or (at your option) any later version. |
11
|
|
|
* |
12
|
|
|
* This program is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU Affero General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU Affero General Public License |
18
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
19
|
|
|
* |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
namespace OCA\FilesAccessControl; |
23
|
|
|
|
24
|
|
|
use OC\Files\Cache\Wrapper\CacheWrapper as Wrapper; |
|
|
|
|
25
|
|
|
use OCP\Constants; |
26
|
|
|
use OCP\Files\Cache\ICache; |
27
|
|
|
use OCP\Files\ForbiddenException; |
28
|
|
|
use OCP\Files\Storage\IStorage; |
29
|
|
|
|
30
|
|
|
class CacheWrapper extends Wrapper { |
31
|
|
|
/** @var Operation */ |
32
|
|
|
protected $operation; |
33
|
|
|
/** @var StorageWrapper */ |
34
|
|
|
protected $storage; |
35
|
|
|
/** @var int */ |
36
|
|
|
protected $mask; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param ICache $cache |
40
|
|
|
* @param IStorage $storage |
41
|
|
|
* @param Operation $operation |
42
|
|
|
*/ |
43
|
|
|
public function __construct(ICache $cache, IStorage $storage, Operation $operation) { |
44
|
|
|
parent::__construct($cache); |
45
|
|
|
$this->storage = $storage; |
|
|
|
|
46
|
|
|
$this->operation = $operation; |
47
|
|
|
|
48
|
|
|
$this->mask = Constants::PERMISSION_ALL; |
49
|
|
|
$this->mask &= ~Constants::PERMISSION_READ; |
50
|
|
|
$this->mask &= ~Constants::PERMISSION_CREATE; |
51
|
|
|
$this->mask &= ~Constants::PERMISSION_UPDATE; |
52
|
|
|
$this->mask &= ~Constants::PERMISSION_DELETE; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public const PERMISSION_CREATE = 4; |
56
|
|
|
public const PERMISSION_READ = 1; |
57
|
|
|
public const PERMISSION_UPDATE = 2; |
58
|
|
|
public const PERMISSION_DELETE = 8; |
59
|
|
|
|
60
|
|
|
protected function formatCacheEntry($entry) { |
61
|
|
|
if (isset($entry['path']) && isset($entry['permissions'])) { |
62
|
|
|
try { |
63
|
|
|
$this->operation->checkFileAccess($this->storage, $entry['path'], $entry['mimetype'] === 'httpd/unix-directory'); |
64
|
|
|
} catch (ForbiddenException $e) { |
65
|
|
|
$entry['permissions'] &= $this->mask; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
return $entry; |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths