Issues (7)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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/Client.php (1 issue)

1
<?php
2
namespace Sourceout\LastFm;
3
4
use Sourceout\LastFm\Http\Http;
5
use Sourceout\LastFm\Http\HttpInterface;
6
use Sourceout\LastFm\Providers\GeoInterface;
7
use Sourceout\LastFm\Services\ServiceFactory;
8
use Sourceout\LastFm\Providers\ProviderInterface;
9
use Sourceout\LastFm\Providers\ResourceInterface;
10
use Sourceout\LastFm\Exception\ProviderDoesNotExistException;
11
use Sourceout\LastFm\Exception\UnregisteredProviderException;
12
use Sourceout\LastFm\Exception\IncomptabileProviderTypeException;
13
14
class Client
15
{
16
    /** @var string[] a list of default providers */
17
    private $providers = [
18
        \Sourceout\LastFm\Providers\LastFm\LastFm::class
19
    ];
20
21
    /** @var array a list of provider interfaces */
22
    private $providerInterfaces = [
23
        \Sourceout\LastFm\Providers\ProviderInterface::class,
24
    ];
25
26
    /** @var HttpInterface|null an instance of http used to fetch data */
27
    private $http;
28
29
30 7
    public function __construct(HttpInterface $http = null)
31
    {
32 7
        $this->http = $http;
33 7
    }
34
35
    /**
36
     * Returns a list of registered providers
37
     *
38
     * @return string[]
39
     */
40 4
    public function getRegisteredProviders() : array
41
    {
42 4
        return $this->providers;
43
    }
44
45
    /**
46
     * Add ability to add new custom providers
47
     *
48
     * @param  array $providers
49
     *
50
     * @return void
51
     * @throws ProviderDoesNotExistsException
52
     * @throws IncomptabileProviderTypeException
53
     */
54 3
    public function registerCustomProviders(array $providers) : void
55
    {
56 3
        foreach ($providers as $provider) {
57 3
            if (!class_exists($provider)) {
58 1
                throw new ProviderDoesNotExistException(
59 1
                    "Provider {$provider} does not exists"
60
                );
61
            } else if (
62 2
                !(array_intersect(
63 2
                        $this->providerInterfaces,
64 2
                        class_implements($provider)
65 2
                    ) == $this->providerInterfaces
66
                )
67
            ) {
68 1
                throw new IncomptabileProviderTypeException(
69 1
                    "Provider {$provider} is not compatible"
70
                );
71
            }
72 1
            array_push($this->providers, $provider);
73
        }
74 1
    }
75
76
    /**
77
     * Returns an instance of ServiceFactory
78
     *
79
     * @param ProviderInterface $provider
80
     *
81
     * @return ServiceFactory
82
     * @throws UnregisteredProviderException
83
     */
84 2
    public function getServiceFactory(
85
        ProviderInterface $provider
86
    ) : ServiceFactory
87
    {
0 ignored issues
show
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
Loading history...
88 2
        $class = get_class($provider);
89 2
        if (!in_array($class, $this->getRegisteredProviders())) {
90 1
            throw new UnregisteredProviderException(
91 1
                "Provider {$class} is not registered"
92
            );
93
        }
94
95 1
        $http = $this->http ?: (new Http());
96 1
        return new ServiceFactory($provider, $http);
97
    }
98
99
    /**
100
     * Setter Method
101
     *
102
     * @param HttpInterface $http
103
     * @return void
104
     */
105 1
    public function setHttpClient(HttpInterface $http) : void
106
    {
107 1
        $this->http = $http;
108 1
    }
109
110
    /**
111
     * Getter Method
112
     *
113
     * @return HttpInterface|null
114
     */
115 1
    public function getHttpClient() : ?HttpInterface
116
    {
117 1
        return $this->http;
118
    }
119
}