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) Enalean, 2015. All rights reserved |
||
4 | * |
||
5 | * This file is a part of Tuleap. |
||
6 | * |
||
7 | * Tuleap 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 | * Tuleap 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 Tuleap. If not, see <http://www.gnu.org/licenses/ |
||
19 | */ |
||
20 | |||
21 | require_once 'account.php'; |
||
22 | require_once 'www/project/admin/UserPermissionsDao.class.php'; |
||
23 | |||
24 | class TestDataBuilder { |
||
25 | |||
26 | const ADMIN_ID = 101; |
||
27 | const ADMIN_USER_NAME = 'admin'; |
||
28 | const ADMIN_REAL_NAME = 'Site Administrator'; |
||
29 | const ADMIN_DISPLAY_NAME = 'Site Administrator (admin)'; |
||
30 | const ADMIN_EMAIL = 'codendi-admin@_DOMAIN_NAME_'; |
||
31 | const ADMIN_STATUS = 'A'; |
||
32 | |||
33 | const TEST_USER_1_ID = 102; |
||
34 | const TEST_USER_1_NAME = 'rest_api_tester_1'; |
||
35 | const TEST_USER_1_REALNAME = 'Test User 1'; |
||
36 | const TEST_USER_1_DISPLAYNAME = 'Test User 1 (rest_api_tester_1)'; |
||
37 | const TEST_USER_1_PASS = 'welcome0'; |
||
38 | const TEST_USER_1_EMAIL = '[email protected]'; |
||
39 | const TEST_USER_1_LDAPID = 'tester1'; |
||
40 | const TEST_USER_1_STATUS = 'A'; |
||
41 | |||
42 | const TEST_USER_2_ID = 103; |
||
43 | const TEST_USER_2_NAME = 'rest_api_tester_2'; |
||
44 | const TEST_USER_2_DISPLAYNAME = ' (rest_api_tester_2)'; |
||
45 | const TEST_USER_2_PASS = 'welcome0'; |
||
46 | const TEST_USER_2_STATUS = 'A'; |
||
47 | const TEST_USER_2_EMAIL = '[email protected]'; |
||
48 | |||
49 | const TEST_USER_3_ID = 104; |
||
50 | const TEST_USER_3_NAME = 'rest_api_tester_3'; |
||
51 | const TEST_USER_3_DISPLAYNAME = ' (rest_api_tester_3)'; |
||
52 | const TEST_USER_3_PASS = 'welcome0'; |
||
53 | const TEST_USER_3_STATUS = 'A'; |
||
54 | const TEST_USER_3_EMAIL = '[email protected]'; |
||
55 | |||
56 | const ADMIN_PROJECT_ID = 100; |
||
57 | const PROJECT_PRIVATE_MEMBER_ID = 101; |
||
58 | const PROJECT_PRIVATE_ID = 102; |
||
59 | const PROJECT_PUBLIC_ID = 103; |
||
60 | const PROJECT_PUBLIC_MEMBER_ID = 104; |
||
61 | const PROJECT_PBI_ID = 105; |
||
62 | |||
63 | const PROJECT_PRIVATE_MEMBER_SHORTNAME = 'private-member'; |
||
64 | const PROJECT_PRIVATE_SHORTNAME = 'private'; |
||
65 | const PROJECT_PUBLIC_SHORTNAME = 'public'; |
||
66 | const PROJECT_PUBLIC_MEMBER_SHORTNAME = 'public-member'; |
||
67 | const PROJECT_PBI_SHORTNAME = 'pbi-6348'; |
||
68 | const PROJECT_BACKLOG_DND = 'dragndrop'; |
||
69 | |||
70 | const STATIC_UGROUP_1_ID = 101; |
||
71 | const STATIC_UGROUP_1_LABEL = 'static_ugroup_1'; |
||
72 | |||
73 | const STATIC_UGROUP_2_ID = 102; |
||
74 | const STATIC_UGROUP_2_LABEL = 'static_ugroup_2'; |
||
75 | |||
76 | const DYNAMIC_UGROUP_PROJECT_MEMBERS_ID = 3; |
||
77 | const DYNAMIC_UGROUP_PROJECT_MEMBERS_LABEL = 'Project members'; |
||
78 | const DYNAMIC_UGROUP_PROJECT_MEMBERS_KEY = 'ugroup_project_members_name_key'; |
||
79 | const DYNAMIC_UGROUP_PROJECT_ADMINS_ID = 4; |
||
80 | const DYNAMIC_UGROUP_PROJECT_ADMINS_LABEL = 'project_admins'; |
||
81 | const DYNAMIC_UGROUP_AUTHENTICATED_USERS_ID = 5; |
||
82 | const DYNAMIC_UGROUP_AUTHENTICATED_USERS_LABEL = 'authenticated_users'; |
||
83 | const DYNAMIC_UGROUP_FILE_MANAGER_ID = 11; |
||
84 | const DYNAMIC_UGROUP_FILE_MANAGER_LABEL = 'file_manager_admins'; |
||
85 | const DYNAMIC_UGROUP_DOCUMENT_TECH_ID = 12; |
||
86 | const DYNAMIC_UGROUP_DOCUMENT_TECH_LABEL = 'document_techs'; |
||
87 | const DYNAMIC_UGROUP_DOCUMENT_ADMIN_ID = 13; |
||
88 | const DYNAMIC_UGROUP_DOCUMENT_ADMIN_LABEL = 'document_admins'; |
||
89 | const DYNAMIC_UGROUP_WIKI_ADMIN_ID = 14; |
||
90 | const DYNAMIC_UGROUP_WIKI_ADMIN_LABEL = 'wiki_admins'; |
||
91 | |||
92 | /** @var ProjectCreator */ |
||
93 | protected $project_creator; |
||
94 | |||
95 | /** @var ProjectManager */ |
||
96 | protected $project_manager; |
||
97 | |||
98 | /** @var UserManager */ |
||
99 | protected $user_manager; |
||
100 | |||
101 | /** @var UserPermissionsDao */ |
||
102 | protected $user_permissions_dao; |
||
103 | |||
104 | public function __construct() { |
||
105 | $this->project_manager = ProjectManager::instance(); |
||
106 | $this->user_manager = UserManager::instance(); |
||
107 | $this->user_permissions_dao = new UserPermissionsDao(); |
||
108 | |||
109 | $this->project_creator = new ProjectCreator($this->project_manager, ReferenceManager::instance()); |
||
110 | |||
111 | $GLOBALS['Language'] = new BaseLanguage('en_US', 'en_US'); |
||
112 | $GLOBALS['sys_lf'] = '\n'; |
||
113 | } |
||
114 | |||
115 | public function activateDebug() { |
||
116 | ForgeConfig::set('DEBUG_MODE', 1); |
||
117 | return $this; |
||
118 | } |
||
119 | |||
120 | protected function activatePlugin($name) { |
||
121 | $plugin_factory = PluginFactory::instance(); |
||
122 | $plugin = $plugin_factory->createPlugin($name); |
||
123 | $plugin_factory->availablePlugin($plugin); |
||
124 | } |
||
125 | |||
126 | protected function setGlobalsForProjectCreation() { |
||
127 | $GLOBALS['svn_prefix'] = '/tmp'; |
||
128 | $GLOBALS['cvs_prefix'] = '/tmp'; |
||
129 | $GLOBALS['grpdir_prefix'] = '/tmp'; |
||
130 | $GLOBALS['ftp_frs_dir_prefix'] = '/tmp'; |
||
131 | $GLOBALS['ftp_anon_dir_prefix'] = '/tmp'; |
||
132 | } |
||
133 | |||
134 | protected function unsetGlobalsForProjectCreation() { |
||
135 | unset($GLOBALS['svn_prefix']); |
||
136 | unset($GLOBALS['cvs_prefix']); |
||
137 | unset($GLOBALS['grpdir_prefix']); |
||
138 | unset($GLOBALS['ftp_frs_dir_prefix']); |
||
139 | unset($GLOBALS['ftp_anon_dir_prefix']); |
||
140 | } |
||
141 | |||
142 | /** |
||
143 | * Instantiates a project with user, groups, admins ... |
||
144 | * |
||
145 | * @param string $project_short_name |
||
146 | * @param string $project_long_name |
||
147 | * @param string $is_public |
||
148 | * @param array $project_members |
||
149 | * @param array $project_admins |
||
150 | */ |
||
151 | protected function createProject( |
||
152 | $project_short_name, |
||
153 | $project_long_name, |
||
154 | $is_public, |
||
155 | array $project_members, |
||
156 | array $project_admins, |
||
157 | array $services |
||
158 | ) { |
||
159 | |||
160 | $user = $this->user_manager->getUserByUserName(self::ADMIN_USER_NAME); |
||
161 | $this->user_manager->setCurrentUser($user); |
||
162 | |||
163 | $project = $this->project_creator->create($project_short_name, $project_long_name, array( |
||
164 | 'project' => array( |
||
165 | 'form_short_description' => '', |
||
166 | 'is_test' => false, |
||
167 | 'is_public' => $is_public, |
||
168 | 'services' => $services, |
||
169 | 'built_from_template' => 100, |
||
170 | ) |
||
171 | )); |
||
172 | |||
173 | $this->project_manager->activate($project); |
||
174 | |||
175 | foreach ($project_members as $project_member) { |
||
176 | $this->addMembersToProject($project, $project_member); |
||
177 | } |
||
178 | |||
179 | foreach ($project_admins as $project_admin) { |
||
180 | $this->addAdminToProject($project, $project_admin); |
||
181 | } |
||
182 | |||
183 | return $project; |
||
184 | } |
||
185 | |||
186 | private function addMembersToProject(Project $project, PFUser $user) { |
||
187 | $GLOBALS['sys_email_admin'] = 'noreply@localhost'; |
||
188 | account_add_user_to_group($project->getId(), $user->getUnixName()); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
189 | unset($GLOBALS['sys_email_admin']); |
||
190 | UserManager::clearInstance(); |
||
191 | $this->user_manager = UserManager::instance(); |
||
192 | } |
||
193 | |||
194 | private function addAdminToProject(Project $project, PFUser $user) { |
||
195 | $this->user_permissions_dao->addUserAsProjectAdmin($project, $user); |
||
196 | } |
||
197 | |||
198 | protected function addUserToUserGroup($user, $project, $ugroup_id) { |
||
199 | ugroup_add_user_to_ugroup($project->getId(), $ugroup_id, $user->getId()); |
||
200 | } |
||
201 | |||
202 | protected function addUserGroupsToProject(Project $project) { |
||
203 | ugroup_create($project->getId(), 'static_ugroup_1', 'static_ugroup_1', ''); |
||
204 | ugroup_create($project->getId(), 'static_ugroup_2', 'static_ugroup_2', ''); |
||
205 | } |
||
206 | } |
||
207 |