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 | * Class LDAPDebugController |
||
4 | * |
||
5 | * This controller is used to debug the LDAP connection. |
||
6 | */ |
||
7 | class LDAPDebugController extends ContentController |
||
0 ignored issues
–
show
|
|||
8 | { |
||
9 | |||
10 | /** |
||
11 | * @var array |
||
12 | */ |
||
13 | private static $allowed_actions = [ |
||
0 ignored issues
–
show
|
|||
14 | 'index', |
||
15 | ]; |
||
16 | |||
17 | /** |
||
18 | * @var array |
||
19 | */ |
||
20 | private static $dependencies = [ |
||
0 ignored issues
–
show
|
|||
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.
![]() |
|||
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. ![]() |
|||
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.
![]() |
|||
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. ![]() |
|||
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.
![]() |
|||
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. ![]() |
|||
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. ![]() |
|||
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 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.