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 | * @package: chapi |
||
4 | * |
||
5 | * @author: msiebeneicher |
||
6 | * @since: 2015-07-29 |
||
7 | * |
||
8 | */ |
||
9 | |||
10 | namespace Chapi\Entity\Chronos; |
||
11 | |||
12 | use Chapi\Entity\Chronos\JobEntity\ContainerEntity; |
||
13 | use Chapi\Entity\Chronos\JobEntity\FetchEntity; |
||
14 | use Chapi\Entity\JobEntityInterface; |
||
15 | |||
16 | class ChronosJobEntity implements JobEntityInterface |
||
17 | { |
||
18 | public $name = ''; |
||
19 | |||
20 | public $command = ''; |
||
21 | |||
22 | public $description = ''; |
||
23 | |||
24 | public $owner = ''; |
||
25 | |||
26 | public $ownerName = ''; |
||
27 | |||
28 | public $schedule = ''; // todo: move to separate entity |
||
29 | |||
30 | public $scheduleTimeZone = ''; |
||
31 | |||
32 | public $parents = []; // todo: move to separate entity |
||
33 | |||
34 | public $epsilon = ''; |
||
35 | |||
36 | public $executor = ''; |
||
37 | |||
38 | public $executorFlags = ''; |
||
39 | |||
40 | public $shell = true; |
||
41 | |||
42 | public $retries = 0; |
||
43 | |||
44 | public $async = false; |
||
45 | |||
46 | public $successCount = 0; |
||
47 | |||
48 | public $errorCount = 0; |
||
49 | |||
50 | public $errorsSinceLastSuccess = 0; |
||
51 | |||
52 | public $lastSuccess = ''; |
||
53 | |||
54 | public $lastError = ''; |
||
55 | |||
56 | public $cpus = 0.1; |
||
57 | |||
58 | public $disk = 24; |
||
59 | |||
60 | public $mem = 32; |
||
61 | |||
62 | public $disabled = false; |
||
63 | |||
64 | public $softError = false; |
||
65 | |||
66 | public $dataProcessingJobType = false; |
||
67 | |||
68 | /** @var FetchEntity[] */ |
||
69 | public $fetch = []; |
||
70 | |||
71 | public $environmentVariables = []; |
||
72 | |||
73 | public $arguments = []; |
||
74 | |||
75 | public $highPriority = false; |
||
76 | |||
77 | public $runAsUser = 'root'; |
||
78 | |||
79 | public $constraints = []; |
||
80 | |||
81 | /** @var ContainerEntity */ |
||
82 | public $container = null; |
||
83 | |||
84 | |||
85 | /** |
||
86 | * @param array|object $jobData |
||
87 | * @throws \InvalidArgumentException |
||
88 | */ |
||
89 | 117 | public function __construct($jobData = []) |
|
90 | { |
||
91 | 117 | if (is_array($jobData) || is_object($jobData)) { |
|
92 | 116 | foreach ($jobData as $key => $value) { |
|
93 | 18 | if (property_exists($this, $key)) { |
|
94 | 18 | if ($key == 'container') { |
|
95 | 2 | $this->{$key} = new ContainerEntity($value); |
|
96 | 18 | } else if ($key == 'fetch') { |
|
97 | 6 | foreach ($value as $fetch) { |
|
98 | 6 | $this->{$key}[] = new FetchEntity($fetch); |
|
99 | } |
||
100 | } else { |
||
101 | 18 | $this->{$key} = $value; |
|
102 | } |
||
103 | 116 | } else { |
|
0 ignored issues
–
show
|
|||
104 | /* We are ignoring fields that are unknown to us. This is bad and can lead to unexpected differences |
||
105 | * when comparing the *.json on disk with the job definition from the Chronos API. |
||
106 | */ |
||
107 | } |
||
108 | } |
||
109 | } else { |
||
110 | 1 | throw new \InvalidArgumentException(sprintf('Argument 1 passed to "%s" must be an array or object', __METHOD__)); |
|
111 | } |
||
112 | 115 | } |
|
113 | |||
114 | /** |
||
115 | * return entity as one-dimensional array |
||
116 | * |
||
117 | * @return mixed[] |
||
118 | */ |
||
119 | 8 | public function getSimpleArrayCopy() |
|
120 | { |
||
121 | 8 | $return = []; |
|
122 | |||
123 | 8 | foreach ($this as $property => $value) { |
|
124 | 8 | $return[$property] = (is_array($value) || is_object($value)) ? json_encode($value) : $value; |
|
125 | } |
||
126 | |||
127 | 8 | return $return; |
|
128 | } |
||
129 | |||
130 | /** |
||
131 | * @return bool |
||
132 | */ |
||
133 | 18 | public function isSchedulingJob() |
|
134 | { |
||
135 | 18 | return (!empty($this->schedule) && empty($this->parents)); |
|
136 | } |
||
137 | |||
138 | /** |
||
139 | * @return bool |
||
140 | */ |
||
141 | 7 | public function isDependencyJob() |
|
142 | { |
||
143 | 7 | return (empty($this->schedule) && !empty($this->parents)); |
|
144 | } |
||
145 | |||
146 | /** |
||
147 | * @return array |
||
148 | */ |
||
149 | 11 | public function jsonSerialize() |
|
150 | { |
||
151 | 11 | $return = (array) $this; |
|
152 | 11 | if (!empty($this->schedule)) { |
|
153 | 10 | unset($return['parents']); |
|
154 | } else { |
||
155 | 1 | unset($return['schedule']); |
|
156 | 1 | unset($return['scheduleTimeZone']); |
|
157 | } |
||
158 | |||
159 | 11 | if (empty($this->container)) { |
|
160 | 11 | unset($return['container']); |
|
161 | } else { |
||
162 | $return['container'] = (array) $this->container; |
||
163 | |||
164 | $return['container']['volumes'] = []; |
||
165 | foreach ($this->container->volumes as $volume) { |
||
166 | $return['container']['volumes'][] = (array) $volume; |
||
167 | } |
||
168 | } |
||
169 | |||
170 | 11 | $return['fetch'] = []; |
|
171 | 11 | foreach ($this->fetch as $fetch) { |
|
172 | $return['fetch'][] = (array) $fetch; |
||
173 | } |
||
174 | |||
175 | 11 | unset($return['successCount']); |
|
176 | 11 | unset($return['errorCount']); |
|
177 | 11 | unset($return['errorsSinceLastSuccess']); |
|
178 | 11 | unset($return['lastSuccess']); |
|
179 | 11 | unset($return['lastError']); |
|
180 | |||
181 | 11 | return $return; |
|
182 | } |
||
183 | |||
184 | /** |
||
185 | * @return \ArrayIterator |
||
186 | */ |
||
187 | 9 | public function getIterator() |
|
188 | { |
||
189 | 9 | return new \ArrayIterator($this); |
|
190 | } |
||
191 | |||
192 | /** |
||
193 | * @return string |
||
194 | */ |
||
195 | 5 | public function getEntityType() |
|
196 | { |
||
197 | 5 | return JobEntityInterface::CHRONOS_TYPE; |
|
198 | } |
||
199 | |||
200 | /** |
||
201 | * @return string |
||
202 | */ |
||
203 | 41 | public function getKey() |
|
204 | { |
||
205 | 41 | return $this->name; |
|
206 | } |
||
207 | } |
||
208 |
This check looks for the
else
branches ofif
statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.These
else
branches can be removed.could be turned into
This is much more concise to read.