Issues (41)

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

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
namespace mindplay\kissform;
4
5
use InvalidArgumentException;
6
use mindplay\kissform\Facets\FieldInterface;
7
use mindplay\kissform\Validators\CheckRequired;
8
9
/**
10
 * Optional base class for mutable input field metadata types.
11
 *
12
 * The getValue() and setValue() methods may be overriden in field types
13
 * and should perform conversion to/from native values, and should throw
14
 * exceptions if invalid input or values is given, because validation is
15
 * assumed to have taken place in advance. The default implementations
16
 * handle strings and can be inherited in string-type fields.
17
 *
18
 * getValue() overrides should throw an {@see UnexpectedValueException}
19
 * if the state of the input model is invalid.
20
 *
21
 * setValue() overrides should throw an {@see InvalidArgumentException}
22
 * if the given value is unacceptable.
23
 */
24
abstract class Field implements FieldInterface
25
{
26
    /**
27
     * @var string field name
28
     */
29
    protected $name;
30
31
    /**
32
     * @var string field label (for labels associated with this input field on a form)
33
     */
34
    protected $label;
35
36
    /**
37
     * @var string field input placeholder value (for input placeholders on forms)
38
     */
39
    protected $placeholder;
40
41
    /**
42
     * @var bool true, if this field is required
43
     */
44
    protected $required = false;
45
46
    /**
47
     * @param string $name field name
48
     */
49 57
    public function __construct($name)
50
    {
51 57
        $this->name = $name;
52 57
    }
53
54 44
    public function getName()
55
    {
56 44
        return $this->name;
57
    }
58
59 17
    public function getLabel()
60
    {
61 17
        return $this->label;
62
    }
63
64 12
    public function getPlaceholder()
65
    {
66 12
        return $this->placeholder;
67
    }
68
69 24
    public function isRequired()
70
    {
71 24
        return $this->required;
72
    }
73
74
    public function getValue(InputModel $model)
75
    {
76
        return $model->getInput($this);
0 ignored issues
show
Bug Compatibility introduced by
The expression $model->getInput($this); of type string|array|null adds the type array to the return on line 76 which is incompatible with the return type declared by the interface mindplay\kissform\Facets\FieldInterface::getValue of type string|null.
Loading history...
77
    }
78
79 10
    public function createValidators()
80
    {
81 10
        return $this->isRequired()
82 9
            ? [new CheckRequired()]
83 10
            : [];
84
    }
85
86
    /**
87
     * @param string $label display label
88
     */
89 18
    public function setLabel($label)
90
    {
91 18
        $this->label = $label;
92 18
    }
93
94
    /**
95
     * @param string $placeholder placeholder label
96
     */
97 1
    public function setPlaceholder($placeholder)
98
    {
99 1
        $this->placeholder = $placeholder;
100 1
    }
101
102
    /**
103
     * @param bool $required TRUE, if input is required for this Field; FALSE, if it's optional
104
     */
105 15
    public function setRequired($required = true)
106
    {
107 15
        $this->required = (bool) $required;
108 15
    }
109
110
    /**
111
     * @param InputModel  $model
112
     * @param string|null $value
113
     *
114
     * @return void
115
     *
116
     * @throws InvalidArgumentException if the given value is unacceptable.
117
     */
118 8
    public function setValue(InputModel $model, $value)
119
    {
120 8
        if (is_scalar($value)) {
121 8
            $model->setInput($this, (string) $value);
122 1
        } elseif ($value === null) {
123 1
            $model->setInput($this, null);
124
        } else {
125
            throw new InvalidArgumentException("string expected");
126
        }
127 8
    }
128
}
129