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 | use Symfony\Component\HttpFoundation\Request; |
||
3 | use Symfony\Component\Routing\Generator\UrlGenerator; |
||
4 | use Zend\Ldap\Exception\LdapException; |
||
5 | |||
6 | require_once __DIR__ . '/../vendor/autoload.php'; |
||
7 | |||
8 | $app = new Silex\Application(); |
||
9 | |||
10 | require_once __DIR__ . '/../app/config.php'; |
||
11 | $app['debug'] = $dashboard_config['debug']; |
||
12 | require_once __DIR__ . '/../app/services.php'; |
||
13 | |||
14 | // now, let's set up the routes |
||
15 | // TODO: organize in controllers? |
||
16 | |||
17 | // (unprotected) index route |
||
18 | $app->get('/', function () use ($app) { |
||
19 | return $app->redirect($app['url_generator']->generate('/members/manage-account')); |
||
20 | }); |
||
21 | |||
22 | $app->match('/members/Benutzerdaten', function (Request $request) use ($app) { |
||
23 | /** @var \Symfony\Component\Security\Core\Authentication\Token\TokenInterface $token */ |
||
24 | $token = $app['security.token_storage']->getToken(); |
||
25 | if (null !== $token) { |
||
26 | $user = $token->getUser(); |
||
27 | |||
28 | if ($request->request->has('change-password')) { |
||
29 | $newpwd = $request->request->get('new-password'); |
||
30 | if ($app['check_password_policy']($newpwd)) { |
||
31 | try { |
||
32 | $app['ldap']->updatePassword($user->getAttributes()['dn'], $request->request->get('old-password'), $request->request->get('new-password')); |
||
33 | $app['session']->getFlashBag() |
||
34 | ->add('success', 'Passwort erfolgreich geändert!'); |
||
35 | return $app->redirect('/members/Benutzerdaten'); |
||
36 | } catch (LdapException $ex) { |
||
37 | $app['session']->getFlashBag() |
||
38 | ->add('error', 'Fehler beim Ändern des Passworts: ' . $ex->getMessage()); |
||
39 | } |
||
40 | } else { |
||
41 | $app['session']->getFlashBag() |
||
42 | ->add('warning', 'Das Passwort muss 8 Zeichen lang sein und mindestens eine Zahl, einen Buchstaben und ein Sonderzeichen enthalten'); |
||
43 | } |
||
44 | } |
||
45 | } |
||
46 | |||
47 | return $app['twig']->render('manage_account.twig', []); |
||
48 | }) |
||
49 | ->method('GET|POST') |
||
50 | ->bind('/members/manage-account'); |
||
51 | |||
52 | $app->match('/members/meine-Gruppen', function (Request $request) use ($app) { |
||
53 | /** @var \Symfony\Component\Security\Core\Authentication\Token\TokenInterface $token */ |
||
54 | $token = $app['security.token_storage']->getToken(); |
||
55 | |||
56 | if (null !== $token) { |
||
57 | $user = $token->getUser(); |
||
58 | $userDN = $user->getAttributes()['dn']; |
||
59 | $action = $request->request->get('action'); |
||
60 | |||
61 | if (isset($action)) { |
||
62 | $userUID = $user->getAttributes()['uid'][0]; |
||
63 | |||
64 | $groupOU = $request->request->get('ou'); |
||
65 | $groupDN = sprintf('ou=%s,ou=groups,o=sog-de,dc=sog', $groupOU); |
||
66 | $groupAttr = $app['ldap']->getEntry($groupDN, ['cn', 'owner']); |
||
67 | |||
68 | switch ($action) { |
||
69 | case 'quit': |
||
70 | try { |
||
71 | if (in_array($userDN, $groupAttr['owner'])) { |
||
72 | $app['session']->getFlashBag()->add('error', 'Nicht möglich! Du bist Koordinator der Gruppe "' . $groupAttr['cn'][0] . '". Zum Beenden deiner Mitgliedschaft wende dich bitte an das Ressort IT.'); |
||
73 | } else { |
||
74 | $app['ldap']->removeFromGroup($userDN, $groupDN); |
||
75 | $app['session']->getFlashBag()->add('success', 'Deine Mitgliedschaft in der Gruppe "' . $groupAttr['cn'][0] . '" wurde beendet.'); |
||
76 | } |
||
77 | } catch (LdapException $ex) { |
||
78 | $app['session']->getFlashBag()->add('error', 'Fehler beim Beenden der Mitgliedschaft in der Gruppe ' . $groupAttr['cn'][0] . '": ' . $ex->getMessage()); |
||
79 | } |
||
80 | break; |
||
81 | case 'drop-request': |
||
82 | try { |
||
83 | $app['ldap']->dropMembershipRequest($userUID, $groupOU); |
||
84 | $app['session']->getFlashBag()->add('success', 'Deine Mitgliedschaftsanfrage für die Gruppe "' . $groupAttr['cn'][0] . '" wurde abgebrochen.'); |
||
85 | } catch (LdapException $ex) { |
||
86 | $app['session']->getFlashBag()->add('error', 'Fehler beim Abbrechen der Mitgliedschaftsanfrage für die Gruppe "' . $groupAttr['cn'][0] . '": ' . $ex->getMessage()); |
||
87 | } |
||
88 | break; |
||
89 | case 'start-request': |
||
90 | try { |
||
91 | $app['ldap']->requestGroupMembership($userUID, $groupOU); |
||
92 | $text = "<p>Hallo,</p>\n |
||
93 | <a>%s hat eine neue Anfrage für die Mitgliedschaft in deiner Gruppe %s beantragt. Du kannst die Anfrage <a href='%s'>im Dashboard unter 'Neue Anfragen'</a> beantworten.</p>\n |
||
94 | <p>Mit freundlichen Grüßen, dein SOG IT-Ressort</p>\n"; |
||
95 | $text = sprintf($text, |
||
96 | $userUID, |
||
97 | $groupAttr['cn'][0], |
||
98 | $app['url_generator']->generate('/members/manage-groups', [], UrlGenerator::ABSOLUTE_URL) |
||
99 | ); |
||
100 | $app['notify_owners']($groupOU, sprintf('[Studieren Ohne Grenzen] Anfrage zur Mitgliedschaft in deiner Gruppe %s', $groupAttr['cn'][0]), $text); |
||
101 | $app['session']->getFlashBag()->add('success', 'Es wurde eine neue Mitgliedschaftsanfrage für die Gruppe "' . $groupAttr['cn'][0] . '" erstellt.'); |
||
102 | } catch (LdapException $ex) { |
||
103 | $app['session']->getFlashBag()->add('error', 'Fehler beim Erstellen einer Mitgliedschaftsanfrage für die Gruppe "' . $groupAttr['cn'][0] . '": ' . $ex->getMessage()); |
||
104 | } |
||
105 | break; |
||
106 | default: |
||
107 | $app['session']->getFlashBag()->add('error', 'Fehler: Der gesendete Befehl wird nicht unterstützt.'); |
||
108 | } |
||
109 | } |
||
110 | |||
111 | $groups = $app['ldap']->getGroups(['cn', 'mailinglistId', 'ou', 'owner', 'member', 'pending'])->toArray(); |
||
112 | $groupList = []; |
||
113 | foreach ($groups as $g) { |
||
114 | $roles = []; |
||
115 | View Code Duplication | if (isset($g['owner']) && in_array($userDN, $g['owner'])) $roles[] = 'owner'; |
|
0 ignored issues
–
show
|
|||
116 | View Code Duplication | if (isset($g['member']) && in_array($userDN, $g['member'])) $roles[] = 'member'; |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
117 | View Code Duplication | if (isset($g['pending']) && in_array($userDN, $g['pending'])) $roles[] = 'pending'; |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
118 | |||
119 | $owners = []; |
||
120 | if (isset($g['owner'])) { |
||
121 | for ($j = 0; $j < count($g['owner']); $j++) { |
||
0 ignored issues
–
show
It seems like you are calling the size function
count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.
If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration: for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}
// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
![]() |
|||
122 | $o = $app['ldap']->getEntry($g['owner'][$j], ['cn', 'mail']); |
||
123 | if (isset($o)) $owners[] = $o; |
||
124 | } |
||
125 | } |
||
126 | |||
127 | $listentry = array( |
||
128 | 'name' => $g['cn'][0], |
||
129 | 'ou' => $g['ou'][0], |
||
130 | 'mailinglistId' => $g['mailinglistid'][0], |
||
131 | 'userRoles' => $roles, |
||
132 | 'owners' => $owners |
||
133 | ); |
||
134 | |||
135 | $groupList[] = $listentry; |
||
136 | } |
||
137 | |||
138 | return $app['twig']->render('manage_groups.twig', ['groupList' => $groupList]); |
||
139 | } |
||
140 | }) |
||
141 | ->method('GET|POST') |
||
142 | ->bind('/members/manage-groups'); |
||
143 | |||
144 | $app->match('/members/Mitglieder-verwalten', function (Request $request) use ($app) { |
||
145 | /** @var \Symfony\Component\Security\Core\Authentication\Token\TokenInterface $token */ |
||
146 | $token = $app['security.token_storage']->getToken(); |
||
147 | |||
148 | if (null !== $token) { |
||
149 | $user = $token->getUser(); |
||
150 | $ownedGroups = $app['ldap']->getOwnedGroups($user->getAttributes()['dn'])->toArray(); |
||
151 | $selGroup = $request->query->get('ou'); |
||
152 | |||
153 | if (count($ownedGroups) === 0) { |
||
154 | $app['session']->getFlashBag()->add('error', 'Keine Berechtigung.'); |
||
155 | return new \Symfony\Component\HttpFoundation\RedirectResponse('/members/Benutzerdaten'); |
||
156 | } |
||
157 | |||
158 | if (!isset($selGroup)) $selGroup = $ownedGroups[0]['ou'][0]; |
||
159 | $selGroupDN = sprintf('ou=%s,ou=groups,o=sog-de,dc=sog', $selGroup); |
||
160 | |||
161 | $action = $request->request->get('manage-action'); |
||
162 | |||
163 | if (isset($action)) { |
||
164 | $ownerPermission = false; |
||
165 | $selGroupName = ''; |
||
166 | foreach ($ownedGroups as $og) { |
||
167 | if ($og['dn'] == $selGroupDN) { |
||
168 | $ownerPermission = true; |
||
169 | $selGroupName = $og['cn'][0]; |
||
170 | break; |
||
171 | } |
||
172 | } |
||
173 | |||
174 | if ($ownerPermission) { |
||
175 | $userID = $request->request->get('uid'); |
||
176 | $userDN = $app['ldap']->findUserDN($userID); |
||
177 | $userAttr = $app['ldap']->getEntry($userDN, ['cn']); |
||
178 | |||
179 | $groupAttr = $app['ldap']->getEntry($selGroupDN, ['owner']); |
||
180 | |||
181 | switch ($action) { |
||
182 | case 'activate': |
||
183 | try { |
||
184 | $app['ldap']->activateMember($userID); |
||
185 | $app['ldap']->approveGroupMembership($userID, 'allgemein'); // TODO: Make 'allgemein' configurable |
||
186 | $app['session']->getFlashBag()->add('success', $userAttr['cn'][0] . ' wurde freigeschaltet, du kannst ihn/sie nun zu deiner Gruppe "' . $selGroupName . '" hinzufügen!'); |
||
187 | } catch (LdapException $ex) { |
||
188 | $app['session']->getFlashBag()->add('error', 'Fehler beim Freischalten von ' . $userAttr['cn'][0] . ': ' . $ex->getMessage()); |
||
189 | } |
||
190 | break; |
||
191 | case 'add': |
||
192 | try { |
||
193 | $app['ldap']->addToGroup($userDN, $selGroupDN); |
||
194 | $app['ldap']->dropMembershipRequest($userID, $selGroup); |
||
195 | $app['session']->getFlashBag()->add('success', $userAttr['cn'][0] . ' wurde zu der Gruppe "' . $selGroupName . '" hinzugefügt!'); |
||
196 | } catch (LdapException $ex) { |
||
197 | $app['session']->getFlashBag()->add('error', 'Fehler beim Hinzufügen von ' . $userAttr['cn'][0] . ' zu der Gruppe "' . $selGroupName . '": ' . $ex->getMessage()); |
||
198 | } |
||
199 | break; |
||
200 | case 'rm': |
||
201 | try { |
||
202 | if (in_array($userDN, $groupAttr['owner'])) { |
||
203 | $app['session']->getFlashBag()->add('error', 'Nicht möglich! "' . $userAttr['cn'][0] . '" ist Koordinator der Gruppe "' . $selGroupName . '". Bitte entferne ihn zuerst als Koordinator.'); |
||
204 | } else { |
||
205 | $app['ldap']->removeFromGroup($userDN, $selGroupDN); |
||
206 | $app['session']->getFlashBag()->add('success', $userAttr['cn'][0] . ' wurde von der Gruppe "' . $selGroupName . '" entfernt!'); |
||
207 | } |
||
208 | } catch (LdapException $ex) { |
||
209 | $app['session']->getFlashBag()->add('error', 'Fehler beim Entfernen von ' . $userAttr['cn'][0] . ' aus der Gruppe "' . $selGroupName . '": ' . $ex->getMessage()); |
||
210 | } |
||
211 | break; |
||
212 | case 'rm-request': |
||
213 | try { |
||
214 | $app['ldap']->dropMembershipRequest($userID, $selGroup); |
||
215 | $app['session']->getFlashBag()->add('success', 'Die Mitgliedschaftsanfrage von ' . $userAttr['cn'][0] . ' für die Gruppe "' . $selGroupName . '" wurde gelöscht!'); |
||
216 | } catch (LdapException $ex) { |
||
217 | $app['session']->getFlashBag()->add('error', 'Fehler beim Löschen der Mitgliedschaftsanfrage von ' . $userAttr['cn'][0] . ' für die Gruppe "' . $selGroupName . '": ' . $ex->getMessage()); |
||
218 | } |
||
219 | break; |
||
220 | default: |
||
221 | $app['session']->getFlashBag()->add('error', 'Fehler: Der gesendete Befehl wird nicht unterstützt.'); |
||
222 | } |
||
223 | |||
224 | } else { |
||
225 | $app['session']->getFlashBag()->add('error', 'Keine Berechtigung für die gewählte Gruppe'); |
||
226 | } |
||
227 | } |
||
228 | |||
229 | $allUsers = $app['ldap']->getAllUsers()->toArray(); |
||
230 | $groupAttr = $app['ldap']->getEntry($selGroupDN, ['owner', 'member', 'pending']); |
||
231 | |||
232 | $memberList = []; |
||
233 | foreach ($allUsers as $u) { |
||
234 | $roles = []; |
||
235 | View Code Duplication | if (isset($groupAttr['owner']) && in_array($u['dn'], $groupAttr['owner'])) $roles[] = 'owner'; |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
236 | View Code Duplication | if (isset($groupAttr['member']) && in_array($u['dn'], $groupAttr['member'])) $roles[] = 'member'; |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
237 | View Code Duplication | if (isset($groupAttr['pending']) && in_array($u['dn'], $groupAttr['pending'])) $roles[] = 'pending'; |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
238 | // we handle inactive members like the other cases, the UI is just so similar |
||
239 | if (strstr($u['dn'], 'ou=inactive')) $roles[] = 'inactive'; |
||
240 | |||
241 | $listentry = array( |
||
242 | 'name' => $u['cn'][0], |
||
243 | 'uid' => $u['uid'][0], |
||
244 | 'email' => $u['mail'][0], |
||
245 | 'userRoles' => $roles |
||
246 | ); |
||
247 | |||
248 | $memberList[] = $listentry; |
||
249 | } |
||
250 | |||
251 | return $app['twig']->render('manage_members.twig', [ |
||
252 | 'memberList' => $memberList, |
||
253 | 'ownedGroups' => $ownedGroups, |
||
254 | 'selectedGroup' => $selGroup |
||
255 | ]); |
||
256 | } |
||
257 | }) |
||
258 | ->method('GET|POST') |
||
259 | ->bind('/members/manage-members'); |
||
260 | |||
261 | $app->get('/members/Hilfe', function () use ($app) { |
||
262 | return $app['twig']->render('help.twig'); |
||
263 | }) |
||
264 | ->bind('/members/help'); |
||
265 | |||
266 | $app->get('/login', function (Request $request) use ($app) { |
||
267 | return $app['twig']->render('login.twig', [ |
||
268 | 'error' => $app['security.last_error']($request), |
||
269 | 'last_username' => $app['session']->get('_security.last_username') |
||
270 | ]); |
||
271 | }); |
||
272 | |||
273 | $app->run(); |
||
274 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.