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 (40)

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/AsyncClient.php (3 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 declare(strict_types=1);
2
3
namespace ApiClients\Client\Twitter;
4
5
use ApiClients\Foundation\Client;
6
use ApiClients\Foundation\Factory;
7
use ApiClients\Foundation\Hydrator\CommandBus\Command\HydrateCommand;
8
use ApiClients\Foundation\Options;
9
use ApiClients\Foundation\Transport\CommandBus\Command\RequestCommand;
10
use ApiClients\Foundation\Transport\Options as TransportOptions;
11
use ApiClients\Middleware\Oauth1\Oauth1Middleware;
12
use ApiClients\Middleware\Oauth1\Options as Oauth1Options;
13
use ApiClients\Tools\CommandBus\CommandBusInterface;
14
use ApiClients\Tools\Psr7\Oauth1\Definition;
15
use GuzzleHttp\Psr7\Request;
16
use Psr\Http\Message\ResponseInterface;
17
use React\EventLoop\LoopInterface;
18
use React\Promise\PromiseInterface;
19
use function React\Promise\resolve;
20
21
final class AsyncClient implements AsyncClientInterface
22
{
23
24
    /**
25
     * @var Client
26
     */
27
    protected $client;
28
29
    /**
30
     * @var array
31
     */
32
    protected $options;
33
34
    /**
35
     * @var AsyncStreamingClient
36
     */
37
    protected $streamingClient;
38
    /**
39
     * @var string
40
     */
41
    private $consumerKey;
42
43
    /**
44
     * @var string
45
     */
46
    private $consumerSecret;
47
48
    /**
49
     * @var LoopInterface
50
     */
51
    private $loop;
52
53
    /**
54
     * AsyncClient constructor.
55
     * @param string        $consumerKey
56
     * @param string        $consumerSecret
57
     * @param LoopInterface $loop
58
     * @param array         $options
59
     * @param Client|null   $client
60
     */
61 2
    public function __construct(
62
        string $consumerKey,
63
        string $consumerSecret,
64
        LoopInterface $loop,
65
        array $options = [],
66
        Client $client = null
67
    ) {
68 2
        $this->consumerKey = $consumerKey;
69 2
        $this->consumerSecret = $consumerSecret;
70 2
        $this->loop = $loop;
71
72 2
        if (!($client instanceof Client)) {
73 2
            $this->options = ApiSettings::getOptions(
74 2
                $consumerKey,
75 2
                $consumerSecret,
76 2
                'Async',
77 2
                $options
78
            );
79
80 2
            $client = Factory::create($this->loop, $this->options);
81
        }
82
83 2
        $this->client = $client;
84 2
    }
85
86 2
    public function withAccessToken(string $accessToken, string $accessTokenSecret): AsyncClient
87
    {
88 2
        $options = $this->options;
89
        // @codingStandardsIgnoreStart
90 2
        $options[Options::TRANSPORT_OPTIONS][TransportOptions::DEFAULT_REQUEST_OPTIONS][Oauth1Middleware::class][Oauth1Options::ACCESS_TOKEN] = new Definition\AccessToken($accessToken);
91 2
        $options[Options::TRANSPORT_OPTIONS][TransportOptions::DEFAULT_REQUEST_OPTIONS][Oauth1Middleware::class][Oauth1Options::TOKEN_SECRET] = new Definition\TokenSecret($accessTokenSecret);
92
        // @codingStandardsIgnoreEnd
93
94 2
        return new self(
95 2
            $this->consumerKey,
96 2
            $this->consumerSecret,
97 2
            $this->loop,
98 2
            $options
99
        );
100
    }
101
102 1
    public function withOutAccessToken(): AsyncClient
103
    {
104 1
        $options = $this->options;
105
        // @codingStandardsIgnoreStart
106 1 View Code Duplication
        if (isset($options[Options::TRANSPORT_OPTIONS][TransportOptions::DEFAULT_REQUEST_OPTIONS][Oauth1Middleware::class][Oauth1Options::ACCESS_TOKEN])) {
107 1
            unset($options[Options::TRANSPORT_OPTIONS][TransportOptions::DEFAULT_REQUEST_OPTIONS][Oauth1Middleware::class][Oauth1Options::ACCESS_TOKEN]);
108
        }
109 1 View Code Duplication
        if (isset($options[Options::TRANSPORT_OPTIONS][TransportOptions::DEFAULT_REQUEST_OPTIONS][Oauth1Middleware::class][Oauth1Options::TOKEN_SECRET])) {
110 1
            unset($options[Options::TRANSPORT_OPTIONS][TransportOptions::DEFAULT_REQUEST_OPTIONS][Oauth1Middleware::class][Oauth1Options::TOKEN_SECRET]);
111
        }
112
        // @codingStandardsIgnoreEnd
113
114 1
        return new self(
115 1
            $this->consumerKey,
116 1
            $this->consumerSecret,
117 1
            $this->loop,
118 1
            $options
119
        );
120
    }
121
122
    public function getCommandBus(): CommandBusInterface
123
    {
124
        return $this->client->getFromContainer(CommandBusInterface::class);
125
    }
126
127 View Code Duplication
    public function profile(): PromiseInterface
128
    {
129
        return $this->client->handle(new RequestCommand(
130
            new Request('GET', 'account/verify_credentials.json')
131
        ))->then(function (ResponseInterface $response) {
132
            return resolve($this->client->handle(new HydrateCommand('Profile', $response->getBody()->getParsedContents())));
0 ignored issues
show
It seems like you code against a concrete implementation and not the interface Psr\Http\Message\StreamInterface as the method getParsedContents() does only exist in the following implementations of said interface: ApiClients\Middleware\Json\JsonStream.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
133
        });
134
    }
135
136 View Code Duplication
    public function user(string $user): PromiseInterface
137
    {
138
        return $this->client->handle(new RequestCommand(
139
            new Request('GET', 'users/show.json?screen_name=' . $user)
140
        ))->then(function (ResponseInterface $response) {
141
            return resolve($this->client->handle(new HydrateCommand('User', $response->getBody()->getParsedContents())));
0 ignored issues
show
It seems like you code against a concrete implementation and not the interface Psr\Http\Message\StreamInterface as the method getParsedContents() does only exist in the following implementations of said interface: ApiClients\Middleware\Json\JsonStream.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
142
        });
143
    }
144
145
    public function tweet(string $status, array $tweet = []): PromiseInterface
146
    {
147
        $tweet['status'] = $status;
148
149
        return $this->client->handle(new RequestCommand(
150
            new Request('POST', 'statuses/update.json?' . http_build_query($tweet))
151
        ))->then(function (ResponseInterface $response) {
152
            return resolve($this->client->handle(new HydrateCommand('Tweet', $response->getBody()->getParsedContents())));
0 ignored issues
show
It seems like you code against a concrete implementation and not the interface Psr\Http\Message\StreamInterface as the method getParsedContents() does only exist in the following implementations of said interface: ApiClients\Middleware\Json\JsonStream.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
153
        });
154
    }
155
156
    public function stream(): AsyncStreamingClientInterface
157
    {
158
        if (!($this->streamingClient instanceof AsyncStreamingClient)) {
159
            $this->streamingClient = new AsyncStreamingClient($this->client);
160
        }
161
162
        return $this->streamingClient;
163
    }
164
}
165