Issues (180)

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.

code/control/LDAPDebugController.php (10 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
/**
3
 * Class LDAPDebugController
4
 *
5
 * This controller is used to debug the LDAP connection.
6
 */
7
class LDAPDebugController extends ContentController
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
8
{
9
10
    /**
11
     * @var array
12
     */
13
    private static $allowed_actions = [
0 ignored issues
show
The property $allowed_actions is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
14
        'index',
15
    ];
16
17
    /**
18
     * @var array
19
     */
20
    private static $dependencies = [
0 ignored issues
show
The property $dependencies is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
21
        'ldapService' => '%$LDAPService'
22
    ];
23
24
    /**
25
     * @var LDAPService
26
     */
27
    public $ldapService;
28
29
    public function init()
30
    {
31
        parent::init();
32
33
        if (!Permission::check('ADMIN')) {
34
            Security::permissionFailure();
35
        }
36
    }
37
38
    /**
39
     * @param SS_HTTPRequest $request
40
     *
41
     * @return string
42
     */
43
    public function index(\SS_HTTPRequest $request) {
44
        return $this->renderWith(['LDAPDebugController']);
45
    }
46
47
    public function Options()
48
    {
49
        $list = new ArrayList();
50
        foreach (Config::inst()->get('LDAPGateway', 'options') as $field => $value) {
0 ignored issues
show
The expression \Config::inst()->get('LDAPGateway', 'options') of type array|integer|double|string|boolean is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
51
            if ($field === 'password') {
52
                $value = '***';
53
            }
54
55
            $list->push(new ArrayData([
56
                'Name' => $field,
57
                'Value' => $value
58
            ]));
59
        }
60
        return $list;
61
    }
62
63 View Code Duplication
    public function UsersSearchLocations()
0 ignored issues
show
This method seems to be duplicated in 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...
64
    {
65
        $locations = Config::inst()->get('LDAPService', 'users_search_locations');
66
        $list = new ArrayList();
67
        if ($locations) {
68
            foreach ($locations as $location) {
0 ignored issues
show
The expression $locations of type array|integer|double|string|boolean is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
69
                $list->push(new ArrayData([
70
                    'Value' => $location
71
                ]));
72
            }
73
        } else {
74
            $list->push($this->Options()->find('Name', 'baseDn'));
75
        }
76
77
        return $list;
78
    }
79
80 View Code Duplication
    public function GroupsSearchLocations()
0 ignored issues
show
This method seems to be duplicated in 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...
81
    {
82
        $locations = Config::inst()->get('LDAPService', 'groups_search_locations');
83
        $list = new ArrayList();
84
        if ($locations) {
85
            foreach ($locations as $location) {
0 ignored issues
show
The expression $locations of type array|integer|double|string|boolean is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
86
                $list->push(new ArrayData([
87
                    'Value' => $location
88
                ]));
89
            }
90
        } else {
91
            $list->push($this->Options()->find('Name', 'baseDn'));
92
        }
93
94
        return $list;
95
    }
96
97
    public function DefaultGroup()
98
    {
99
        $code = Config::inst()->get('LDAPService', 'default_group');
100
        if ($code) {
101
            $group = Group::get()->filter('Code', $code)->limit(1)->first();
102
            if (!($group && $group->exists())) {
103
                return sprintf(
104
                    'WARNING: LDAPService.default_group configured with \'%s\' but there is no Group with that Code in the database!',
105
                    $code
106
                );
107
            } else {
108
                return sprintf('%s (Code: %s)', $group->Title, $group->Code);
109
            }
110
        }
111
112
        return null;
113
    }
114
115
    public function MappedGroups()
116
    {
117
        return LDAPGroupMapping::get();
118
    }
119
120 View Code Duplication
    public function Nodes()
0 ignored issues
show
This method seems to be duplicated in 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...
121
    {
122
        $groups = $this->ldapService->getNodes(false);
123
        $list = new ArrayList();
124
        foreach ($groups as $record) {
125
            $list->push(new ArrayData([
126
                'DN' => $record['dn']
127
            ]));
128
        }
129
        return $list;
130
    }
131
132 View Code Duplication
    public function Groups()
0 ignored issues
show
This method seems to be duplicated in 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...
133
    {
134
        $groups = $this->ldapService->getGroups(false);
135
        $list = new ArrayList();
136
        foreach ($groups as $record) {
137
            $list->push(new ArrayData([
138
                'DN' => $record['dn']
139
            ]));
140
        }
141
        return $list;
142
    }
143
144
    public function Users()
145
    {
146
        return count($this->ldapService->getUsers());
147
    }
148
}
149