Issues (21)

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/Identification.php (2 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
 * Identification Validation
4
 *
5
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
8
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
9
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
10
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
11
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
12
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
13
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
14
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
15
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16
 *
17
 * This software consists of voluntary contributions made by many individuals
18
 * and is licensed under the MIT license.
19
 *
20
 * @author    Jacques Marneweck <[email protected]>
21
 * @copyright 2015-2016 Jacques Marneweck.  All rights strictly reserved.
22
 * @license   MIT
23
 */
24
25
namespace Jacques\Validators;
26
27
use Carbon\Carbon;
28
29
class Identification
30
{
31
    /**
32
     * Checks that a identification number is theoretically valid.  It does not
33
     * validate that the identification number actually belongs to a human.
34
     *
35
     * id_type is either:
36
     *   - 1 - South African Identification Number
37
     *   - 2 - Passport
38
     *   - 3 - South African Asylum Document Number
39
     *
40
     * @param string  $id_document_number Document Number of the document
41
     * @param integer $id_type Identification Document Type
42
     *
43
     * @throws \InvalidArgumentException
44
     *
45
     * @return bool   true if is theoretically valid else false
46
     */
47
    public static function is_valid($id_document_number = null, $id_type = null)
48
    {
49
        if (is_null($id_document_number)) {
50
            throw new \InvalidArgumentException('Please enter a valid id document number.');
51
        }
52
53
        if (is_null($id_type)) {
54
            throw new \InvalidArgumentException('Please pass in a valid id type for the id document number you are testing.');
55
        }
56
57
        if (!is_numeric($id_type)) {
58
            throw new \InvalidArgumentException('Please pass in a numeric value for the id type wanting to be tested.');
59
        }
60
61
        $id_type = (int)$id_type;
62
63
        if ($id_type < 1 || $id_type > 3) {
64
            throw new \InvalidArgumentException('Please enter a numeric value for the id type.  1 == ZA ID / 2 == Passport / 3 == ZA Asylum');
65
        }
66
67
        if (1 == $id_type) {
68
            if (!ctype_digit($id_document_number)) {
69
                return false;
70
            }
71
72
            $idvalid = \PayBreak\Luhn\Luhn::validateNumber($id_document_number);
73
74
            return ($idvalid);
75
        }
76
77
        /**
78
         * Passport numbers are either like MA123456 or 12345678.
79
         */
80 View Code Duplication
        if (2 == $id_type) {
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...
81
            if (mb_strlen($id_document_number) < 8) {
82
                return false;
83
            }
84
85
            return true;
86
        }
87
88
        /**
89
         * South African Asylum Document Numbers
90
         */
91 View Code Duplication
        if (3 == $id_type) {
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...
92
            if (mb_strlen($id_document_number) < 8) {
93
                return false;
94
            }
95
96
            return true;
97
        }
98
        return false;
99
    }
100
}
101