Issues (2873)

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.

classes/fields/email.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
/**
4
 * @package Pods\Fields
5
 */
6
class PodsField_Email extends PodsField {
7
8
	/**
9
	 * {@inheritdoc}
10
	 */
11
	public static $group = 'Text';
12
13
	/**
14
	 * {@inheritdoc}
15
	 */
16
	public static $type = 'email';
17
18
	/**
19
	 * {@inheritdoc}
20
	 */
21
	public static $label = 'E-mail';
22
23
	/**
24
	 * {@inheritdoc}
25
	 */
26
	public static $prepare = '%s';
27
28
	/**
29
	 * {@inheritdoc}
30
	 */
31
	public function setup() {
32
33
		self::$label = __( 'E-mail', 'pods' );
34
	}
35
36
	/**
37
	 * {@inheritdoc}
38
	 */
39
	public function options() {
40
41
		$options = array(
42
			static::$type . '_repeatable'  => array(
43
				'label'             => __( 'Repeatable Field', 'pods' ),
44
				'default'           => 0,
45
				'type'              => 'boolean',
46
				'help'              => __( 'Making a field repeatable will add controls next to the field which allows users to Add/Remove/Reorder additional values. These values are saved in the database as an array, so searching and filtering by them may require further adjustments".', 'pods' ),
47
				'boolean_yes_label' => '',
48
				'dependency'        => true,
49
				'developer_mode'    => true,
50
			),
51
			static::$type . '_max_length'  => array(
52
				'label'   => __( 'Maximum Length', 'pods' ),
53
				'default' => 255,
54
				'type'    => 'number',
55
				'help'    => __( 'Set to -1 for no limit', 'pods' ),
56
			),
57
			static::$type . '_html5'       => array(
58
				'label'   => __( 'Enable HTML5 Input Field?', 'pods' ),
59
				'default' => apply_filters( 'pods_form_ui_field_html5', 0, static::$type ),
60
				'type'    => 'boolean',
61
			),
62
			static::$type . '_placeholder' => array(
63
				'label'   => __( 'HTML Placeholder', 'pods' ),
64
				'default' => '',
65
				'type'    => 'text',
66
				'help'    => array(
67
					__( 'Placeholders can provide instructions or an example of the required data format for a field. Please note: It is not a replacement for labels or description text, and it is less accessible for people using screen readers.', 'pods' ),
68
					'https://www.w3.org/WAI/tutorials/forms/instructions/#placeholder-text',
69
				),
70
			),
71
		);
72
73
		return $options;
74
	}
75
76
	/**
77
	 * {@inheritdoc}
78
	 */
79
	public function schema( $options = null ) {
80
81
		$length = (int) pods_v( static::$type . '_max_length', $options, 255 );
82
83
		$schema = 'VARCHAR(' . $length . ')';
84
85
		if ( 255 < $length || $length < 1 ) {
86
			$schema = 'LONGTEXT';
87
		}
88
89
		return $schema;
90
	}
91
92
	/**
93
	 * {@inheritdoc}
94
	 */
95
	public function input( $name, $value = null, $options = null, $pod = null, $id = null ) {
96
97
		$options         = (array) $options;
98
		$form_field_type = PodsForm::$field_type;
99
100
		if ( is_array( $value ) ) {
101
			$value = implode( ' ', $value );
102
		}
103
104
		$field_type = 'email';
105
106
		if ( isset( $options['name'] ) && false === PodsForm::permission( static::$type, $options['name'], $options, null, $pod, $id ) ) {
107
			if ( pods_v( 'read_only', $options, false ) ) {
108
				$options['readonly'] = true;
109
110
				$field_type = 'text';
111
			} else {
112
				return;
113
			}
114
		} elseif ( ! pods_has_permissions( $options ) && pods_v( 'read_only', $options, false ) ) {
115
			$options['readonly'] = true;
116
117
			$field_type = 'text';
118
		}
119
120
		pods_view( PODS_DIR . 'ui/fields/' . $field_type . '.php', compact( array_keys( get_defined_vars() ) ) );
121
	}
122
123
	/**
124
	 * {@inheritdoc}
125
	 */
126
	public function validate( $value, $name = null, $options = null, $fields = null, $pod = null, $id = null, $params = null ) {
127
128
		$errors = array();
129
130
		$check = $this->pre_save( $value, $id, $name, $options, $fields, $pod, $params );
131
132
		if ( is_array( $check ) ) {
133
			$errors = $check;
134
		} else {
135
			if ( 0 < strlen( $value ) && '' === $check ) {
136
				$label = pods_v( 'label', $options, ucwords( str_replace( '_', ' ', $name ) ) );
137
138
				if ( 1 === (int) pods_v( 'required', $options ) ) {
139
					$errors[] = sprintf( __( '%s is required', 'pods' ), $label );
140
				} else {
141
					$errors[] = sprintf( __( 'Invalid e-mail provided for %s', 'pods' ), $label );
142
				}
143
			}
144
		}
145
146
		if ( ! empty( $errors ) ) {
147
			return $errors;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $errors; (array) is incompatible with the return type of the parent method PodsField::validate of type boolean.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
148
		}
149
150
		return true;
151
	}
152
153
	/**
154
	 * {@inheritdoc}
155
	 */
156
	public function pre_save( $value, $id = null, $name = null, $options = null, $fields = null, $pod = null, $params = null ) {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
157
158
		$options = (array) $options;
159
160
		if ( ! is_email( $value ) ) {
161
			$value = '';
162
		}
163
164
		$length = (int) pods_v( static::$type . '_max_length', $options, 255 );
165
166
		if ( 0 < $length && $length < pods_mb_strlen( $value ) ) {
167
			$value = pods_mb_substr( $value, 0, $length );
168
		}
169
170
		return $value;
171
	}
172
173
	/**
174
	 * {@inheritdoc}
175
	 */
176
	public function ui( $id, $value, $name = null, $options = null, $fields = null, $pod = null ) {
0 ignored issues
show
This method's name is shorter than the configured minimum length of 3 characters.

Even though PHP does not care about the name of your methods, it is generally a good practice to choose method names which can be easily understood by other human readers.

Loading history...
177
178
		return '<a href="mailto:' . esc_attr( $value ) . '">' . $value . '</a>';
179
	}
180
}
181