Issues (1752)

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/Fwlib/Validator/Constraint/Email.php (1 issue)

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
namespace Fwlib\Validator\Constraint;
3
4
use Fwlib\Util\UtilContainerAwareTrait;
5
use Fwlib\Validator\AbstractConstraint;
6
7
/**
8
 * Constraint Email
9
 *
10
 * @copyright   Copyright 2013-2015 Fwolf
11
 * @license     http://www.gnu.org/licenses/lgpl.html LGPL-3.0+
12
 */
13
class Email extends AbstractConstraint
14
{
15
    use UtilContainerAwareTrait;
16
17
18
    /**
19
     * Check email domain through dns
20
     *
21
     * @var bool
22
     */
23
    protected $dnsCheck = false;
24
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    protected $messageTemplates = [
30
        'default'   => 'The input should be valid email address'
31
    ];
32
33
34
    /**
35
     * {@inheritdoc}
36
     *
37
     * @link http://www.linuxjournal.com/article/9585
38
     */
39
    protected function doValidate($value)
40
    {
41
        $atIndex = strrpos($value, '@');
42
        if (false === $atIndex) {
43
            return false;
44
        }
45
46
        $domain = substr($value, $atIndex + 1);
47
        $local = substr($value, 0, $atIndex);
48
49
        $valid = $this->validateDomainPart($domain) &&
50
            $this->validateLocalPart($local);
51
52
        // Some network provider will return fake A record if a dns query
53
        // return fail, usually display some ads, so we only check MX record.
54
        if ($valid && $this->dnsCheck &&
55
            $this->getUtilContainer()->getEnv()->isNixOs() &&
56
            !checkdnsrr($domain, 'MX')
57
        ) {
58
            $valid = false;
59
        }
60
61
        if (!$valid) {
62
            $this->setMessage('default');
63
        }
64
65
        return $valid;
66
    }
67
68
69
    /**
70
     * Setter of $dnsCheck
71
     *
72
     * @param   boolean $dnsCheck
73
     * @return  static
74
     */
75
    public function setDnsCheck($dnsCheck)
76
    {
77
        $this->dnsCheck = $dnsCheck;
78
79
        return $this;
80
    }
81
82
83
    /**
84
     * @param   string  $domain
85
     * @return  bool
86
     */
87
    protected function validateDomainPart($domain)
88
    {
89
        $valid = true;
90
        $length = strlen($domain);
91
92
        if ($length < 1 || $length > 255) {
93
            // domain part length exceeded
94
            $valid = false;
95
96
        } elseif (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) {
97
            // character not valid in domain part
98
            $valid = false;
99
100
        } elseif (preg_match('/\\.\\./', $domain)) {
101
            // domain part has two consecutive dots
102
            $valid = false;
103
        }
104
105
        return $valid;
106
    }
107
108
109
    /**
110
     * @param   string  $local
111
     * @return  bool
112
     */
113
    protected function validateLocalPart($local)
114
    {
115
        $valid = true;
116
        $length = strlen($local);
117
118
        if ($length < 1 || $length > 64) {
119
            // local part length exceeded
120
            $valid = false;
121
122
        } elseif ($local[0] == '.' || $local[$length-1] == '.') {
123
            // local part starts or ends with '.'
124
            $valid = false;
125
126
        } elseif (preg_match('/\\.\\./', $local)) {
127
            // local part has two consecutive dots
128
            $valid = false;
129
130 View Code Duplication
        } elseif (!preg_match(
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
131
            '/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/',
132
            str_replace("\\\\", "", $local)
133
        )) {
134
            // Character not valid in local part unless local part is quoted
135
            if (!preg_match(
136
                '/^"(\\\\"|[^"])+"$/',
137
                str_replace("\\\\", "", $local)
138
            )) {
139
                $valid = false;
140
            }
141
        }
142
143
        return $valid;
144
    }
145
}
146