This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace PHPDaemon\Applications; |
||
3 | |||
4 | use PHPDaemon\HTTPRequest\Generic; |
||
5 | |||
6 | /** |
||
7 | * @property mixed stream |
||
8 | * @package Applications |
||
9 | * @subpackage CGI |
||
10 | * |
||
11 | * @author Vasily Zorin <[email protected]> |
||
12 | */ |
||
13 | class CGIRequest extends Generic |
||
14 | { |
||
15 | /** |
||
16 | * @var bool |
||
17 | */ |
||
18 | public $terminateOnAbort = false; |
||
19 | /** |
||
20 | * @var \PHPDaemon\Core\ShellCommand |
||
21 | */ |
||
22 | public $proc; |
||
23 | |||
24 | /** |
||
25 | * Constructor. |
||
26 | * @return void |
||
27 | */ |
||
28 | public function init() |
||
29 | { |
||
30 | $this->header('Content-Type: text/html'); // default header. |
||
31 | |||
32 | $this->proc = new \PHPDaemon\Core\ShellCommand(); |
||
33 | $this->proc->readPacketSize = $this->appInstance->readPacketSize; |
||
0 ignored issues
–
show
The property
readPacketSize does not exist on object<PHPDaemon\Core\AppInstance> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
34 | $this->proc->onReadData([$this, 'onReadData']); |
||
0 ignored issues
–
show
The method
onReadData does not exist on object<PHPDaemon\Core\ShellCommand> ? Since you implemented __call , maybe consider adding a @method annotation.
If you implement This is often the case, when class ParentClass {
private $data = array();
public function __call($method, array $args) {
if (0 === strpos($method, 'get')) {
return $this->data[strtolower(substr($method, 3))];
}
throw new \LogicException(sprintf('Unsupported method: %s', $method));
}
}
/**
* If this class knows which fields exist, you can specify the methods here:
*
* @method string getName()
*/
class SomeClass extends ParentClass { }
![]() |
|||
35 | $this->proc->onWrite([$this, 'onWrite']); |
||
0 ignored issues
–
show
The call to
ShellCommand::onWrite() has too many arguments starting with array($this, 'onWrite') .
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 ![]() |
|||
36 | $this->proc->binPath = $this->appInstance->binPath; |
||
0 ignored issues
–
show
The property
binPath does not exist on object<PHPDaemon\Core\AppInstance> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
37 | $this->proc->chroot = $this->appInstance->chroot; |
||
0 ignored issues
–
show
The property
chroot does not exist on object<PHPDaemon\Core\AppInstance> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
38 | |||
39 | if (isset($this->attrs->server['BINPATH'])) { |
||
40 | if (isset($this->appInstance->binAliases[$this->attrs->server['BINPATH']])) { |
||
41 | $this->proc->binPath = $this->appInstance->binAliases[$this->attrs->server['BINPATH']]; |
||
0 ignored issues
–
show
The property
binAliases does not seem to exist in PHPDaemon\Core\AppInstance .
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name. If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading. ![]() |
|||
42 | } elseif ($this->appInstance->config->allowoverridebinpath->value) { |
||
43 | $this->proc->binPath = $this->attrs->server['BINPATH']; |
||
44 | } |
||
45 | } |
||
46 | |||
47 | View Code Duplication | if (isset($this->attrs->server['CHROOT']) && $this->appInstance->config->allowoverridechroot->value) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
48 | $this->proc->chroot = $this->attrs->server['CHROOT']; |
||
49 | } |
||
50 | |||
51 | View Code Duplication | if (isset($this->attrs->server['SETUSER']) && $this->appInstance->config->allowoverrideuser->value) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
52 | $this->proc->setUser = $this->attrs->server['SETUSER']; |
||
53 | } |
||
54 | |||
55 | View Code Duplication | if (isset($this->attrs->server['SETGROUP']) && $this->appInstance->config->allowoverridegroup->value) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
56 | $this->proc->setGroup = $this->attrs->server['SETGROUP']; |
||
57 | } |
||
58 | |||
59 | if (isset($this->attrs->server['CWD']) && $this->appInstance->config->allowoverridecwd->value) { |
||
60 | $this->proc->cwd = $this->attrs->server['CWD']; |
||
61 | } elseif ($this->appInstance->config->cwd->value !== null) { |
||
62 | $this->proc->cwd = $this->appInstance->config->cwd->value; |
||
63 | } else { |
||
64 | $this->proc->cwd = dirname($this->attrs->server['SCRIPT_FILENAME']); |
||
65 | } |
||
66 | |||
67 | $this->proc->setArgs([$this->attrs->server['SCRIPT_FILENAME']]); |
||
68 | $this->proc->setEnv($this->attrs->server); |
||
69 | $this->proc->execute(); |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * Called when request iterated. |
||
74 | * @return void |
||
75 | */ |
||
76 | public function run() |
||
77 | { |
||
78 | if (!$this->proc) { |
||
79 | $this->out('Couldn\'t execute CGI proccess.'); |
||
80 | $this->finish(); |
||
81 | return; |
||
82 | } |
||
83 | if (!$this->proc->eof()) { |
||
84 | $this->sleep(); |
||
85 | } |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * Called when the request aborted. |
||
90 | * @return void |
||
91 | */ |
||
92 | public function onAbort() |
||
93 | { |
||
94 | if ($this->terminateOnAbort && $this->stream) { |
||
95 | $this->stream->close(); |
||
96 | } |
||
97 | } |
||
98 | |||
99 | /** |
||
100 | * Called when new data received from process. |
||
101 | * @param object $process Process pointer. |
||
102 | * @param string $data Data. |
||
103 | * @return void |
||
104 | */ |
||
105 | public function onReadData($process, $data) |
||
106 | { |
||
107 | $this->combinedOut($data); |
||
108 | } |
||
109 | |||
110 | /** |
||
111 | * Called when new piece of request's body is received. |
||
112 | * @param string $c Piece of request's body. |
||
113 | * @return void |
||
114 | */ |
||
115 | public function stdin($c) |
||
116 | { |
||
117 | if ($c === '') { |
||
118 | $this->onWrite($this->proc); |
||
119 | } else { |
||
120 | $this->proc->write($c); |
||
121 | } |
||
122 | } |
||
123 | |||
124 | /** |
||
125 | * Called when the request aborted. |
||
126 | * @param \PHPDaemon\Core\ShellCommand $process |
||
127 | * @return void |
||
128 | */ |
||
129 | public function onWrite($process) |
||
0 ignored issues
–
show
|
|||
130 | { |
||
131 | if ($this->attrs->stdin_done && ($this->proc->writeState === false)) { |
||
0 ignored issues
–
show
The property
writeState does not exist on object<PHPDaemon\Core\ShellCommand> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
132 | $this->proc->closeWrite(); |
||
133 | } |
||
134 | } |
||
135 | } |
||
136 |
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.