Issues (4)

Security Analysis    no request data  

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/Validate.php (3 issues)

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
 * Jaeger
4
 *
5
 * @copyright	Copyright (c) 2015-2016, mithra62
6
 * @link		http://jaeger-app.com
7
 * @version		1.0
8
 * @filesource 	./Validate.php
9
 */
10
namespace JaegerApp;
11
12
use Valitron\Validator;
13
use JaegerApp\Exceptions\ValidateException;
14
15
/**
16
 * mithra62 - Validation Object
17
 *
18
 * Object to manage system settings
19
 *
20
 * @package Validate
21
 * @author Eric Lamb <[email protected]>
22
 */
23
class Validate extends Validator
24
{
25
26
    /**
27
     * The regex engine
28
     * 
29
     * @var \mithra62\Regex
30
     */
31
    protected $regex = null;
32
33
    /**
34
     * Overrides the initial validation constructor
35
     * 
36
     * @throws \InvalidArgumentException
37
     */
38
    public function __construct()
39
    {
40
        $langDir = static::langDir();
41
        
42
        $lang = static::lang();
43
        // Load language file in directory
44
        $langFile = rtrim($langDir, '/') . '/' . $lang . '.php';
45
        if (stream_resolve_include_path($langFile)) {
46
            $langMessages = include $langFile;
47
            static::$_ruleMessages = array_merge(static::$_ruleMessages, $langMessages);
48
        } else {
49
            throw new \InvalidArgumentException("fail to load language file '$langFile'");
50
        }
51
        
52
        $this->loadRules();
53
    }
54
55
    /**
56
     * Adds all the custom rules
57
     * 
58
     * @throws ValidateException
59
     */
60
    protected function loadRules()
61
    {
62
        $old_cwd = getcwd();
63
        chdir(__DIR__);
64
        $path = 'Validate' . DIRECTORY_SEPARATOR . 'Rules';
65
        if (! is_dir($path)) {
66
            throw new ValidateException("Rules Directory " . $path . " isn't a directory...");
67
        }
68
        
69
        $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::LEAVES_ONLY);
70
        
71
        foreach ($files as $file) {
72
            if (! $file->isDir()) {
73
                $name = '\\JaegerApp\\' . str_replace('/', '\\', str_replace('.php', '', $file->getPathname()));
74
                $class = $name;
75
                if (class_exists($class)) {
76
                    $rule = new $class();
77
                    if ($rule instanceof Validate\RuleInterface) {
78
                        self::addRule($rule->getName(), array(
79
                            $rule,
80
                            'validate'
81
                        ), $rule->getErrorMessage());
0 ignored issues
show
$rule->getErrorMessage() is of type array, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
82
                    }
83
                }
84
            }
85
        }
86
        
87
        chdir($old_cwd);
88
    }
89
90
    /**
91
     * Processes the validation group
92
     * 
93
     * @param array $data            
94
     * @return \Valitron\boolean
95
     */
96
    public function val(array $data)
97
    {
98
        $this->_fields = $data;
99
        $labels = array();
100
        foreach ($data as $key => $value) {
101
            $labels[$key] = ucwords(str_replace('_', ' ', $key));
102
        }
103
        
104
        $this->labels($labels);
105
        
106
        return parent::validate();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (validate() instead of val()). Are you sure this is correct? If so, you might want to change this to $this->validate().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
107
    }
108
109
    /**
110
     * Checks if there are errors and returns a boolean
111
     * 
112
     * @return boolean
113
     */
114
    public function hasErrors()
115
    {
116
        if (count($this->errors()) != '0') {
117
            return true;
118
        }
119
        
120
        return false;
121
    }
122
123
    /**
124
     * Returns the error messages
125
     * 
126
     * @return Ambigous <\Valitron\array, \Valitron\bool>
127
     */
128
    public function getErrorMessages()
129
    {
130
        return $this->errors();
131
    }
132
133
    /**
134
     * Returns an array of all the custom rules
135
     * 
136
     * @return array
137
     */
138
    public function getCustomRules()
139
    {
140
        return static::$_rules;
141
    }
142
143
    /**
144
     * Sets the regular expression engine
145
     * 
146
     * @param \mithra62\Regex $regex            
147
     * @return \mithra62\Validate
148
     */
149
    public function setRegex(\JaegerApp\Regex $regex)
150
    {
151
        $this->regex = $regex;
0 ignored issues
show
Documentation Bug introduced by
It seems like $regex of type object<JaegerApp\Regex> is incompatible with the declared type object<mithra62\Regex> of property $regex.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
152
        return $this;
153
    }
154
    
155
    public function getRegex()
156
    {
157
        return $this->regex;
158
    }
159
}