Issues (45)

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.

src/Xhgui/Searcher/Pdo.php (6 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 Xhgui_Searcher_Pdo implements Xhgui_Searcher_Interface
4
{
5
    /**
6
     * @var PDO
7
     */
8
    private $pdo;
9
10
    /**
11
     * @var string
12
     */
13
    private $table;
14
15
    /**
16
     * @param PDO    $pdo   An open database connection
17
     * @param string $table Table name where Xhgui profiles are stored
18
     */
19
    public function __construct(PDO $pdo, $table)
20
    {
21
        $this->pdo = $pdo;
22
        $this->table = $table;
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28 View Code Duplication
    public function latest()
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...
29
    {
30
        $stmt = $this->pdo->query("
31
          SELECT
32
            id,
33
            profile,
34
            url,
35
            SERVER,
36
            GET,
37
            ENV,
38
            simple_url,
39
            request_ts,
40
            request_ts_micro,
41
            request_date
42
          FROM {$this->table}
43
          ORDER BY request_date ASC
44
          LIMIT 1
45
        ");
46
47
        $row = $stmt->fetch(PDO::FETCH_ASSOC);
48
        if (false === $row) {
49
            throw new Exception('No profile available yet.');
50
        }
51
52
        return new Xhgui_Profile([
53
            '_id' => $row['id'],
54
            'meta' => [
55
                'url' => $row['url'],
56
                'SERVER' => json_decode($row['SERVER'], true),
57
                'get' => json_decode($row['GET'], true),
58
                'env' => json_decode($row['ENV'], true),
59
                'simple_url' => $row['simple_url'],
60
                'request_ts' => (int) $row['request_ts'],
61
                'request_ts_micro' => $row['request_ts_micro'],
62
                'request_date' => $row['request_date'],
63
            ],
64
            'profile' => json_decode($row['profile'], true)
65
        ]);
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     */
71
    public function query($conditions, $limit, $fields = [])
72
    {
73
        // TODO: Implement query() method.
74
    }
75
76
    /**
77
     * {@inheritdoc}
78
     */
79 View Code Duplication
    public function get($id)
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...
80
    {
81
        $stmt = $this->pdo->prepare("
82
          SELECT
83
            profile,
84
            url,
85
            SERVER,
86
            GET,
87
            ENV,
88
            simple_url,
89
            request_ts,
90
            request_ts_micro,
91
            request_date
92
          FROM {$this->table}
93
          WHERE id = :id
94
        ");
95
96
        $stmt->execute(['id' => $id]);
97
98
        if (false === $row = $stmt->fetch(PDO::FETCH_ASSOC)) {
99
            throw new Exception('No profile data found.');
100
        }
101
102
        return new Xhgui_Profile([
103
            '_id' => $id,
104
            'meta' => [
105
                'url' => $row['url'],
106
                'SERVER' => json_decode($row['SERVER'], true),
107
                'get' => json_decode($row['GET'], true),
108
                'env' => json_decode($row['ENV'], true),
109
                'simple_url' => $row['simple_url'],
110
                'request_ts' => (int) $row['request_ts'],
111
                'request_ts_micro' => $row['request_ts_micro'],
112
                'request_date' => $row['request_date'],
113
            ],
114
            'profile' => json_decode($row['profile'], true)
115
        ]);
116
    }
117
118
    /**
119
     * {@inheritdoc}
120
     */
121
    public function getForUrl($url, $options, $conditions = array())
122
    {
123
        // TODO: Implement getForUrl() method.
124
    }
125
126
    /**
127
     * {@inheritdoc}
128
     */
129
    public function getPercentileForUrl($percentile, $url, $search = array())
130
    {
131
        // TODO: Implement getPercentileForUrl() method.
132
    }
133
134
    /**
135
     * {@inheritdoc}
136
     */
137
    public function getAvgsForUrl($url, $search = array())
138
    {
139
        // TODO: Implement getAvgsForUrl() method.
140
    }
141
142
    /**
143
     * {@inheritdoc}
144
     */
145
    public function getAll($options = array())
146
    {
147
        $sort = $options['sort'];
0 ignored issues
show
$sort is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
148
        $direction = $options['direction'];
0 ignored issues
show
$direction is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
149
        $page = $options['page'];
0 ignored issues
show
$page is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
150
        $perPage = $options['perPage'];
0 ignored issues
show
$perPage is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
151
152
        $stmt = $this->pdo->query("
153
          SELECT
154
            id,
155
            url,
156
            SERVER,
157
            GET,
158
            ENV,
159
            simple_url,
160
            request_ts,
161
            request_ts_micro,
162
            request_date,
163
            main_wt,
164
            main_ct,
165
            main_cpu, 
166
            main_mu,
167
            main_pmu
168
          FROM {$this->table}
169
          ORDER BY request_ts DESC
170
        ", PDO::FETCH_ASSOC);
171
172
        $results = [];
173
        foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
174
            $results[] = new Xhgui_Profile([
175
                '_id' => $row['id'],
176
                'meta' => [
177
                    'url' => $row['url'],
178
                    'SERVER' => json_decode($row['SERVER'], true),
179
                    'get' => json_decode($row['GET'], true),
180
                    'env' => json_decode($row['ENV'], true),
181
                    'simple_url' => $row['simple_url'],
182
                    'request_ts' => $row['request_ts'],
183
                    'request_ts_micro' => $row['request_ts_micro'],
184
                    'request_date' => $row['request_date'],
185
                ],
186
                'profile' => [
187
                    'main()' => [
188
                        'wt' => (int) $row['main_wt'],
189
                        'ct' => (int) $row['main_ct'],
190
                        'cpu' => (int) $row['main_cpu'],
191
                        'mu' => (int) $row['main_mu'],
192
                        'pmu' => (int) $row['main_pmu'],
193
                    ]
194
                ]
195
            ]);
196
        }
197
198
        return array(
199
            'results' => $results,
200
            'sort' => 'meta.request_ts',
201
            'direction' => 'desc',
202
            'page' => 1,
203
            'perPage' => count($results),
204
            'totalPages' => 1
205
        );
206
    }
207
208
    /**
209
     * {@inheritdoc}
210
     */
211
    public function delete($id)
212
    {
213
        $stmt = $this->pdo->prepare("
214
          DELETE FROM {$this->table}
215
          WHERE id = :id
216
        ");
217
218
        $stmt->execute(['id' => $id]);
219
    }
220
221
    /**
222
     * {@inheritdoc}
223
     */
224
    public function truncate()
225
    {
226
        return is_int(
227
            $this->pdo->exec("DELETE FROM {$this->table}")
228
        );
229
    }
230
231
    /**
232
     * {@inheritdoc}
233
     */
234
    public function saveWatch(array $data)
235
    {
236
        return true;
237
    }
238
239
    /**
240
     * {@inheritdoc}
241
     */
242
    public function getAllWatches()
243
    {
244
        return [];
245
    }
246
247
    /**
248
     * {@inheritdoc}
249
     */
250
    public function truncateWatches()
251
    {
252
    }
253
}
254