Issues (21)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/Support/DelegatedValidator.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

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
It seems like $rules defined by parameter $rules on line 175 can also be of type string; however, Proengsoft\JsValidation\...erProxy::explodeRules() does only seem to accept array, maybe add an additional type check?

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.

Loading history...
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