Issues (30)

Security Analysis    not enabled

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

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
 * @author    jan huang <[email protected]>
4
 * @copyright 2016
5
 *
6
 * @see      https://www.github.com/janhuang
7
 * @see      https://fastdlabs.com
8
 */
9
10
namespace FastD;
11
12
use FastD\ServiceProvider\SwooleServiceProvider;
13
use FastD\Servitization\Server\HTTPServer;
14
use swoole_server;
15
use Symfony\Component\Console\Input\InputInterface;
16
17
/**
18
 * Class App.
19
 */
20
class Server
21
{
22
    /**
23
     * @var Application
24
     */
25
    protected $application;
26
27
    /**
28
     * @var \FastD\Swoole\Server
29
     */
30
    protected $server;
31
32
    /**
33
     * Server constructor.
34
     *
35
     * @param Application $application
36
     */
37 1
    public function __construct(Application $application)
38
    {
39 1
        $application->register(new SwooleServiceProvider());
40
41 1
        $server = config()->get('server.class', HTTPServer::class);
42
43 1
        $this->server = $server::createServer(
44 1
            $application->getName(),
45 1
            config()->get('server.host'),
46 1
            config()->get('server.options', [])
47 1
        );
48
49 1
        $application->add('server', $this->server);
50
51 1
        $this->initListeners();
52 1
        $this->initProcesses();
53 1
    }
54
55
    /**
56
     * @return swoole_server
57
     */
58
    public function getSwoole()
59
    {
60
        return $this->server->getSwoole();
61
    }
62
63
    /**
64
     * @return Swoole\Server
65
     */
66 1
    public function bootstrap()
67
    {
68 1
        return $this->server->bootstrap();
69
    }
70
71
    /**
72
     * @return $this
73
     */
74 1
    public function initListeners()
75
    {
76 1
        $listeners = config()->get('server.listeners', []);
77 1
        foreach ($listeners as $listener) {
78 1
            $this->server->listen(new $listener['class'](
79 1
                app()->getName().' ports',
80 1
                $listener['host'],
81 1
                isset($listener['options']) ? $listener['options'] : []
82 1
            ));
83 1
        }
84
85 1
        return $this;
86
    }
87
88
    /**
89
     * @return $this
90
     */
91 1
    public function initProcesses()
92
    {
93 1
        $processes = config()->get('server.processes', []);
94 1
        foreach ($processes as $process) {
95 1
            $this->server->process(new $process(app()->getName().' process'));
96 1
        }
97
98 1
        return $this;
99
    }
100
101
    /**
102
     * @return $this
103
     */
104
    public function daemon()
105
    {
106
        $this->server->daemon();
107
108
        return $this;
109
    }
110
111
    /**
112
     * @return int
113
     */
114
    public function start()
115
    {
116
        $this->bootstrap();
117
118
        return $this->server->start();
119
    }
120
121
    /**
122
     * @return int
123
     */
124
    public function stop()
125
    {
126
        return $this->server->shutdown();
127
    }
128
129
    /**
130
     * @return int
131
     */
132
    public function restart()
133
    {
134
        return $this->server->restart();
135
    }
136
137
    /**
138
     * @return int
139
     */
140
    public function reload()
141
    {
142
        return $this->server->reload();
143
    }
144
145
    /**
146
     * @return int
147
     */
148
    public function status()
149
    {
150
        return $this->server->status();
151
    }
152
153
    /**
154
     * @param array $dir
155
     *
156
     * @return int
157
     */
158
    public function watch(array $dir = ['.'])
159
    {
160
        return $this->server->watch($dir);
161
    }
162
163
    /**
164
     * @param InputInterface $input
165
     */
166
    public function run(InputInterface $input)
167
    {
168
        if ($input->hasParameterOption(['--daemon', '-d'], true)) {
0 ignored issues
show
The call to InputInterface::hasParameterOption() has too many arguments starting with true.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
169
            $this->daemon();
170
        }
171
172
        switch ($input->getArgument('action')) {
173
            case 'start':
174
                if ($input->hasParameterOption(['--dir'])) {
175
                    $this->watch([$input->getOption('dir')]);
176
                } else {
177
                    $this->start();
178
                }
179
180
                break;
181
            case 'stop':
182
                $this->stop();
183
184
                break;
185
            case 'reload':
186
                $this->reload();
187
188
                break;
189
            case 'status':
190
            default:
191
                $this->status();
192
        }
193
    }
194
}
195