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 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace PCextreme\Cloudstack\Util; |
||
6 | |||
7 | use InvalidArgumentException; |
||
8 | use PCextreme\Cloudstack\Exception\ClientException; |
||
9 | |||
10 | trait UrlHelpersTrait |
||
11 | { |
||
12 | /** |
||
13 | * Generate Client URL for specified username. |
||
14 | * |
||
15 | * @param string $username |
||
16 | * @param string $domainId |
||
17 | * @return string |
||
18 | * @throws InvalidArgumentException |
||
19 | */ |
||
20 | public function clientUrl(string $username, string $domainId) : string |
||
21 | { |
||
22 | if (is_null($this->urlClient)) { |
||
0 ignored issues
–
show
|
|||
23 | throw new InvalidArgumentException( |
||
24 | 'Required options not defined: urlClient' |
||
25 | ); |
||
26 | } |
||
27 | |||
28 | // Prepare session. |
||
29 | // Using the SSO (Single Sign On) key we can generate a sessionkey used for the console url. |
||
30 | $command = 'login'; |
||
31 | $params = [ |
||
32 | 'command' => $command, |
||
33 | 'username' => $username, |
||
34 | 'domainid' => $domainId, |
||
35 | 'timestamp' => round(microtime(true) * 1000), |
||
36 | 'response' => 'json', |
||
37 | ]; |
||
38 | |||
39 | $method = $this->getCommandMethod($command); |
||
0 ignored issues
–
show
It seems like
getCommandMethod() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the ![]() $method is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
40 | $query = $this->enableSso()->getCommandQuery($params); |
||
0 ignored issues
–
show
It seems like
enableSso() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the ![]() |
|||
41 | |||
42 | return $this->urlClient.'?loginUrl='.urlencode($query); |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * Generate Console URL for specified username owning the virtual machine. |
||
47 | * |
||
48 | * @param string $username |
||
49 | * @param string $domainId |
||
50 | * @param string $virtualMachineId |
||
51 | * @return string |
||
52 | * @throws InvalidArgumentException |
||
53 | */ |
||
54 | public function consoleUrl(string $username, string $domainId, string $virtualMachineId) : string |
||
55 | { |
||
56 | if (is_null($this->urlConsole)) { |
||
0 ignored issues
–
show
The property
urlConsole does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
![]() |
|||
57 | throw new InvalidArgumentException( |
||
58 | 'Required options not defined: urlConsole' |
||
59 | ); |
||
60 | } |
||
61 | |||
62 | // Prepare session. |
||
63 | // Using the SSO (Single Sign On) key we can generate a sessionkey used for the console url. |
||
64 | $command = 'login'; |
||
65 | $params = [ |
||
66 | 'command' => $command, |
||
67 | 'username' => $username, |
||
68 | 'domainid' => $domainId, |
||
69 | 'timestamp' => round(microtime(true) * 1000), |
||
70 | 'response' => 'json', |
||
71 | ]; |
||
72 | |||
73 | $base = $this->urlApi; |
||
0 ignored issues
–
show
The property
urlApi does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
![]() |
|||
74 | $method = $this->getCommandMethod($command); |
||
0 ignored issues
–
show
It seems like
getCommandMethod() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the ![]() |
|||
75 | $query = $this->enableSso()->getCommandQuery($params); |
||
0 ignored issues
–
show
It seems like
enableSso() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the ![]() |
|||
76 | $url = $this->appendQuery($base, $query); |
||
0 ignored issues
–
show
It seems like
appendQuery() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the ![]() |
|||
77 | $request = $this->getRequest($method, $url); |
||
0 ignored issues
–
show
It seems like
getRequest() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the ![]() |
|||
78 | |||
79 | $login = $this->getResponse($request); |
||
0 ignored issues
–
show
It seems like
getResponse() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the ![]() |
|||
80 | |||
81 | // Prepare a signed request for the Console url. |
||
82 | // Effectively this will be the console url, it won't be requested at the Cloudstack API. |
||
83 | $params = [ |
||
84 | 'cmd' => 'access', |
||
85 | 'vm' => $virtualMachineId, |
||
86 | 'userid' => $login['loginresponse']['userid'], |
||
87 | 'sessionkey' => $login['loginresponse']['sessionkey'], |
||
88 | 'timestamp' => round(microtime(true) * 1000), |
||
89 | 'apikey' => $this->apiKey, |
||
0 ignored issues
–
show
The property
apiKey does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
![]() |
|||
90 | ]; |
||
91 | |||
92 | $base = $this->urlConsole; |
||
93 | $query = $this->getCommandQuery($params); |
||
0 ignored issues
–
show
It seems like
getCommandQuery() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the ![]() |
|||
94 | |||
95 | return $this->appendQuery($base, $query); |
||
0 ignored issues
–
show
It seems like
appendQuery() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the ![]() |
|||
96 | } |
||
97 | } |
||
98 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: