GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (59)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

public/index.php (7 issues)

Upgrade to new PHP Analysis Engine

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
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.

Loading history...
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.

Loading history...
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.

Loading history...
118
119
            $owners = [];
120
            if (isset($g['owner'])) {
121
                for ($j = 0; $j < count($g['owner']); $j++) {
0 ignored issues
show
Performance Best Practice introduced by
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
}
Loading history...
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.

Loading history...
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.

Loading history...
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.

Loading history...
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