Issues (341)

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.

Rule/Email.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
 * Part of the Joomla Framework Form Package
4
 *
5
 * @copyright  Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
6
 * @license    GNU General Public License version 2 or later; see LICENSE
7
 */
8
9
namespace Joomla\Form\Rule;
10
11
use Joomla\Form\Rule;
12
use Joomla\Form\Form;
13
use Joomla\Registry\Registry;
14
use SimpleXMLElement;
15
16
/**
17
 * Form Rule class for the Joomla Framework.
18
 *
19
 * @since       1.0
20
 * @deprecated  The joomla/form package is deprecated
21
 */
22
class Email extends Rule
0 ignored issues
show
Deprecated Code introduced by
The class Joomla\Form\Rule has been deprecated with message: The joomla/form package is deprecated

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
23
{
24
	/**
25
	 * The regular expression to use in testing a form field value.
26
	 *
27
	 * @var    string
28
	 * @since  1.0
29
	 * @see    http://www.w3.org/TR/html-markup/input.email.html
30
	 */
31
	protected $regex = '^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$';
32
33
	/**
34
	 * Method to test the email address and optionally check for uniqueness.
35
	 *
36
	 * @param   SimpleXMLElement  $element  The SimpleXMLElement object representing the <field /> tag for the form field object.
37
	 * @param   mixed             $value    The form field value to validate.
38
	 * @param   string            $group    The field name group control value. This acts as as an array container for the field.
39
	 *                                      For example if the field has name="foo" and the group value is set to "bar" then the
40
	 *                                      full field name would end up being "bar[foo]".
41
	 * @param   Registry          $input    An optional Registry object with the entire data set to validate against the entire form.
42
	 * @param   Form              $form     The form object for which the field is being tested.
43
	 *
44
	 * @return  boolean  True if the value is valid, false otherwise.
45
	 *
46
	 * @since   1.0
47
	 */
48
	public function test(SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null)
49
	{
50
		// If the field is empty and not required, the field is valid.
51
		$required = ((string) $element['required'] == 'true' || (string) $element['required'] == 'required');
52
53
		if (!$required && empty($value))
54
		{
55
			return true;
56
		}
57
58
		// If the tld attribute is present, change the regular expression to require at least 2 characters for it.
59
		$tld = ((string) $element['tld'] == 'tld' || (string) $element['tld'] == 'required');
60
61
		if ($tld)
62
		{
63
			$this->regex = '^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])'
64
				. '?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+$';
65
		}
66
67
		// Determine if the multiple attribute is present
68
		$multiple = ((string) $element['multiple'] == 'true' || (string) $element['multiple'] == 'multiple');
69
70
		if ($multiple)
71
		{
72
			$values = explode(',', $value);
73
		}
74
75
		if (!$multiple)
76
		{
77
			// Test the value against the regular expression.
78
			if (!parent::test($element, $value, $group, $input, $form))
79
			{
80
				return false;
81
			}
82
		}
83
		else
84
		{
85
			foreach ($values as $value)
0 ignored issues
show
The variable $values does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
86
			{
87
				// Test the value against the regular expression.
88
				if (!parent::test($element, $value, $group, $input, $form))
89
				{
90
					return false;
91
				}
92
			}
93
		}
94
95
		return true;
96
	}
97
}
98