Issues (63)

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.

DataCollector/LdapToolsDataCollector.php (6 issues)

Labels
Severity

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
 * This file is part of the LdapToolsBundle package.
4
 *
5
 * (c) Chad Sikorra <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace LdapTools\Bundle\LdapToolsBundle\DataCollector;
12
13
use LdapTools\Bundle\LdapToolsBundle\Log\LdapProfilerLogger;
14
use LdapTools\LdapManager;
15
use LdapTools\Log\LogOperation;
16
use Symfony\Component\HttpFoundation\Request;
17
use Symfony\Component\HttpFoundation\Response;
18
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
19
20
/**
21
 * Data Collector for LdapTools.
22
 *
23
 * @author Chad Sikorra <[email protected]>
24
 */
25
class LdapToolsDataCollector extends DataCollector
26
{
27
    /**
28
     * @var LdapManager
29
     */
30
    protected $ldap;
31
32
    /**
33
     * @var LdapProfilerLogger
34
     */
35
    protected $logger;
36
37
    /**
38
     * LdapToolsDataCollector constructor.
39
     * @param LdapProfilerLogger $logger
40
     * @param LdapManager|null $ldap
41
     */
42
    public function __construct(LdapProfilerLogger $logger, LdapManager $ldap = null)
43
    {
44
        $this->ldap = $ldap;
45
        $this->logger = $logger;
46
        $this->reset();
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function getName()
53
    {
54
        return 'ldaptools';
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public function collect(Request $request, Response $response, \Exception $exception = null)
61
    {
62
        if (!$this->ldap) {
63
            return;
64
        }
65
        $this->data['domains'] = $this->ldap->getDomains();
66
67
        $this->data['operations_by_domain'] = [];
68
        foreach ($this->data['domains'] as $domain) {
69
            $this->data['operations_by_domain'][$domain] = $this->addOperationToData(...$this->logger->getOperations($domain));
70
        }
71
        $this->data['operations'] = $this->addOperationToData(...$this->logger->getOperations());
72
        $this->data['errors'] = $this->addOperationToData(...$this->logger->getErrors());
73
    }
74
75
    /**
76
     * {@inheritdoc}
77
     */
78
    public function reset()
79
    {
80
        $this->data['domains'] = [];
81
        $this->data['errors'] = [];
82
        $this->data['operations'] = [];
83
        $this->data['operations_by_domain'] = [];
84
    }
85
86
    /**
87
     * @return array
88
     */
89
    public function getOperationsByDomain()
90
    {
91
        return $this->data['operations_by_domain'];
92
    }
93
94
    /**
95
     * @return int
96
     */
97
    public function getTime()
98
    {
99
        $time = 0;
100
101
        foreach ($this->data['operations'] as $operation) {
102
            $time += $operation['duration'];
103
        }
104
105
        return $time;
106
    }
107
108
    /**
109
     * @return array
110
     */
111
    public function getOperations()
112
    {
113
        return $this->data['operations'];
114
    }
115
116
    /**
117
     * @return array
118
     */
119
    public function getErrors()
120
    {
121
        return $this->data['errors'];
122
    }
123
124
    /**
125
     * @return string[]
126
     */
127
    public function getDomains()
128
    {
129
        return $this->data['domains'];
130
    }
131
132
    /**
133
     * @param \LdapTools\Log\LogOperation[] ...$logs
134
     * @return array
135
     */
136
    protected function addOperationToData(LogOperation ...$logs)
137
    {
138
        $logData  = [];
139
140
        foreach ($logs as $log) {
141
            $data = [];
142
143
            $data['data'] = $log->getOperation()->getLogArray();
0 ignored issues
show
The method getOperation cannot be called on $log (of type array<integer,object<LdapTools\Log\LogOperation>>).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
144
            $data['startTime'] = $log->getStartTime();
0 ignored issues
show
The method getStartTime cannot be called on $log (of type array<integer,object<LdapTools\Log\LogOperation>>).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
145
            $data['stopTime'] = $log->getStopTime();
0 ignored issues
show
The method getStopTime cannot be called on $log (of type array<integer,object<LdapTools\Log\LogOperation>>).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
146
            $data['domain'] = $log->getDomain();
0 ignored issues
show
The method getDomain cannot be called on $log (of type array<integer,object<LdapTools\Log\LogOperation>>).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
147
            $data['error'] = $log->getError();
0 ignored issues
show
The method getError cannot be called on $log (of type array<integer,object<LdapTools\Log\LogOperation>>).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
148
            $data['name'] = $log->getOperation()->getName();
0 ignored issues
show
The method getOperation cannot be called on $log (of type array<integer,object<LdapTools\Log\LogOperation>>).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
149
            $data['duration'] = ($data['stopTime'] - $data['startTime']) * 1000;
150
151
            $logData[] = $data;
152
        }
153
154
        return $logData;
155
    }
156
}
157