Issues (26)

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/HttpClientConfigurator.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
declare(strict_types=1);
4
5
/*
6
 * This software may be modified and distributed under the terms
7
 * of the MIT license. See the LICENSE file for details.
8
 */
9
10
namespace FAPI\PhraseApp;
11
12
use Http\Client\Common\Plugin;
13
use Http\Client\Common\PluginClient;
14
use Http\Client\HttpClient;
15
use Http\Discovery\HttpClientDiscovery;
16
use Http\Discovery\Psr17FactoryDiscovery;
17
use Http\Message\Authentication\BasicAuth;
18
use Psr\Http\Message\UriFactoryInterface;
19
20
/**
21
 * Configure an HTTP client.
22
 *
23
 * @author Sascha-Oliver Prolic <[email protected]>
24
 *
25
 * @internal This class should not be used outside of the API Client, it is not part of the BC promise.
26
 */
27
final class HttpClientConfigurator
28
{
29
    /**
30
     * @var string
31
     */
32
    private $endpoint = 'https://api.phraseapp.com';
33
34
    /**
35
     * @var UriFactoryInterface
36
     */
37
    private $uriFactory;
38
39
    /**
40
     * @var HttpClient
41
     */
42
    private $httpClient;
43
44
    /**
45
     * @var Plugin[]
46
     */
47
    private $prependPlugins = [];
48
49
    /**
50
     * @var Plugin[]
51
     */
52
    private $appendPlugins = [];
53
54
    /**
55
     * @var string
56
     */
57
    private $token;
58
59
    /**
60
     * @param string                   $token
61
     * @param HttpClient|null          $httpClient
62
     * @param UriFactoryInterface|null $uriFactory
63
     */
64 4
    public function __construct(string $token, HttpClient $httpClient = null, UriFactoryInterface $uriFactory = null)
65
    {
66 4
        $this->token = $token;
67 4
        $this->httpClient = $httpClient ?? HttpClientDiscovery::find();
68 4
        $this->uriFactory = $uriFactory ?? Psr17FactoryDiscovery::findUrlFactory();
0 ignored issues
show
Deprecated Code introduced by
The method Http\Discovery\Psr17Fact...overy::findUrlFactory() has been deprecated with message: This will be removed in 2.0. Consider using the findUriFactory() method.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
69 4
    }
70
71
    /**
72
     * @return HttpClient
73
     */
74
    public function createConfiguredClient(): HttpClient
75
    {
76
        $plugins = $this->prependPlugins;
77
78
        $plugins[] = new Plugin\AuthenticationPlugin(new BasicAuth($this->token, ''));
79
        $plugins[] = new Plugin\AddHostPlugin($this->uriFactory->createUri($this->endpoint));
80
        $plugins[] = new Plugin\HeaderDefaultsPlugin([
81
            'User-Agent' => 'FriendsOfApi/PhraseApp (https://github.com/FriendsOfApi/phraseapp)',
82
        ]);
83
84
        return new PluginClient($this->httpClient, array_merge($plugins, $this->appendPlugins));
85
    }
86
87
    /**
88
     * @param string $endpoint
89
     *
90
     * @return HttpClientConfigurator
91
     */
92
    public function setEndpoint(string $endpoint): HttpClientConfigurator
93
    {
94
        $this->endpoint = $endpoint;
95
96
        return $this;
97
    }
98
99
    /**
100
     * @param Plugin ...$plugin
101
     *
102
     * @return HttpClientConfigurator
103
     */
104 2
    public function appendPlugin(Plugin ...$plugin): HttpClientConfigurator
105
    {
106 2
        foreach ($plugin as $p) {
107 2
            $this->appendPlugins[] = $p;
108
        }
109
110 2
        return $this;
111
    }
112
113
    /**
114
     * @param Plugin ...$plugin
115
     *
116
     * @return HttpClientConfigurator
117
     */
118 2
    public function prependPlugin(Plugin ...$plugin): HttpClientConfigurator
119
    {
120 2
        $plugin = array_reverse($plugin);
121 2
        foreach ($plugin as $p) {
122 2
            array_unshift($this->prependPlugins, $p);
123
        }
124
125 2
        return $this;
126
    }
127
}
128