Issues (41)

Security Analysis    no request data  

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.

src/Searcher/PdoSearcher.php (2 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
namespace XHGui\Searcher;
4
5
use XHGui\Db\PdoRepository;
6
use XHGui\Exception\NotImplementedException;
7
use XHGui\Options\SearchOptions;
8
use XHGui\Profile;
9
10
class PdoSearcher implements SearcherInterface
11
{
12
    /** @var PdoRepository */
13
    private $db;
14
15
    public function __construct(PdoRepository $db)
16
    {
17
        $this->db = $db;
18
    }
19
20
    /**
21
     * {@inheritdoc}
22
     */
23 View Code Duplication
    public function latest(): Profile
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...
24
    {
25
        $row = $this->db->getLatest();
26
27
        return new Profile([
28
            '_id' => $row['id'],
29
            'meta' => [
30
                'url' => $row['url'],
31
                'SERVER' => json_decode($row['SERVER'], true),
32
                'get' => json_decode($row['GET'], true),
33
                'env' => json_decode($row['ENV'], true),
34
                'simple_url' => $row['simple_url'],
35
                'request_ts' => (int) $row['request_ts'],
36
                'request_ts_micro' => $row['request_ts_micro'],
37
                'request_date' => $row['request_date'],
38
            ],
39
            'profile' => json_decode($row['profile'], true),
40
        ]);
41
    }
42
43
    public function query($conditions, $limit, $fields = []): void
44
    {
45
        throw NotImplementedException::notImplementedPdo(__METHOD__);
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51 View Code Duplication
    public function get($id): Profile
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...
52
    {
53
        $row = $this->db->getById($id);
54
55
        return new Profile([
56
            '_id' => $id,
57
            'meta' => [
58
                'url' => $row['url'],
59
                'SERVER' => json_decode($row['SERVER'], true),
60
                'get' => json_decode($row['GET'], true),
61
                'env' => json_decode($row['ENV'], true),
62
                'simple_url' => $row['simple_url'],
63
                'request_ts' => (int) $row['request_ts'],
64
                'request_ts_micro' => $row['request_ts_micro'],
65
                'request_date' => $row['request_date'],
66
            ],
67
            'profile' => json_decode($row['profile'], true),
68
        ]);
69
    }
70
71
    public function getForUrl($url, $options, $conditions = []): void
72
    {
73
        throw NotImplementedException::notImplementedPdo(__METHOD__);
74
    }
75
76
    public function getPercentileForUrl($percentile, $url, $search = []): void
77
    {
78
        throw NotImplementedException::notImplementedPdo(__METHOD__);
79
    }
80
81
    /**
82
     * {@inheritdoc}
83
     */
84
    public function getAvgsForUrl($url, $search = []): void
85
    {
86
        throw NotImplementedException::notImplementedPdo(__METHOD__);
87
    }
88
89
    /**
90
     * {@inheritdoc}
91
     */
92
    public function getAll(SearchOptions $options): array
93
    {
94
        $page = $options['page'];
95
        $direction = $options['direction'];
96
        $perPage = $options['perPage'];
97
        $url = $options['conditions']['url'] ?? '';
98
99
        $totalRows = $this->db->countByUrl($url);
100
        $totalPages = max(ceil($totalRows / $perPage), 1);
101
        if ($page > $totalPages) {
102
            $page = $totalPages;
103
        }
104
        $skip = ($page - 1) * $perPage;
105
106
        $results = [];
107
        foreach ($this->db->findByUrl($url, $direction, $skip, $perPage) as $row) {
108
            $results[] = new Profile([
109
                '_id' => $row['id'],
110
                'meta' => [
111
                    'url' => $row['url'],
112
                    'SERVER' => json_decode($row['SERVER'], true),
113
                    'get' => json_decode($row['GET'], true),
114
                    'env' => json_decode($row['ENV'], true),
115
                    'simple_url' => $row['simple_url'],
116
                    'request_ts' => $row['request_ts'],
117
                    'request_ts_micro' => $row['request_ts_micro'],
118
                    'request_date' => $row['request_date'],
119
                ],
120
                'profile' => [
121
                    'main()' => [
122
                        'wt' => (int) $row['main_wt'],
123
                        'ct' => (int) $row['main_ct'],
124
                        'cpu' => (int) $row['main_cpu'],
125
                        'mu' => (int) $row['main_mu'],
126
                        'pmu' => (int) $row['main_pmu'],
127
                    ],
128
                ],
129
            ]);
130
        }
131
132
        return [
133
            'results' => $results,
134
            'sort' => 'meta.request_ts',
135
            'direction' => $direction,
136
            'page' => $page,
137
            'perPage' => $perPage,
138
            'totalPages' => $totalPages,
139
        ];
140
    }
141
142
    /**
143
     * {@inheritdoc}
144
     */
145
    public function delete($id): void
146
    {
147
        $this->db->deleteById($id);
148
    }
149
150
    public function truncate()
151
    {
152
        $this->db->deleteAll();
153
154
        return $this;
155
    }
156
157
    /**
158
     * {@inheritdoc}
159
     */
160
    public function saveWatch(array $data)
161
    {
162
        return true;
163
    }
164
165
    /**
166
     * {@inheritdoc}
167
     */
168
    public function getAllWatches()
169
    {
170
        return [];
171
    }
172
173
    /**
174
     * {@inheritdoc}
175
     */
176
    public function truncateWatches()
177
    {
178
        return $this;
179
    }
180
181
    /**
182
     * {@inheritdoc}
183
     */
184
    public function stats()
185
    {
186
        $row = $this->db->getStatistics();
187
188
        if (!$row) {
189
            $row = [
190
                'profiles' => 0,
191
                'latest' => 0,
192
                'bytes' => 0,
193
            ];
194
        }
195
196
        return $row;
197
    }
198
}
199