GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (15)

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/Provider/Http/UdgerCom.php (1 issue)

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
namespace UserAgentParser\Provider\Http;
3
4
use GuzzleHttp\Client;
5
use GuzzleHttp\Psr7\Request;
6
use stdClass;
7
use UserAgentParser\Exception;
8
use UserAgentParser\Model;
9
10
/**
11
 * Abstraction of udger.com
12
 *
13
 * @author Martin Keckeis <[email protected]>
14
 * @license MIT
15
 * @see https://udger.com/support/documentation/?doc=38
16
 */
17
class UdgerCom extends AbstractHttpProvider
18
{
19
    /**
20
     * Name of the provider
21
     *
22
     * @var string
23
     */
24
    protected $name = 'UdgerCom';
25
26
    /**
27
     * Homepage of the provider
28
     *
29
     * @var string
30
     */
31
    protected $homepage = 'https://udger.com/';
32
33
    protected $detectionCapabilities = [
34
35
        'browser' => [
36
            'name'    => true,
37
            'version' => true,
38
        ],
39
40
        'renderingEngine' => [
41
            'name'    => true,
42
            'version' => false,
43
        ],
44
45
        'operatingSystem' => [
46
            'name'    => true,
47
            'version' => false,
48
        ],
49
50
        'device' => [
51
            'model'    => false,
52
            'brand'    => false,
53
            'type'     => true,
54
            'isMobile' => false,
55
            'isTouch'  => false,
56
        ],
57
58
        'bot' => [
59
            'isBot' => true,
60
            'name'  => false,
61
            'type'  => false,
62
        ],
63
    ];
64
65
    protected $defaultValues = [
66
        'general' => [
67
            '/^unknown$/i',
68
        ],
69
    ];
70
71
    private static $uri = 'http://api.udger.com/parse';
72
73
    private $apiKey;
74
75 21
    public function __construct(Client $client, $apiKey)
76
    {
77 21
        parent::__construct($client);
78
79 21
        $this->apiKey = $apiKey;
80 21
    }
81
82 7
    public function getVersion()
83
    {
84 7
        return;
85
    }
86
87
    /**
88
     *
89
     * @param  string                     $userAgent
90
     * @param  array                      $headers
91
     * @return stdClass
92
     * @throws Exception\RequestException
93
     */
94 14
    protected function getResult($userAgent, array $headers)
0 ignored issues
show
The parameter $headers is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
95
    {
96
        /*
97
         * an empty UserAgent makes no sense
98
         */
99 14
        if ($userAgent == '') {
100 1
            throw new Exception\NoResultFoundException('No result found for user agent: ' . $userAgent);
101
        }
102
103
        $params = [
104 13
            'accesskey' => $this->apiKey,
105 13
            'uastrig'   => $userAgent,
106
        ];
107
108 13
        $body = http_build_query($params, null, '&');
109
110 13
        $request = new Request('POST', self::$uri, [
111 13
            'Content-Type' => 'application/x-www-form-urlencoded',
112
        ], $body);
113
114 13
        $response = $this->getResponse($request);
115
116
        /*
117
         * no json returned?
118
         */
119 12
        $contentType = $response->getHeader('Content-Type');
120 12
        if (! isset($contentType[0]) || $contentType[0] != 'application/json') {
121 1
            throw new Exception\RequestException('Could not get valid "application/json" response from "' . $request->getUri() . '". Response is "' . $response->getBody()->getContents() . '"');
122
        }
123
124 11
        $content = json_decode($response->getBody()->getContents());
125
126
        /*
127
         * No result found?
128
         */
129 11
        if (isset($content->flag) && $content->flag == 3) {
130 1
            throw new Exception\NoResultFoundException('No result found for user agent: ' . $userAgent);
131
        }
132
133
        /*
134
         * Errors
135
         */
136 10
        if (isset($content->flag) && $content->flag == 4) {
137 1
            throw new Exception\InvalidCredentialsException('Your API key "' . $this->apiKey . '" is not valid for ' . $this->getName());
138
        }
139
140 9
        if (isset($content->flag) && $content->flag == 6) {
141 1
            throw new Exception\LimitationExceededException('Exceeded the maximum number of request with API key "' . $this->apiKey . '" for ' . $this->getName());
142
        }
143
144 8
        if (isset($content->flag) && $content->flag > 3) {
145 1
            throw new Exception\RequestException('Could not get valid response from "' . $request->getUri() . '". Response is "' . $response->getBody()->getContents() . '"');
146
        }
147
148
        /*
149
         * Missing data?
150
         */
151 7
        if (! $content instanceof stdClass || ! isset($content->info)) {
152 1
            throw new Exception\RequestException('Could not get valid response from "' . $request->getUri() . '". Response is "' . $response->getBody()->getContents() . '"');
153
        }
154
155 6
        return $content;
156
    }
157
158
    /**
159
     *
160
     * @param  stdClass $resultRaw
161
     * @return boolean
162
     */
163 6
    private function isBot(stdClass $resultRaw)
164
    {
165 6
        if (isset($resultRaw->type) && $resultRaw->type === 'Robot') {
166 2
            return true;
167
        }
168
169 4
        return false;
170
    }
171
172
    /**
173
     *
174
     * @param Model\Bot $bot
175
     * @param stdClass  $resultRaw
176
     */
177 2
    private function hydrateBot(Model\Bot $bot, stdClass $resultRaw)
178
    {
179 2
        $bot->setIsBot(true);
180
181 2
        if (isset($resultRaw->ua_family)) {
182 2
            $bot->setName($this->getRealResult($resultRaw->ua_family));
183
        }
184 2
    }
185
186
    /**
187
     *
188
     * @param Model\Browser $browser
189
     * @param stdClass      $resultRaw
190
     */
191 4
    private function hydrateBrowser(Model\Browser $browser, stdClass $resultRaw)
192
    {
193 4
        if (isset($resultRaw->ua_family)) {
194 1
            $browser->setName($this->getRealResult($resultRaw->ua_family, 'browser', 'name'));
195
        }
196
197 4
        if (isset($resultRaw->ua_ver)) {
198 1
            $browser->getVersion()->setComplete($this->getRealResult($resultRaw->ua_ver));
199
        }
200 4
    }
201
202
    /**
203
     *
204
     * @param Model\RenderingEngine $engine
205
     * @param stdClass              $resultRaw
206
     */
207 4
    private function hydrateRenderingEngine(Model\RenderingEngine $engine, stdClass $resultRaw)
208
    {
209 4
        if (isset($resultRaw->ua_engine)) {
210 1
            $engine->setName($this->getRealResult($resultRaw->ua_engine));
211
        }
212 4
    }
213
214
    /**
215
     *
216
     * @param Model\OperatingSystem $os
217
     * @param stdClass              $resultRaw
218
     */
219 4
    private function hydrateOperatingSystem(Model\OperatingSystem $os, stdClass $resultRaw)
220
    {
221 4
        if (isset($resultRaw->os_family)) {
222 1
            $os->setName($this->getRealResult($resultRaw->os_family));
223
        }
224 4
    }
225
226
    /**
227
     *
228
     * @param Model\Device $device
229
     * @param stdClass     $resultRaw
230
     */
231 4
    private function hydrateDevice(Model\Device $device, stdClass $resultRaw)
232
    {
233 4
        if (isset($resultRaw->device_name)) {
234 1
            $device->setType($this->getRealResult($resultRaw->device_name));
235
        }
236 4
    }
237
238 14
    public function parse($userAgent, array $headers = [])
239
    {
240 14
        $resultRaw = $this->getResult($userAgent, $headers);
241
242
        /*
243
         * Hydrate the model
244
         */
245 6
        $result = new Model\UserAgent($this->getName(), $this->getVersion());
246 6
        $result->setProviderResultRaw($resultRaw);
247
248
        /*
249
         * Bot detection
250
         */
251 6
        if ($this->isBot($resultRaw->info) === true) {
252 2
            $this->hydrateBot($result->getBot(), $resultRaw->info);
253
254 2
            return $result;
255
        }
256
257
        /*
258
         * hydrate the result
259
         */
260 4
        $this->hydrateBrowser($result->getBrowser(), $resultRaw->info);
261 4
        $this->hydrateRenderingEngine($result->getRenderingEngine(), $resultRaw->info);
262 4
        $this->hydrateOperatingSystem($result->getOperatingSystem(), $resultRaw->info);
263 4
        $this->hydrateDevice($result->getDevice(), $resultRaw->info);
264
265 4
        return $result;
266
    }
267
}
268