Issues (12)

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/Omdb.php (1 issue)

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
 * Created by Marcin.
4
 * Date: 09.12.2017
5
 * Time: 22:46
6
 */
7
8
namespace mrcnpdlk\Xmdb;
9
10
11
use Campo\UserAgent;
12
use Curl\Curl;
13
use HttpLib\Http;
14
use mrcnpdlk\Xmdb\Model\Omdb\Title;
15
use mrcnpdlk\Xmdb\Model\Ratio;
16
17
class Omdb
18
{
19
    /**
20
     * @var \mrcnpdlk\Xmdb\Client
21
     */
22
    private $oClient;
23
    /**
24
     * @var \Psr\Log\LoggerInterface
25
     */
26
    private $oLog;
27
    /**
28
     * @var \mrcnpdlk\Psr16Cache\Adapter
29
     */
30
    private $oAdapter;
31
    /**
32
     * @var string
33
     */
34
    private $sToken;
35
    /**
36
     * @var string
37
     */
38
    private $url;
39
40
    /**
41
     * Omdb constructor.
42
     *
43
     * @param \mrcnpdlk\Xmdb\Client $oClient
44
     *
45
     * @throws \mrcnpdlk\Xmdb\Exception
46
     */
47
    public function __construct(Client $oClient)
48
    {
49
        $this->oClient  = $oClient;
50
        $this->oLog     = $oClient->getLogger();
51
        $this->oAdapter = $oClient->getAdapter();
52
        $this->sToken   = $oClient->getOmdbToken();
53
        $this->url      = 'http://www.omdbapi.com/?r=json&apikey=' . $oClient->getOmdbToken();
54
    }
55
56
    /**
57
     * @param string                          $imdbId
58
     *
59
     * @param \mrcnpdlk\Xmdb\Model\Ratio|null $oRatio
60
     *
61
     * @return Title
62
     * @throws \mrcnpdlk\Xmdb\Exception
63
     */
64
    public function getByImdbId(string $imdbId, Ratio $oRatio = null)
65
    {
66
        try {
67
            $oResp = $this->oClient->getAdapter()->useCache(
68
                function () use ($imdbId) {
69
                    $oCurl = new Curl();
70
                    $oCurl->setUserAgent(UserAgent::random());
71
                    $oCurl->setHeader('Accept-Language', $this->oClient->getLang());
72
                    $params = [
73
                        'i'    => $imdbId,
74
                        'plot' => 'full',
75
                        'r'    => 'json',
76
                    ];
77
                    $oCurl->get($this->url . '&' . http_build_query($params));
78
79
                    if ($oCurl->error) {
80
                        throw new \RuntimeException('Curl Error! ' . ($oCurl->httpStatusCode ? Http::message($oCurl->httpStatusCode) : 'Unknown code'),
81
                            $oCurl->error_code);
82
                    }
83
                    if ($oCurl->response->Response !== 'True') {
84
                        throw new \RuntimeException($oCurl->response->Error);
85
                    }
86
87
                    return $oCurl->response;
88
                },
89
                [__METHOD__, $imdbId, $this->oClient->getLang()],
90
                3600 * 2)
91
            ;
92
93
            $oTitle = Title::create($oResp);
94
95
            if ($oRatio) {
96
                $oRatio->calculateRatio([$oTitle]);
0 ignored issues
show
array($oTitle) is of type array<integer,object<mrc...\Model\\Omdb\\Title>"}>, but the function expects a array<integer,object<mrc...Xmdb\Model\Imdb\Title>>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
97
            }
98
99
            return $oTitle;
100
101
        } catch (\Exception $e) {
102
            throw new Exception($e->getMessage(), 1, $e);
103
        }
104
    }
105
106
    /**
107
     * @param string $title
108
     *
109
     * @return Title
110
     * @throws \mrcnpdlk\Xmdb\Exception
111
     */
112
    public function getByTitle(string $title)
113
    {
114
        try {
115
            $oResp = $this->oClient->getAdapter()->useCache(
116
                function () use ($title) {
117
                    $oCurl = new Curl();
118
                    $oCurl->setUserAgent(UserAgent::random());
119
                    $oCurl->setHeader('Accept-Language', $this->oClient->getLang());
120
                    $params = [
121
                        't'    => $title,
122
                        'plot' => 'full',
123
                        'r'    => 'json',
124
                    ];
125
                    $oCurl->get($this->url . '&' . http_build_query($params));
126
127
                    if ($oCurl->error) {
128
                        throw new \RuntimeException('Curl Error! ' . ($oCurl->httpStatusCode ? Http::message($oCurl->httpStatusCode) : 'Unknown code'),
129
                            $oCurl->error_code);
130
                    }
131
                    if ($oCurl->response->Response !== 'True') {
132
                        throw new \RuntimeException($oCurl->response->Error);
133
                    }
134
135
                    return $oCurl->response;
136
                },
137
                [__METHOD__, $title, $this->oClient->getLang()],
138
                3600 * 2)
139
            ;
140
141
142
            return Title::create($oResp);
143
144
        } catch (\Exception $e) {
145
            throw new Exception($e->getMessage(), 1, $e);
146
        }
147
    }
148
149
}
150