Issues (73)

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/FormComposite.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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 14 and the first side effect is on line 3.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
namespace WFV;
3
defined( 'ABSPATH' ) || die();
4
5
use WFV\Artisan\FormArtisan;
6
use WFV\Contract\ValidateInterface;
7
use WFV\RuleFactory;
8
9
/**
10
 * Form Composition
11
 *
12
 * @since 0.10.0
13
 */
14
class FormComposite {
15
16
	/**
17
	 *
18
	 *
19
	 * @since 0.10.0
20
	 * @access private
21
	 * @var string
22
	 */
23
	protected $alias;
24
25
	/**
26
	 *
27
	 *
28
	 * @since 0.10.0
29
	 * @access protected
30
	 * @var array
31
	 */
32
	protected $collection;
33
34
	/**
35
	 *
36
	 *
37
	 * @since 0.10.0
38
	 *
39
	 * @param ArtisanInterface $builder
40
	 */
41
	public function __construct( FormArtisan $builder ) {
42
		$this->alias = $builder->action;
43
		$this->collection = $builder->collection;
44
	}
45
46
	/**
47
	 * Convenience method to repopulate checkbox input
48
	 *
49
	 * @since 0.10.0
50
	 *
51
	 * @param string $field Field name.
52
	 * @param string $value Value to compare against.
53
	 * @return string|null
54
	 */
55
	public function checked_if( $field = null, $value = null ) {
56
		return $this->string_or_null( 'checked', $field, $value );
57
	}
58
59
	/**
60
	 * Echo the encoded value of given field from a callback
61
	 * Default callback is esc_html()
62
	 * Also returns the encoded string for assignment
63
	 *
64
	 * @since 0.10.1
65
	 *
66
	 * @param string (optional) $field
67
	 * @param callable (optional) $callback
68
	 * @return string
69
	 */
70
	public function display( $field = null, callable $callback = null ) {
0 ignored issues
show
The parameter $callback is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
71
		echo $input = $this->utilize('input')->escape( $field );
72
		return $input;
73
	}
74
75
	/**
76
	 * Use error collection
77
	 *
78
	 *
79
	 * @since 0.10.0
80
	 *
81
	 * @return WFV\Collection\ErrorCollection
82
	 */
83
	public function errors() {
84
		return $this->utilize('errors');
85
	}
86
87
	/**
88
	 * Convenience method to check if form has input errors
89
	 *
90
	 *
91
	 * @since 0.12.0
92
	 *
93
	 * @return bool
94
	 */
95
	public function has_errors() {
96
		return $this->utilize('errors')->is_populated();
97
	}
98
99
	/**
100
	 * Use input collection
101
	 *
102
	 * @since 0.10.0
103
	 *
104
	 * @return WFV\Collection\InputCollection
105
	 */
106
	public function input() {
107
		return $this->utilize('input');
108
	}
109
110
	/**
111
	 * Convenience method to check if validation passed
112
	 *
113
	 * @since 0.12.0
114
	 *
115
	 * @return bool
116
	 */
117
	public function is_valid() {
118
		return ( $this->input()->is_populated() ) &&
119
			!$this->has_errors();
120
	}
121
122
	/**
123
	 * Return the form name/action
124
	 *
125
	 * @since 0.11.3
126
	 *
127
	 * @return string
128
	 */
129
	public function name() {
130
		return $this->alias;
131
	}
132
133
	/**
134
	 * Use rules collection
135
	 *
136
	 * @since 0.11.0
137
	 *
138
	 * @return WFV\Collection\RuleCollection
139
	 */
140
	public function rules() {
141
		return $this->utilize('rules');
142
	}
143
144
	/**
145
	 * Convenience method to repopulate select input
146
	 *
147
	 * @since 0.10.0
148
	 *
149
	 * @param string $field Field name.
150
	 * @param string $value Value to compare against.
151
	 * @return string|null
152
	 */
153
	public function selected_if( $field = null, $value = null ) {
154
		return $this->string_or_null( 'selected', $field, $value );
155
	}
156
157
	/**
158
	 * Convienience method to print the hidden fields
159
	 *  for token and action
160
	 *
161
	 * @since 0.10.0
162
	 *
163
	 */
164
	public function token_fields() {
165
		// TODO - Move markup into something - perhaps a renderable interface?
166
		$token_name = $this->alias . '_token';
167
		echo $nonce_field = wp_nonce_field( $this->alias, $token_name, false, false );
168
		echo $action_field = '<input type="hidden" name="action" value="'. $this->alias .'">';
169
	}
170
171
	/**
172
	 *
173
	 *
174
	 * @since 0.10.0
175
	 * @access protected
176
	 *
177
	 * @param string $response
178
	 * @param string (optional) $field
179
	 * @param string (optional) $value
180
	 * @return string|null
181
	 */
182
	protected function string_or_null( $response, $field = null, $value = null ) {
183
		$input = $this->utilize('input');
184
		return ( $input->contains( $field, $value ) ) ? $response : null;
185
	}
186
187
	/**
188
	 * Use a component.
189
	 *
190
	 * @since 0.10.0
191
	 * @access protected
192
	 *
193
	 * @param string $component Key indentifier.
194
	 */
195
	protected function utilize( $component ) {
196
		return $this->collection[ $component ];
197
	}
198
}
199