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 | /** |
||
4 | * This aims to be a simple controller that only kicks off the rendering on the react |
||
5 | * components. It passes a model to the frontend with URLS to dispatchers that takes |
||
6 | * care of various actions, like git fetching, planning, approvals and so on. |
||
7 | */ |
||
8 | class EnvironmentOverview extends Dispatcher { |
||
0 ignored issues
–
show
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.
You can fix this by adding a namespace to your class: namespace YourVendor;
class YourClass { }
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries. ![]() The property $allowed_actions is not named in camelCase.
This check marks property names that have not been written in camelCase. In camelCase names are written without any punctuation, the start of each new word being marked
by a capital letter. Thus the name database connection string becomes ![]() |
|||
9 | |||
10 | const ACTION_OVERVIEW = 'overview'; |
||
11 | |||
12 | /** |
||
13 | * @var array |
||
14 | */ |
||
15 | private static $action_types = [ |
||
0 ignored issues
–
show
|
|||
16 | self::ACTION_OVERVIEW |
||
17 | ]; |
||
18 | |||
19 | /** |
||
20 | * The "deployment" action here should only go to index, it gets used by |
||
21 | * the frontend routing. |
||
22 | */ |
||
23 | private static $allowed_actions = [ |
||
0 ignored issues
–
show
|
|||
24 | 'deployment' |
||
25 | ]; |
||
26 | |||
27 | public function init() { |
||
28 | parent::init(); |
||
29 | $this->project = $this->getCurrentProject(); |
||
0 ignored issues
–
show
The property
project does not seem to exist. Did you mean _project_cache ?
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. ![]() |
|||
30 | if (!$this->project) { |
||
0 ignored issues
–
show
The property
project does not seem to exist. Did you mean _project_cache ?
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. ![]() |
|||
31 | return $this->project404Response(); |
||
32 | } |
||
33 | // Performs canView permission check by limiting visible projects |
||
34 | $this->environment = $this->getCurrentEnvironment($this->project); |
||
0 ignored issues
–
show
The property
environment does not exist on object<EnvironmentOverview> . 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. ![]() The property
project does not seem to exist. Did you mean _project_cache ?
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. ![]() |
|||
35 | } |
||
36 | |||
37 | /** |
||
38 | * |
||
39 | * @param \SS_HTTPRequest $request |
||
40 | * |
||
41 | * @return \HTMLText|\SS_HTTPResponse |
||
42 | */ |
||
43 | public function index(\SS_HTTPRequest $request) { |
||
44 | if (!$this->environment) { |
||
0 ignored issues
–
show
The property
environment does not exist on object<EnvironmentOverview> . 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. ![]() |
|||
45 | return $this->environment404Response(); |
||
46 | } |
||
47 | |||
48 | $this->setCurrentActionType(self::ACTION_OVERVIEW); |
||
49 | |||
50 | return $this->customise([ |
||
51 | 'Environment' => $this->environment |
||
0 ignored issues
–
show
The property
environment does not exist on object<EnvironmentOverview> . 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. ![]() |
|||
52 | ])->renderWith(['EnvironmentOverview', 'DNRoot']); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @return string |
||
57 | */ |
||
58 | public function Link() { |
||
59 | return $this->environment->Link(); |
||
0 ignored issues
–
show
The property
environment does not exist on object<EnvironmentOverview> . 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. ![]() |
|||
60 | } |
||
61 | |||
62 | /** |
||
63 | * The model includes the CSRF tokens and the various API |
||
64 | * endpoints that the front end might be interested in. |
||
65 | * |
||
66 | * @param string $name |
||
67 | * |
||
68 | * @return array |
||
69 | */ |
||
70 | public function getModel($name = '') { |
||
71 | $approversList = []; |
||
72 | |||
73 | // virtual stacks have a special case in that they need to look at the base project |
||
74 | // due to the team setup being on the base. |
||
75 | if ($this->getCurrentProject() instanceof VirtualProject) { |
||
0 ignored issues
–
show
The class
VirtualProject does not exist. Did you forget a USE statement, or did you not list all dependencies?
This error could be the result of: 1. Missing dependenciesPHP Analyzer uses your Are you sure this class is defined by one of your dependencies, or did you maybe
not list a dependency in either the 2. Missing use statementPHP does not complain about undefined classes in if ($x instanceof DoesNotExist) {
// Do something.
}
If you have not tested against this specific condition, such errors might go unnoticed. ![]() |
|||
76 | $baseProject = $this->getCurrentProject()->BaseProject(); |
||
77 | } else { |
||
78 | $baseProject = $this->getCurrentProject(); |
||
79 | } |
||
80 | |||
81 | foreach ($baseProject->listMembers() as $data) { |
||
82 | if ($baseProject->allowed(\ApprovalsDispatcher::ALLOW_APPROVAL, \Member::get()->byId($data['MemberID']))) { |
||
83 | $approversList[$data['MemberID']] = [ |
||
84 | 'id' => $data['MemberID'], |
||
85 | 'email' => $data['Email'], |
||
86 | 'role' => $data['RoleTitle'], |
||
87 | 'name' => $data['FullName'] |
||
88 | ]; |
||
89 | } |
||
90 | } |
||
91 | |||
92 | $base = Director::absoluteBaseURL(); |
||
93 | return [ |
||
94 | 'basename' => Director::baseURL() . $this->getCurrentEnvironment()->Link(self::ACTION_OVERVIEW), |
||
95 | 'dispatchers' => [ |
||
96 | 'git' => $base . $this->getCurrentProject()->Link('git'), |
||
97 | 'deploys' => $base . $this->getCurrentEnvironment()->Link('deploys'), |
||
98 | 'approvals' => $base . $this->getCurrentEnvironment()->Link('approvals') |
||
99 | ], |
||
100 | 'api_auth' => [ |
||
101 | 'name' => $this->getSecurityToken()->getName(), |
||
102 | 'value' => $this->getSecurityToken()->getValue() |
||
103 | ], |
||
104 | 'environment' => [ |
||
105 | 'id' => $this->environment->ID, |
||
0 ignored issues
–
show
The property
environment does not exist on object<EnvironmentOverview> . 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. ![]() |
|||
106 | 'name' => $this->environment->Name, |
||
0 ignored issues
–
show
The property
environment does not exist on object<EnvironmentOverview> . 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. ![]() |
|||
107 | 'project_name' => $this->getCurrentProject()->Name, |
||
108 | 'usage' => $this->environment->Usage, |
||
0 ignored issues
–
show
The property
environment does not exist on object<EnvironmentOverview> . 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. ![]() |
|||
109 | 'supported_options' => $this->environment->getSupportedOptions()->map('name', 'defaultValue'), |
||
0 ignored issues
–
show
The property
environment does not exist on object<EnvironmentOverview> . 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. ![]() |
|||
110 | 'approvers' => $approversList |
||
111 | ], |
||
112 | 'user' => [ |
||
113 | 'can_approve' => \ApprovalsDispatcher::can_approve($this->getCurrentEnvironment()), |
||
0 ignored issues
–
show
It seems like
$this->getCurrentEnvironment() can be null ; however, can_approve() does not accept null , maybe add an additional type check?
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: /** @return stdClass|null */
function mayReturnNull() { }
function doesNotAcceptNull(stdClass $x) { }
// With potential error.
function withoutCheck() {
$x = mayReturnNull();
doesNotAcceptNull($x); // Potential error here.
}
// Safe - Alternative 1
function withCheck1() {
$x = mayReturnNull();
if ( ! $x instanceof stdClass) {
throw new \LogicException('$x must be defined.');
}
doesNotAcceptNull($x);
}
// Safe - Alternative 2
function withCheck2() {
$x = mayReturnNull();
if ($x instanceof stdClass) {
doesNotAcceptNull($x);
}
}
![]() |
|||
114 | 'can_bypass_approval' => \ApprovalsDispatcher::can_bypass_approval($this->getCurrentEnvironment()), |
||
0 ignored issues
–
show
It seems like
$this->getCurrentEnvironment() can be null ; however, can_bypass_approval() does not accept null , maybe add an additional type check?
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: /** @return stdClass|null */
function mayReturnNull() { }
function doesNotAcceptNull(stdClass $x) { }
// With potential error.
function withoutCheck() {
$x = mayReturnNull();
doesNotAcceptNull($x); // Potential error here.
}
// Safe - Alternative 1
function withCheck1() {
$x = mayReturnNull();
if ( ! $x instanceof stdClass) {
throw new \LogicException('$x must be defined.');
}
doesNotAcceptNull($x);
}
// Safe - Alternative 2
function withCheck2() {
$x = mayReturnNull();
if ($x instanceof stdClass) {
doesNotAcceptNull($x);
}
}
![]() |
|||
115 | 'can_abort_deployment' => \DeployDispatcher::can_abort_deployment($this->getCurrentEnvironment()) |
||
0 ignored issues
–
show
It seems like
$this->getCurrentEnvironment() can be null ; however, can_abort_deployment() does not accept null , maybe add an additional type check?
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: /** @return stdClass|null */
function mayReturnNull() { }
function doesNotAcceptNull(stdClass $x) { }
// With potential error.
function withoutCheck() {
$x = mayReturnNull();
doesNotAcceptNull($x); // Potential error here.
}
// Safe - Alternative 1
function withCheck1() {
$x = mayReturnNull();
if ( ! $x instanceof stdClass) {
throw new \LogicException('$x must be defined.');
}
doesNotAcceptNull($x);
}
// Safe - Alternative 2
function withCheck2() {
$x = mayReturnNull();
if ($x instanceof stdClass) {
doesNotAcceptNull($x);
}
}
![]() |
|||
116 | ] |
||
117 | ]; |
||
118 | } |
||
119 | |||
120 | } |
||
121 |
This check marks property names that have not been written in camelCase.
In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes
databaseConnectionString
.