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

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

Labels
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
3
declare(strict_types=1);
4
5
namespace ReactParallel\Pool\Infinite;
6
7
use Closure;
8
use React\EventLoop\LoopInterface;
9
use React\EventLoop\TimerInterface;
10
use React\Promise\Promise;
11
use React\Promise\PromiseInterface;
12
use ReactParallel\Contracts\ClosedException;
13
use ReactParallel\Contracts\GroupInterface;
14
use ReactParallel\Contracts\LowLevelPoolInterface;
15
use ReactParallel\EventLoop\EventLoopBridge;
16
use ReactParallel\Runtime\Runtime;
17
use WyriHaximus\PoolInfo\Info;
18
19
use function array_key_exists;
20
use function array_pop;
21
use function assert;
22
use function count;
23
use function dirname;
24
use function file_exists;
25
use function is_string;
26
use function React\Promise\reject;
27
use function spl_object_hash;
28
29
use const DIRECTORY_SEPARATOR;
30
31
final class Infinite implements LowLevelPoolInterface
32
{
33
    private LoopInterface $loop;
0 ignored issues
show
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
34
35
    /** @var Runtime[] */
36
    private array $runtimes = [];
37
38
    /** @var string[] */
39
    private array $idleRuntimes = [];
40
41
    /** @var TimerInterface[] */
42
    private array $ttlTimers = [];
43
44
    private EventLoopBridge $eventLoopBridge;
45
46
    private string $autoload;
47
48
    private float $ttl;
49
50
    /** @var GroupInterface[] */
51
    private array $groups = [];
52
53
    private bool $closed = false;
54
55
    public function __construct(LoopInterface $loop, EventLoopBridge $eventLoopBridge, float $ttl)
56
    {
57
        $this->loop     = $loop;
58
        $this->ttl      = $ttl;
59
        $this->autoload = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
60
        foreach ([2, 5] as $level) {
61
            $this->autoload = dirname(__FILE__, $level) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
62
            if (file_exists($this->autoload)) {
63
                break;
64
            }
65
        }
66
67
        $this->eventLoopBridge = $eventLoopBridge;
68
    }
69
70
    /**
71
     * @param mixed[] $args
72
     */
73
    public function run(Closure $callable, array $args = []): PromiseInterface
74
    {
75
        if ($this->closed === true) {
76
            return reject(ClosedException::create());
77
        }
78
79
        return (new Promise(function (callable $resolve, callable $reject): void {
80
            if (count($this->idleRuntimes) === 0) {
81
                $resolve($this->spawnRuntime());
82
83
                return;
84
            }
85
86
            $resolve($this->getIdleRuntime());
87
        }))->then(function (Runtime $runtime) use ($callable, $args): PromiseInterface {
88
            /** @psalm-suppress UndefinedInterfaceMethod */
89
            return $runtime->run($callable, $args)->always(function () use ($runtime): void {
90
                if ($this->ttl >= 0.1) {
91
                    $this->addRuntimeToIdleList($runtime);
92
                    $this->startTtlTimer($runtime);
93
94
                    return;
95
                }
96
97
                $this->closeRuntime(spl_object_hash($runtime));
98
            });
99
        });
100
    }
101
102
    public function close(): bool
103
    {
104
        if (count($this->groups) > 0) {
105
            return false;
106
        }
107
108
        $this->closed = true;
109
110
        foreach ($this->runtimes as $hash => $runtime) {
111
            $this->closeRuntime($hash);
112
        }
113
114
        return true;
115
    }
116
117
    public function kill(): bool
118
    {
119
        if (count($this->groups) > 0) {
120
            return false;
121
        }
122
123
        $this->closed = true;
124
125
        foreach ($this->runtimes as $runtime) {
126
            $runtime->kill();
127
        }
128
129
        return true;
130
    }
131
132
    /**
133
     * @return iterable<string, int>
134
     */
135
    public function info(): iterable
136
    {
137
        yield Info::TOTAL => count($this->runtimes);
138
        yield Info::BUSY => count($this->runtimes) - count($this->idleRuntimes);
139
        yield Info::CALLS => 0;
140
        yield Info::IDLE  => count($this->idleRuntimes);
141
        yield Info::SIZE  => count($this->runtimes);
142
    }
143
144
    public function acquireGroup(): GroupInterface
145
    {
146
        $group                         = Group::create();
147
        $this->groups[(string) $group] = $group;
148
149
        return $group;
150
    }
151
152
    public function releaseGroup(GroupInterface $group): void
153
    {
154
        unset($this->groups[(string) $group]);
155
    }
156
157
    private function getIdleRuntime(): Runtime
158
    {
159
        $hash = array_pop($this->idleRuntimes);
160
        assert(is_string($hash));
161
162
        if (array_key_exists($hash, $this->ttlTimers)) {
163
            $this->loop->cancelTimer($this->ttlTimers[$hash]);
164
            unset($this->ttlTimers[$hash]);
165
        }
166
167
        return $this->runtimes[$hash];
168
    }
169
170
    private function addRuntimeToIdleList(Runtime $runtime): void
171
    {
172
        $hash                      = spl_object_hash($runtime);
173
        $this->idleRuntimes[$hash] = $hash;
174
    }
175
176
    private function spawnRuntime(): Runtime
177
    {
178
        $runtime                                   = new Runtime($this->eventLoopBridge, $this->autoload);
179
        $this->runtimes[spl_object_hash($runtime)] = $runtime;
180
181
        return $runtime;
182
    }
183
184
    private function startTtlTimer(Runtime $runtime): void
185
    {
186
        $hash = spl_object_hash($runtime);
187
188
        $this->ttlTimers[$hash] = $this->loop->addTimer($this->ttl, function () use ($hash): void {
189
            $this->closeRuntime($hash);
190
        });
191
    }
192
193
    private function closeRuntime(string $hash): void
194
    {
195
        $runtime = $this->runtimes[$hash];
196
        $runtime->close();
197
198
        unset($this->runtimes[$hash]);
199
200
        if (array_key_exists($hash, $this->idleRuntimes)) {
201
            unset($this->idleRuntimes[$hash]);
202
        }
203
204
        if (! array_key_exists($hash, $this->ttlTimers)) {
205
            return;
206
        }
207
208
        $this->loop->cancelTimer($this->ttlTimers[$hash]);
209
210
        unset($this->ttlTimers[$hash]);
211
    }
212
}
213