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 | namespace Proengsoft\JsValidation\Support; |
||
4 | |||
5 | use Illuminate\Validation\Validator as BaseValidator; |
||
6 | |||
7 | class DelegatedValidator |
||
8 | { |
||
9 | use AccessProtectedTrait; |
||
10 | |||
11 | /** |
||
12 | * The Validator resolved instance. |
||
13 | * |
||
14 | * @var \Illuminate\Validation\Validator |
||
15 | */ |
||
16 | protected $validator; |
||
17 | |||
18 | /** |
||
19 | * Validation rule parser instance. |
||
20 | * |
||
21 | * @var \Proengsoft\JsValidation\Support\ValidationRuleParserProxy |
||
22 | */ |
||
23 | protected $ruleParser; |
||
24 | |||
25 | /** |
||
26 | * Closure to invoke non accessible Validator methods. |
||
27 | * |
||
28 | * @var \Closure |
||
29 | */ |
||
30 | protected $validatorMethod; |
||
31 | |||
32 | /** |
||
33 | * DelegatedValidator constructor. |
||
34 | * |
||
35 | * @param \Illuminate\Validation\Validator $validator |
||
36 | * @param \Proengsoft\JsValidation\Support\ValidationRuleParserProxy $ruleParser |
||
37 | */ |
||
38 | 288 | public function __construct(BaseValidator $validator, ValidationRuleParserProxy $ruleParser) |
|
39 | { |
||
40 | 288 | $this->validator = $validator; |
|
41 | 288 | $this->ruleParser = $ruleParser; |
|
42 | 288 | $this->validatorMethod = $this->createProtectedCaller($validator); |
|
43 | 288 | } |
|
44 | |||
45 | /** |
||
46 | * Call validator method. |
||
47 | * |
||
48 | * @param string $method |
||
49 | * @param array $args |
||
50 | * @return mixed |
||
51 | */ |
||
52 | 72 | private function callValidator($method, $args = []) |
|
53 | { |
||
54 | 72 | return $this->callProtected($this->validatorMethod, $method, $args); |
|
55 | } |
||
56 | |||
57 | /** |
||
58 | * Get current \Illuminate\Validation\Validator instance. |
||
59 | * |
||
60 | * @return \Illuminate\Validation\Validator |
||
61 | */ |
||
62 | 12 | public function getValidator() |
|
63 | { |
||
64 | 12 | return $this->validator; |
|
65 | } |
||
66 | |||
67 | /** |
||
68 | * Get the data under validation. |
||
69 | * |
||
70 | * @return array |
||
71 | */ |
||
72 | 12 | public function getData() |
|
73 | { |
||
74 | 12 | return $this->validator->getData(); |
|
75 | } |
||
76 | |||
77 | /** |
||
78 | * Set the data under validation. |
||
79 | * |
||
80 | * @param array |
||
81 | */ |
||
82 | 12 | public function setData($data) |
|
83 | { |
||
84 | 12 | $rules = $this->validator->getRules(); |
|
85 | 12 | $this->validator->setData($data); |
|
86 | 12 | if (is_array($rules)) { |
|
87 | $this->validator->setRules($rules); |
||
88 | } |
||
89 | 12 | } |
|
90 | |||
91 | /** |
||
92 | * Get the validation rules. |
||
93 | * |
||
94 | * @return array |
||
95 | */ |
||
96 | 12 | public function getRules() |
|
97 | { |
||
98 | 12 | return $this->validator->getRules(); |
|
99 | } |
||
100 | |||
101 | /** |
||
102 | * Determine if a given rule implies the attribute is required. |
||
103 | * |
||
104 | * @param string $rule |
||
105 | * @return bool |
||
106 | */ |
||
107 | 12 | public function isImplicit($rule) |
|
108 | { |
||
109 | 12 | return $this->callValidator('isImplicit', [$rule]); |
|
110 | } |
||
111 | |||
112 | /** |
||
113 | * Replace all error message place-holders with actual values. |
||
114 | * |
||
115 | * @param string $message |
||
116 | * @param string $attribute |
||
117 | * @param string $rule |
||
118 | * @param array $parameters |
||
119 | * @return string |
||
120 | */ |
||
121 | 24 | public function makeReplacements($message, $attribute, $rule, $parameters) |
|
122 | { |
||
123 | 24 | if (is_object($rule)) { |
|
124 | $rule = get_class($rule); |
||
125 | } |
||
126 | |||
127 | 24 | return $this->callValidator('makeReplacements', [$message, $attribute, $rule, $parameters]); |
|
128 | } |
||
129 | |||
130 | /** |
||
131 | * Determine if the given attribute has a rule in the given set. |
||
132 | * |
||
133 | * @param string $attribute |
||
134 | * @param string|array $rules |
||
135 | * @return bool |
||
136 | */ |
||
137 | 12 | public function hasRule($attribute, $rules) |
|
138 | { |
||
139 | 12 | return $this->callValidator('hasRule', [$attribute, $rules]); |
|
140 | } |
||
141 | |||
142 | /** |
||
143 | * Get the validation message for an attribute and rule. |
||
144 | * |
||
145 | * @param string $attribute |
||
146 | * @param string $rule |
||
147 | * @return string |
||
148 | */ |
||
149 | 24 | public function getMessage($attribute, $rule) |
|
150 | { |
||
151 | 24 | if (is_object($rule)) { |
|
152 | 12 | $rule = get_class($rule); |
|
153 | } |
||
154 | |||
155 | 24 | return $this->callValidator('getMessage', [$attribute, $rule]); |
|
156 | } |
||
157 | |||
158 | /** |
||
159 | * Extract the rule name and parameters from a rule. |
||
160 | * |
||
161 | * @param array|string $rules |
||
162 | * @return array |
||
163 | */ |
||
164 | 12 | public function parseRule($rules) |
|
165 | { |
||
166 | 12 | return $this->ruleParser->parse($rules); |
|
167 | } |
||
168 | |||
169 | /** |
||
170 | * Explode the rules into an array of rules. |
||
171 | * |
||
172 | * @param string|array $rules |
||
173 | * @return array |
||
174 | */ |
||
175 | 12 | public function explodeRules($rules) |
|
176 | { |
||
177 | 12 | return $this->ruleParser->explodeRules($rules); |
|
0 ignored issues
–
show
|
|||
178 | } |
||
179 | |||
180 | /** |
||
181 | * Add conditions to a given field based on a Closure. |
||
182 | * |
||
183 | * @param string $attribute |
||
184 | * @param string|array $rules |
||
185 | * @param callable $callback |
||
186 | * @return void |
||
187 | */ |
||
188 | 12 | public function sometimes($attribute, $rules, callable $callback) |
|
189 | { |
||
190 | 12 | $this->validator->sometimes($attribute, $rules, $callback); |
|
191 | 12 | } |
|
192 | |||
193 | /** |
||
194 | * Delegate method calls to validator instance. |
||
195 | * |
||
196 | * @param $method |
||
197 | * @param $params |
||
198 | * @return mixed |
||
199 | */ |
||
200 | 60 | public function __call($method, $params) |
|
201 | { |
||
202 | 60 | $arrCaller = [$this->validator, $method]; |
|
203 | |||
204 | 60 | return call_user_func_array($arrCaller, $params); |
|
205 | } |
||
206 | } |
||
207 |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.