Issues (1)

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/Phone.php (1 issue)

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
namespace LVR\Phone;
3
4
use Illuminate\Contracts\Validation\Rule;
5
6
class Phone implements Rule
7
{
8
    /**
9
     * Determine if the validation rule passes.
10
     *
11
     * @param  string $attribute
12
     * @param  mixed  $value
13
     *
14
     * @return bool
15
     */
16 6
    public function passes($attribute, $value)
17
    {
18 6
        return $this->isPhone($value);
19
    }
20
21
    /**
22
     * Get the validation error message.
23
     *
24
     * @return string
25
     */
26 3
    public function message()
27
    {
28 3
        return 'Incorrect phone format for :attribute.';
29
    }
30
31
    /**
32
     * Checks through all validation methods to verify it is in a
33
     * phone number format of some type
34
     * @param  string  $value The phone number to check
35
     * @return boolean        is it correct format?
36
     */
37 6
    protected function isPhone($value)
38
    {
39 6
        return $this->isE123($value) || $this->isE164($value) || $this->isNANP($value) || $this->isDigits($value);
40
    }
41
42
    /**
43
     * Format example 5555555555, 15555555555
44
     * @param  [type]  $value [description]
0 ignored issues
show
The doc-type [type] could not be parsed: Unknown type name "" at position 0. [(view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
45
     * @return boolean        [description]
46
     */
47 6
    protected function isDigits($value)
48
    {
49 6
        $conditions = [];
50 6
        $conditions[] = strlen($value) >= 10;
51 6
        $conditions[] = strlen($value) <= 16;
52 6
        $conditions[] = preg_match("/[^\d]/i", $value) === 0;
53 6
        return (bool) array_product($conditions);
54
    }
55
56
    /**
57
     * Format example +22 555 555 1234, (607) 555 1234, (022607) 555 1234
58
     * @param $value
59
     * @return bool
60
     */
61 9
    protected function isE123($value)
62
    {
63 9
        return preg_match('/^(?:\((\+?\d+)?\)|\+?\d+) ?\d*(-?\d{2,3} ?){0,4}$/', $value) === 1;
64
    }
65
66
    /**
67
     * Format example +15555555555
68
     * @param  string  $value The phone number to check
69
     * @return boolean        is it correct format?
70
     */
71 6
    protected function isE164($value)
72
    {
73 6
        $conditions = [];
74 6
        $conditions[] = strpos($value, "+") === 0;
75 6
        $conditions[] = strlen($value) >= 9;
76 6
        $conditions[] = strlen($value) <= 16;
77 6
        $conditions[] = preg_match("/[^\d+]/i", $value) === 0;
78 6
        return (bool) array_product($conditions);
79
    }
80
81
    /**
82
     * Format examples: (555) 555-5555, 1 (555) 555-5555, 1-555-555-5555, 555-555-5555, 1 555 555-5555
83
     * https://en.wikipedia.org/wiki/National_conventions_for_writing_telephone_numbers#United_States.2C_Canada.2C_and_other_NANP_countries
84
     * @param  string  $value The phone number to check
85
     * @return boolean        is it correct format?
86
     */
87 6
    protected function isNANP($value)
88
    {
89 6
        $conditions = [];
90 6
        $conditions[] = preg_match("/^(?:\+1|1)?\s?-?\(?\d{3}\)?(\s|-)?\d{3}-\d{4}$/i", $value) > 0;
91 6
        return (bool) array_product($conditions);
92
    }
93
}