This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Copyright (c) STMicroelectronics, 2010. All Rights Reserved. |
||
4 | * |
||
5 | * This file is a part of Codendi. |
||
6 | * |
||
7 | * Codendi is free software; you can redistribute it and/or modify |
||
8 | * it under the terms of the GNU General Public License as published by |
||
9 | * the Free Software Foundation; either version 2 of the License, or |
||
10 | * (at your option) any later version. |
||
11 | * |
||
12 | * Codendi 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 General Public License for more details. |
||
16 | * |
||
17 | * You should have received a copy of the GNU General Public License |
||
18 | * along with Codendi. If not, see <http://www.gnu.org/licenses/>. |
||
19 | */ |
||
20 | |||
21 | /** |
||
22 | * This is the WebDAV server tree it implements Sabre_DAV_ObjectTree to rewrite some methods |
||
23 | */ |
||
24 | class WebDAVTree extends Sabre_DAV_ObjectTree { |
||
25 | |||
26 | /** |
||
27 | * Tests if the release destination is a package |
||
28 | * we allow moving releases only within the same project |
||
29 | * |
||
30 | * @param WebDAVFRSRelease $release |
||
31 | * @param mixed $destination |
||
32 | * |
||
33 | * @return boolean |
||
34 | */ |
||
35 | function releaseCanBeMoved($release, $destination) { |
||
36 | return (($destination instanceof WebDAVFRSPackage) |
||
37 | && ($release->getProject()->getGroupId() == $destination->getProject()->getGroupId())); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * Tests if the file destination is a release |
||
42 | * we allow moving files only within the same project |
||
43 | * |
||
44 | * @param WebDAVFRSFile $file |
||
45 | * @param mixed $destination |
||
46 | * |
||
47 | * @return boolean |
||
48 | */ |
||
49 | function fileCanBeMoved($file, $destination) { |
||
50 | return (($destination instanceof WebDAVFRSRelease) |
||
51 | && ($file->getProject()->getGroupId() == $destination->getProject()->getGroupId())); |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * Tests if the node can be moved or not |
||
56 | * |
||
57 | * @param mixed $source |
||
58 | * @param mixed $destination |
||
59 | * |
||
60 | * @return boolean |
||
61 | */ |
||
62 | function canBeMoved($source, $destination) { |
||
63 | return(($source instanceof WebDAVFRSRelease && $this->releaseCanBeMoved($source, $destination)) |
||
64 | || ($source instanceof WebDAVFRSFile && $this->fileCanBeMoved($source, $destination))); |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * Copy a docman item |
||
69 | * We don't allow copying docman items from a project to another |
||
70 | * We don't allow copying FRS items |
||
71 | * |
||
72 | * Copy or move of items is disabled as of today, because we need more feedback on |
||
73 | * how basic (create/update/delete) features works before allowing it. |
||
74 | * |
||
75 | * @param String $sourcePath |
||
76 | * @param String $destinationPath |
||
77 | * |
||
78 | * @return void |
||
79 | */ |
||
80 | public function copy($sourcePath, $destinationPath) { |
||
81 | throw new Sabre_DAV_Exception_MethodNotAllowed($GLOBALS['Language']->getText('plugin_webdav_common', 'write_access_disabled')); |
||
82 | |||
83 | // Check that write access is enabled for WebDAV |
||
84 | /*if ($this->getUtils()->isWriteEnabled()) { |
||
85 | list($destinationDir, $destinationName) = Sabre_DAV_URLUtil::splitPath($destinationPath); |
||
86 | $destination = $this->getNodeForPath($destinationDir); |
||
87 | $source = $this->getNodeForPath($sourcePath); |
||
88 | // Check that the source is a docman item & the destination is a docman folder |
||
89 | if ($destination instanceof WebDAVDocmanFolder |
||
90 | && ($source instanceof WebDAVDocmanFolder || $source instanceof WebDAVDocmanDocument)) { |
||
91 | // Check that the items are in the same project |
||
92 | $sourceItem = $source->getItem(); |
||
93 | $destinationItem = $destination->getItem(); |
||
94 | if ($sourceItem->getGroupId() == $destinationItem->getGroupId()) { |
||
95 | // Check user permissions |
||
96 | $user = $source->getUser(); |
||
97 | $docmanPermissionManager = $this->getUtils()->getDocmanPermissionsManager($source->getProject()); |
||
98 | if ($docmanPermissionManager->userCanAccess($user, $sourceItem->getId()) |
||
99 | && $docmanPermissionManager->userCanWrite($user, $destinationItem->getId())) { |
||
100 | $dataRoot = $this->getUtils()->getDocmanRoot(); |
||
101 | $itemFactory = $this->getUtils()->getDocmanItemFactory(); |
||
102 | $itemFactory->cloneItems($sourceItem->getGroupId(), |
||
103 | $destinationItem->getGroupId(), |
||
104 | $user, |
||
105 | array(), |
||
106 | true, |
||
107 | $dataRoot, |
||
108 | $sourceItem->getId(), |
||
109 | $destinationItem->getId(), |
||
110 | 1); |
||
111 | } else { |
||
112 | throw new Sabre_DAV_Exception_MethodNotAllowed($GLOBALS['Language']->getText('plugin_webdav_common', 'docman_item_denied_copy')); |
||
113 | } |
||
114 | } else { |
||
115 | throw new Sabre_DAV_Exception_MethodNotAllowed($GLOBALS['Language']->getText('plugin_webdav_common', 'docman_item_projects_copy')); |
||
116 | } |
||
117 | } else { |
||
118 | throw new Sabre_DAV_Exception_MethodNotAllowed($GLOBALS['Language']->getText('plugin_webdav_common', 'docman_bad_item')); |
||
119 | } |
||
120 | } else { |
||
121 | throw new Sabre_DAV_Exception_MethodNotAllowed($GLOBALS['Language']->getText('plugin_webdav_common', 'write_access_disabled')); |
||
122 | }*/ |
||
123 | } |
||
124 | |||
125 | /** |
||
126 | * This method moves nodes from location to another |
||
127 | * |
||
128 | * Move only allowed to rename a file in a given release. Otherwise as this |
||
129 | * operation is not yet well supported by the FRS itself we cannot implement |
||
130 | * it the right way. |
||
131 | * |
||
132 | * @return void |
||
133 | * |
||
134 | * @see lib/Sabre/DAV/Sabre_DAV_Tree#move($sourcePath, $destinationPath) |
||
135 | */ |
||
136 | public function move($sourcePath, $destinationPath) { |
||
137 | list($sourceDir, $sourceName) = Sabre_DAV_URLUtil::splitPath($sourcePath); |
||
0 ignored issues
–
show
|
|||
138 | list($destinationDir, $destinationName) = Sabre_DAV_URLUtil::splitPath($destinationPath); |
||
139 | |||
140 | $source = $this->getNodeForPath($sourcePath); |
||
141 | $itemFactory = $this->getUtils()->getDocmanItemFactory(); |
||
142 | $destination = $this->getNodeForPath($destinationDir); |
||
143 | // Check that write access is enabled for WebDAV |
||
144 | if ($this->getUtils()->isWriteEnabled()) { |
||
145 | if ($sourceDir === $destinationDir) { |
||
146 | $source->setName($destinationName); |
||
147 | /*} else if ($destination instanceof WebDAVDocmanFolder |
||
148 | && ($source instanceof WebDAVDocmanFolder || $source instanceof WebDAVDocmanDocument)) { |
||
149 | throw new Sabre_DAV_Exception_MethodNotAllowed($GLOBALS['Language']->getText('plugin_webdav_common', 'write_access_disabled')); |
||
150 | |||
151 | $sourceItem = $source->getItem(); |
||
152 | $destinationItem = $destination->getItem(); |
||
153 | $user = $source->getUser(); |
||
154 | $ordering = 'beginning'; |
||
155 | if ($sourceItem->getGroupId() == $destinationItem->getGroupId()) { |
||
156 | $docmanPermissionManager = $this->getUtils()->getDocmanPermissionsManager($source->getProject()); |
||
157 | if ($docmanPermissionManager->userCanAccess($user, $sourceItem->getId()) |
||
158 | && $docmanPermissionManager->userCanWrite($user, $destinationItem->getId())) { |
||
159 | $subItemsWritable = $docmanPermissionManager->currentUserCanWriteSubItems($sourceItem->getId()); |
||
160 | if($subItemsWritable) { |
||
161 | $itemFactory->setNewParent($sourceItem->getId(), $destinationItem->getId(), $ordering); |
||
162 | $event = 'plugin_docman_event_move'; |
||
163 | $sourceItem->fireEvent($event, $user, $destinationItem); |
||
164 | } else { |
||
165 | throw new Sabre_DAV_Exception_MethodNotAllowed($GLOBALS['Language']->getText('plugin_webdav_common', 'error_subitems_not_moved_no_w')); |
||
166 | } |
||
167 | } else { |
||
168 | throw new Sabre_DAV_Exception_MethodNotAllowed($GLOBALS['Language']->getText('plugin_webdav_common', 'docman_item_denied_move')); |
||
169 | } |
||
170 | } else { |
||
171 | throw new Sabre_DAV_Exception_MethodNotAllowed($GLOBALS['Language']->getText('plugin_webdav_common', 'docman_item_projects_move')); |
||
172 | }*/ |
||
173 | } else { |
||
174 | throw new Sabre_DAV_Exception_MethodNotAllowed($GLOBALS['Language']->getText('plugin_webdav_common', 'move_error')); |
||
175 | } |
||
176 | } else { |
||
177 | throw new Sabre_DAV_Exception_MethodNotAllowed($GLOBALS['Language']->getText('plugin_webdav_common', 'write_access_disabled')); |
||
178 | } |
||
179 | } |
||
180 | |||
181 | /** |
||
182 | * Returns an instance of WebDAVUtils |
||
183 | * |
||
184 | * @return WebDAVUtils |
||
185 | */ |
||
186 | function getUtils() { |
||
187 | return WebDAVUtils::getInstance(); |
||
188 | } |
||
189 | |||
190 | } |
||
191 | |||
192 | ?> |
This checks looks for assignemnts to variables using the
list(...)
function, where not all assigned variables are subsequently used.Consider the following code example.
Only the variables
$a
and$c
are used. There was no need to assign$b
.Instead, the list call could have been.